-
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.
* chore: remove account data * chore: snake_case * chore: more changes * chore: export names * chore: remove send_id * chore: tweaks * chore: message_id * chore: subscriber_pk * chore: comment * chore: reorder and comments * chore: add project_pk * chore: notify_topic -> notification_topic * chore: keep as Uuid * chore: export JWT ss & domain
- Loading branch information
1 parent
cc5c00d
commit 296d39e
Showing
12 changed files
with
260 additions
and
175 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,53 @@ | ||
use { | ||
crate::model::types::AccountId, | ||
parquet_derive::ParquetRecordWriter, | ||
relay_rpc::domain::{ProjectId, Topic}, | ||
serde::Serialize, | ||
std::sync::Arc, | ||
uuid::Uuid, | ||
}; | ||
|
||
pub struct SubscriberNotificationParams { | ||
pub project_pk: Uuid, | ||
pub project_id: ProjectId, | ||
pub subscriber_pk: Uuid, | ||
pub account: AccountId, | ||
pub notification_type: Arc<str>, | ||
pub notify_topic: Topic, | ||
pub message_id: Arc<str>, | ||
} | ||
|
||
#[derive(Debug, Serialize, ParquetRecordWriter)] | ||
pub struct SubscriberNotification { | ||
/// Time at which the event was generated | ||
pub event_at: chrono::NaiveDateTime, | ||
/// Primary key of the project in the Notify Server database that the notification was sent from and the subscriber is subscribed to | ||
pub project_pk: Uuid, | ||
/// Project ID of the project that the notification was sent from and the subscriber is subscribed to | ||
pub project_id: Arc<str>, | ||
/// Primary key of the subscriber in the Notify Server database that the notificaiton is being sent to | ||
pub subscriber_pk: Uuid, | ||
/// Hash of the CAIP-10 account of the subscriber | ||
pub account_hash: String, | ||
/// The notification type ID | ||
pub notification_type: Arc<str>, | ||
/// The topic that the notification was sent on | ||
pub notification_topic: Arc<str>, | ||
/// Relay message ID of the notification | ||
pub message_id: Arc<str>, | ||
} | ||
|
||
impl From<SubscriberNotificationParams> for SubscriberNotification { | ||
fn from(params: SubscriberNotificationParams) -> Self { | ||
Self { | ||
event_at: wc::analytics::time::now(), | ||
project_pk: params.project_pk, | ||
project_id: params.project_id.into_value(), | ||
subscriber_pk: params.subscriber_pk, | ||
account_hash: sha256::digest(params.account.as_ref()), | ||
notification_type: params.notification_type, | ||
notification_topic: params.notify_topic.into_value(), | ||
message_id: params.message_id, | ||
} | ||
} | ||
} |
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,90 @@ | ||
use { | ||
crate::model::types::AccountId, | ||
itertools::Itertools, | ||
parquet_derive::ParquetRecordWriter, | ||
relay_rpc::domain::{ProjectId, Topic}, | ||
serde::Serialize, | ||
std::{ | ||
collections::HashSet, | ||
fmt::{self, Display, Formatter}, | ||
sync::Arc, | ||
}, | ||
uuid::Uuid, | ||
}; | ||
|
||
pub enum NotifyClientMethod { | ||
Subscribe, | ||
Update, | ||
Unsubscribe, | ||
} | ||
|
||
impl Display for NotifyClientMethod { | ||
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result { | ||
match self { | ||
Self::Subscribe => write!(f, "subscribe"), | ||
Self::Update => write!(f, "update"), | ||
Self::Unsubscribe => write!(f, "unsubscribe"), | ||
} | ||
} | ||
} | ||
|
||
pub struct SubscriberUpdateParams { | ||
pub project_pk: Uuid, | ||
pub project_id: ProjectId, | ||
pub pk: Uuid, | ||
pub account: AccountId, | ||
pub updated_by_iss: Arc<str>, | ||
pub updated_by_domain: String, | ||
pub method: NotifyClientMethod, | ||
pub old_scope: HashSet<Arc<str>>, | ||
pub new_scope: HashSet<Arc<str>>, | ||
pub notification_topic: Topic, | ||
pub topic: Topic, | ||
} | ||
|
||
#[derive(Debug, Serialize, ParquetRecordWriter)] | ||
pub struct SubscriberUpdate { | ||
/// Time at which the event was generated | ||
pub event_at: chrono::NaiveDateTime, | ||
/// Primary key of the project in the Notify Server database that the subscriber is subscribed to | ||
pub project_pk: Uuid, | ||
/// 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 pk: Uuid, | ||
/// Hash of the CAIP-10 account of the subscriber | ||
pub account_hash: String, | ||
/// JWT iss that made the update | ||
pub updated_by_iss: Arc<str>, | ||
/// CACAO domain that made the update | ||
pub updated_by_domain: String, | ||
/// The change that happend to the subscriber, can be subscribe, update, or unsubscribe | ||
pub method: String, | ||
/// Notification types that the subscriber was subscribed to before the update, separated by commas | ||
pub old_scope: String, | ||
/// Notification types that the subscriber is subscribed to after the update, separated by commas | ||
pub new_scope: String, | ||
/// The topic that notifications are sent on | ||
pub notification_topic: Arc<str>, | ||
/// The topic used to create or manage the subscription that the update message was published to | ||
pub topic: Arc<str>, | ||
} | ||
|
||
impl From<SubscriberUpdateParams> for SubscriberUpdate { | ||
fn from(params: SubscriberUpdateParams) -> Self { | ||
Self { | ||
event_at: wc::analytics::time::now(), | ||
project_pk: params.project_pk, | ||
project_id: params.project_id.into_value(), | ||
pk: params.pk, | ||
account_hash: sha256::digest(params.account.as_ref()), | ||
updated_by_iss: params.updated_by_iss, | ||
updated_by_domain: params.updated_by_domain, | ||
method: params.method.to_string(), | ||
old_scope: params.old_scope.iter().join(","), | ||
new_scope: params.new_scope.iter().join(","), | ||
notification_topic: params.notification_topic.into_value(), | ||
topic: params.topic.into_value(), | ||
} | ||
} | ||
} |
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.