2021-12-05 09:29:42 +08:00
|
|
|
use flowy_derive::ProtoBuf_Enum;
|
2023-01-26 15:40:23 +08:00
|
|
|
use flowy_notification::NotificationBuilder;
|
2023-07-29 09:46:24 +08:00
|
|
|
|
2023-08-20 14:13:54 +08:00
|
|
|
use crate::entities::AuthStateChangedPB;
|
|
|
|
|
2023-07-05 20:57:09 +08:00
|
|
|
const USER_OBSERVABLE_SOURCE: &str = "User";
|
2021-09-07 23:30:43 +08:00
|
|
|
|
2023-06-09 22:23:07 +08:00
|
|
|
#[derive(ProtoBuf_Enum, Debug, Default)]
|
2021-10-14 14:34:22 +08:00
|
|
|
pub(crate) enum UserNotification {
|
2023-06-09 22:23:07 +08:00
|
|
|
#[default]
|
2023-02-13 09:29:49 +08:00
|
|
|
Unknown = 0,
|
2023-08-20 14:13:54 +08:00
|
|
|
UserAuthStateChanged = 1,
|
2023-02-13 09:29:49 +08:00
|
|
|
DidUpdateUserProfile = 2,
|
2023-07-29 09:46:24 +08:00
|
|
|
DidUpdateUserWorkspaces = 3,
|
2023-08-17 23:46:39 +08:00
|
|
|
DidUpdateCloudConfig = 4,
|
2024-05-10 16:08:32 +02:00
|
|
|
DidUpdateUserWorkspace = 5,
|
2024-06-25 01:59:38 +02:00
|
|
|
DidUpdateAISetting = 6,
|
2021-09-07 23:30:43 +08:00
|
|
|
}
|
|
|
|
|
2021-11-27 19:19:41 +08:00
|
|
|
impl std::convert::From<UserNotification> for i32 {
|
2023-02-13 09:29:49 +08:00
|
|
|
fn from(notification: UserNotification) -> Self {
|
|
|
|
notification as i32
|
|
|
|
}
|
2021-09-07 23:30:43 +08:00
|
|
|
}
|
|
|
|
|
2023-10-24 20:11:06 +08:00
|
|
|
#[tracing::instrument(level = "trace")]
|
2023-01-27 17:17:51 +08:00
|
|
|
pub(crate) fn send_notification(id: &str, ty: UserNotification) -> NotificationBuilder {
|
2023-07-05 20:57:09 +08:00
|
|
|
NotificationBuilder::new(id, ty, USER_OBSERVABLE_SOURCE)
|
2021-10-05 11:46:56 +08:00
|
|
|
}
|
2023-01-27 17:17:51 +08:00
|
|
|
|
2023-10-24 23:13:51 +08:00
|
|
|
#[tracing::instrument(level = "trace")]
|
2023-12-30 07:05:26 +08:00
|
|
|
pub(crate) fn send_auth_state_notification(payload: AuthStateChangedPB) {
|
2023-08-20 14:13:54 +08:00
|
|
|
NotificationBuilder::new(
|
|
|
|
"auth_state_change_notification",
|
|
|
|
UserNotification::UserAuthStateChanged,
|
|
|
|
USER_OBSERVABLE_SOURCE,
|
|
|
|
)
|
|
|
|
.payload(payload)
|
2023-12-30 07:05:26 +08:00
|
|
|
.send()
|
2023-01-27 17:17:51 +08:00
|
|
|
}
|