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 00a39c6 commit 8635e3f
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"

Check warning on line 493 in ee/tabby-schema/src/dao.rs

View check run for this annotation

Codecov / codecov/patch

ee/tabby-schema/src/dao.rs#L490-L493

Added lines #L490 - L493 were not covered by tests
}
}

Check warning on line 495 in ee/tabby-schema/src/dao.rs

View check run for this annotation

Codecov / codecov/patch

ee/tabby-schema/src/dao.rs#L495

Added line #L495 was not covered by tests

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"),

Check warning on line 501 in ee/tabby-schema/src/dao.rs

View check run for this annotation

Codecov / codecov/patch

ee/tabby-schema/src/dao.rs#L497-L501

Added lines #L497 - L501 were not covered by tests
}
}

Check warning on line 503 in ee/tabby-schema/src/dao.rs

View check run for this annotation

Codecov / codecov/patch

ee/tabby-schema/src/dao.rs#L503

Added line #L503 was not covered by tests
}
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)]

Check warning on line 3 in ee/tabby-schema/src/schema/notification.rs

View check run for this annotation

Codecov / codecov/patch

ee/tabby-schema/src/schema/notification.rs#L3

Added line #L3 was not covered by tests
pub enum NotificationKind {
Admin,
AllUser,
}

0 comments on commit 8635e3f

Please sign in to comment.