Skip to content

Commit

Permalink
Store or ignore group messages (#1019)
Browse files Browse the repository at this point in the history
  • Loading branch information
neekolas authored Aug 29, 2024
1 parent 03471ef commit 0e51c34
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
10 changes: 5 additions & 5 deletions xmtp_mls/src/groups/sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ use crate::{
},
utils::{hash::sha256, id::calculate_message_id},
xmtp_openmls_provider::XmtpOpenMlsProvider,
Client, Delete, Fetch, Store, XmtpApi,
Client, Delete, Fetch, StoreOrIgnore, XmtpApi,
};
use futures::future::try_join_all;
use log::debug;
Expand Down Expand Up @@ -411,7 +411,7 @@ impl MlsGroup {
sender_inbox_id,
delivery_status: DeliveryStatus::Published,
}
.store(provider.conn_ref())?
.store_or_ignore(provider.conn_ref())?
}
Some(Content::V2(V2 {
idempotency_key,
Expand All @@ -438,7 +438,7 @@ impl MlsGroup {
sender_inbox_id: sender_inbox_id.clone(),
delivery_status: DeliveryStatus::Published,
}
.store(provider.conn_ref())?;
.store_or_ignore(provider.conn_ref())?;
}
Some(Reply(history_reply)) => {
let content: MessageHistoryContent =
Expand All @@ -461,7 +461,7 @@ impl MlsGroup {
sender_inbox_id,
delivery_status: DeliveryStatus::Published,
}
.store(provider.conn_ref())?;
.store_or_ignore(provider.conn_ref())?;
}
_ => {
return Err(MessageProcessingError::InvalidPayload);
Expand Down Expand Up @@ -725,7 +725,7 @@ impl MlsGroup {
delivery_status: DeliveryStatus::Published,
};

msg.store(conn)?;
msg.store_or_ignore(conn)?;
Ok(Some(msg))
}

Expand Down
3 changes: 2 additions & 1 deletion xmtp_mls/src/storage/encrypted_store/group_message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use super::{
db_connection::DbConnection,
schema::{group_messages, group_messages::dsl},
};
use crate::{impl_fetch, impl_store, StorageError};
use crate::{impl_fetch, impl_store, impl_store_or_ignore, StorageError};

#[derive(
Debug, Clone, Serialize, Deserialize, Insertable, Identifiable, Queryable, Eq, PartialEq,
Expand Down Expand Up @@ -106,6 +106,7 @@ where

impl_fetch!(StoredGroupMessage, group_messages, Vec<u8>);
impl_store!(StoredGroupMessage, group_messages);
impl_store_or_ignore!(StoredGroupMessage, group_messages);

impl DbConnection {
/// Query for group messages
Expand Down

0 comments on commit 0e51c34

Please sign in to comment.