Skip to content

Commit

Permalink
add NotificationKind
Browse files Browse the repository at this point in the history
  • Loading branch information
wsxiaoys committed Dec 5, 2024
1 parent 9f0f8c1 commit 271748b
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 5 deletions.
24 changes: 19 additions & 5 deletions ee/tabby-schema/src/dao.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@ use tabby_db::{
};

use crate::{
integration::{Integration, IntegrationKind, IntegrationStatus},
repository::RepositoryKind,
schema::{
integration::{Integration, IntegrationKind, IntegrationStatus}, notification::NotificationKind, repository::RepositoryKind, schema::{
auth::{self, OAuthCredential, OAuthProvider},
email::{AuthMethod, EmailSetting, Encryption},
job,
Expand All @@ -21,8 +19,7 @@ use crate::{
setting::{NetworkSetting, SecuritySetting},
user_event::{EventKind, UserEvent},
CoreError,
},
thread::{self, MessageAttachment},
}, thread::{self, MessageAttachment}
};

impl From<InvitationDAO> for auth::Invitation {
Expand Down Expand Up @@ -488,3 +485,20 @@ impl DbEnum for thread::Role {
}
}
}

impl DbEnum for NotificationKind {
fn as_enum_str(&self) -> &'static str {
match self {
NotificationKind::Admin => "admin",
NotificationKind::AllUser => "all_user"
}
}

fn from_enum_str(s: &str) -> anyhow::Result<Self> {
match s {
"admin" => Ok(NotificationKind::Admin),
"all_user" => Ok(NotificationKind::AllUser),
_ => bail!("{s} is not a valid value for NotificationKind"),
}
}
}
1 change: 1 addition & 0 deletions ee/tabby-schema/src/schema/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ pub mod user_event;
pub mod user_group;
pub mod web_documents;
pub mod worker;
pub mod notification;

use std::{sync::Arc, time::Instant};

Expand Down
7 changes: 7 additions & 0 deletions ee/tabby-schema/src/schema/notification.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
use juniper::GraphQLEnum;

#[derive(GraphQLEnum, Clone, Debug)]
pub enum NotificationKind {
Admin,
AllUser,
}

0 comments on commit 271748b

Please sign in to comment.