Skip to content

Commit

Permalink
feat: add message id to watch event payload (#57)
Browse files Browse the repository at this point in the history
  • Loading branch information
heilhead authored Jan 31, 2024
1 parent d2a772f commit b4683d7
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions relay_rpc/src/rpc/watch.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use {
crate::{
domain::Topic,
domain::{MessageId, Topic},
jwt::{JwtBasicClaims, VerifyableClaims},
},
serde::{Deserialize, Serialize},
Expand Down Expand Up @@ -77,6 +77,8 @@ impl VerifyableClaims for WatchUnregisterClaims {
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct WatchEventPayload {
/// Message ID.
pub message_id: MessageId,
/// Webhook status. Either `accepted`, `queued` or `delivered`.
pub status: WatchStatus,
/// Topic of the message that triggered the watch event.
Expand Down Expand Up @@ -220,6 +222,7 @@ mod test {
whu: "https://example.com".to_owned(),
typ: WatchType::Subscriber,
evt: WatchEventPayload {
message_id: 12345678.into(),
status: WatchStatus::Accepted,
topic,
message: Arc::from("test message"),
Expand All @@ -232,7 +235,7 @@ mod test {
// lowercase.
assert_eq!(
serde_json::to_string(&claims).unwrap(),
r#"{"iss":"did:key:z6Mku3wsRZTAHjr6xrYWVUfyGeNSNz1GJRVfazp3N76AL9gE","aud":"wss://relay.walletconnect.com","sub":"https://example.com","iat":946684800,"exp":32503680000,"act":"irn_watchEvent","typ":"subscriber","whu":"https://example.com","evt":{"status":"accepted","topic":"474e88153f4db893de42c35e1891dc0e37a02e11961385de0475460fb48b8639","message":"test message","publishedAt":946684800,"tag":1100}}"#
r#"{"iss":"did:key:z6Mku3wsRZTAHjr6xrYWVUfyGeNSNz1GJRVfazp3N76AL9gE","aud":"wss://relay.walletconnect.com","sub":"https://example.com","iat":946684800,"exp":32503680000,"act":"irn_watchEvent","typ":"subscriber","whu":"https://example.com","evt":{"messageId":12345678,"status":"accepted","topic":"474e88153f4db893de42c35e1891dc0e37a02e11961385de0475460fb48b8639","message":"test message","publishedAt":946684800,"tag":1100}}"#
);

// Verify that the claims can be encoded and decoded correctly.
Expand Down

0 comments on commit b4683d7

Please sign in to comment.