Skip to content

Commit

Permalink
try send message in async transaction
Browse files Browse the repository at this point in the history
  • Loading branch information
cameronvoell committed Jan 10, 2025
1 parent 5a83340 commit 39bc5d4
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions xmtp_mls/src/groups/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -717,19 +717,21 @@ impl<ScopedClient: ScopedGroupClient> MlsGroup<ScopedClient> {
message: &[u8],
provider: &XmtpOpenMlsProvider,
) -> Result<Vec<u8>, GroupError> {
let update_interval_ns = Some(SEND_MESSAGE_UPDATE_INSTALLATIONS_INTERVAL_NS);
self.maybe_update_installations(provider, update_interval_ns)
.await?;

let message_id =
self.prepare_message(message, provider, |now| Self::into_envelope(message, now));

self.sync_until_last_intent_resolved(provider).await?;

// implicitly set group consent state to allowed
self.update_consent_state(provider, ConsentState::Allowed)?;

message_id
self.context().store().transaction_async(provider, |tx_provider| async move {
let update_interval_ns = Some(SEND_MESSAGE_UPDATE_INSTALLATIONS_INTERVAL_NS);
self.maybe_update_installations(tx_provider, update_interval_ns).await?;

let message_id = self.prepare_message(
message,
tx_provider,
|now| Self::into_envelope(message, now)
)?;

self.sync_until_last_intent_resolved(tx_provider).await?;
self.update_consent_state(tx_provider, ConsentState::Allowed)?;

Ok(message_id)
}).await
}

/// Publish all unpublished messages. This happens by calling `sync_until_last_intent_resolved`
Expand Down

0 comments on commit 39bc5d4

Please sign in to comment.