Skip to content

Commit

Permalink
Add sending sync message requests
Browse files Browse the repository at this point in the history
  • Loading branch information
direc85 authored Sep 29, 2024
1 parent 15d7f22 commit 67c1dfb
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions libsignal-service/src/sender.rs
Original file line number Diff line number Diff line change
Expand Up @@ -771,6 +771,37 @@ where
Ok(())
}

/// Send a `Keys` request message
#[tracing::instrument(skip(self))]
pub async fn send_sync_message_request(
&mut self,
recipient: &ServiceAddress,
request_type: sync_message::request::Type,
) -> Result<(), MessageSenderError> {
if self.device_id == DEFAULT_DEVICE_ID.into() {
let reason = format!(
"Primary device can't send sync requests, ignoring {:?}",
request_type
);
return Err(MessageSenderError::ServiceError(
ServiceError::SendError { reason },
));
}

let msg = SyncMessage {
request: Some(sync_message::Request {
r#type: Some(request_type.into()),
}),
..SyncMessage::with_padding()
};

let ts = Utc::now().timestamp_millis() as u64;
self.send_message(recipient, None, msg, ts, false, true)
.await?;

Ok(())
}

#[tracing::instrument(level = "trace", skip(self))]
fn create_pni_signature(
&mut self,
Expand Down

0 comments on commit 67c1dfb

Please sign in to comment.