This repository has been archived by the owner on Oct 19, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
47 changed files
with
525 additions
and
325 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
// Legacy models from V2, where its useful to keep the struct for rerouting/conversion | ||
pub mod projects; | ||
pub mod notifications; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
use chrono::{DateTime, Utc}; | ||
use serde::{Serialize, Deserialize}; | ||
|
||
use crate::models::{ids::{NotificationId, UserId}, notifications::{NotificationBody, Notification, NotificationAction}}; | ||
|
||
#[derive(Serialize, Deserialize)] | ||
pub struct LegacyNotification { | ||
pub id: NotificationId, | ||
pub user_id: UserId, | ||
pub read: bool, | ||
pub created: DateTime<Utc>, | ||
pub body: NotificationBody, | ||
|
||
// DEPRECATED: use body field instead | ||
#[serde(rename = "type")] | ||
pub type_: Option<String>, | ||
pub title: String, | ||
pub text: String, | ||
pub link: String, | ||
pub actions: Vec<LegacyNotificationAction>, | ||
} | ||
|
||
#[derive(Serialize, Deserialize, Clone)] | ||
pub struct LegacyNotificationAction { | ||
pub title: String, | ||
/// The route to call when this notification action is called. Formatted HTTP Method, route | ||
pub action_route: (String, String), | ||
} | ||
|
||
impl LegacyNotification { | ||
pub fn from(notification : Notification) -> Self { | ||
Self { | ||
id: notification.id, | ||
user_id: notification.user_id, | ||
read: notification.read, | ||
created: notification.created, | ||
body: notification.body, | ||
type_: notification.type_, | ||
title: notification.name, | ||
text: notification.text, | ||
link: notification.link, | ||
actions: notification.actions.into_iter().map(LegacyNotificationAction::from).collect() | ||
} | ||
} | ||
} | ||
|
||
impl LegacyNotificationAction { | ||
pub fn from(notification_action : NotificationAction) -> Self { | ||
Self { | ||
title: notification_action.name, | ||
action_route: notification_action.action_route | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.