-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: get notifications analytics (#410)
* fix: get notifications analytics * fix: basic request topic * fix: add message_id * fix: get_by_iss * feat: get_by_domain * feat: project details * fix: subscriber details * fix: add notification_topic * fix: returned_count * fix: notification details
- Loading branch information
1 parent
514f8e9
commit 46fb200
Showing
8 changed files
with
153 additions
and
34 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
use { | ||
crate::model::types::AccountId, | ||
parquet_derive::ParquetRecordWriter, | ||
relay_rpc::domain::{ProjectId, Topic}, | ||
serde::Serialize, | ||
std::sync::Arc, | ||
uuid::Uuid, | ||
}; | ||
|
||
pub struct GetNotificationsParams { | ||
pub topic: Topic, | ||
pub message_id: Arc<str>, | ||
pub get_by_iss: Arc<str>, | ||
pub get_by_domain: Arc<str>, | ||
pub project_pk: Uuid, | ||
pub project_id: ProjectId, | ||
pub subscriber_pk: Uuid, | ||
pub subscriber_account: AccountId, | ||
pub notification_topic: Topic, | ||
pub subscriber_notification_id: Uuid, | ||
pub notification_id: Uuid, | ||
pub notification_type: Uuid, | ||
pub returned_count: usize, | ||
} | ||
|
||
#[derive(Debug, Serialize, ParquetRecordWriter)] | ||
pub struct GetNotifications { | ||
/// Time at which the event was generated | ||
pub event_at: chrono::NaiveDateTime, | ||
/// The relay topic used to manage the subscription that the get notifications request message was published to | ||
pub topic: Arc<str>, | ||
/// Relay message ID of request | ||
pub message_id: Arc<str>, | ||
/// JWT iss that made the request | ||
pub get_by_iss: Arc<str>, | ||
/// CACAO domain that made the request | ||
pub get_by_domain: Arc<str>, | ||
/// Primary key of the project in the Notify Server database that the subscriber is subscribed to | ||
pub project_pk: String, | ||
/// Project ID of the project that the subscriber is subscribed to | ||
pub project_id: Arc<str>, | ||
/// Primary Key of the subscriber in the Notify Server database | ||
pub subscriber_pk: String, | ||
/// Hash of the CAIP-10 account of the subscriber | ||
pub subscriber_account_hash: String, | ||
/// The topic that notifications are sent on | ||
pub notification_topic: Arc<str>, | ||
/// The ID of the subscriber-specific notification | ||
pub subscriber_notification_id: Uuid, | ||
/// The ID of the notification | ||
pub notification_id: Uuid, | ||
/// The notification type ID | ||
pub notification_type: Uuid, | ||
/// The total number of notifications returned in the request | ||
pub returned_count: usize, | ||
} | ||
|
||
impl From<GetNotificationsParams> for GetNotifications { | ||
fn from(params: GetNotificationsParams) -> Self { | ||
Self { | ||
event_at: wc::analytics::time::now(), | ||
topic: params.topic.into_value(), | ||
message_id: params.message_id, | ||
get_by_iss: params.get_by_iss, | ||
get_by_domain: params.get_by_domain, | ||
project_pk: params.project_pk.to_string(), | ||
project_id: params.project_id.into_value(), | ||
subscriber_pk: params.subscriber_pk.to_string(), | ||
subscriber_account_hash: sha256::digest(params.subscriber_account.as_ref()), | ||
notification_topic: params.notification_topic.into_value(), | ||
subscriber_notification_id: params.subscriber_notification_id, | ||
notification_id: params.notification_id, | ||
notification_type: params.notification_type, | ||
returned_count: params.returned_count, | ||
} | ||
} | ||
} |
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
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