Skip to content

Commit

Permalink
replace id with topic
Browse files Browse the repository at this point in the history
  • Loading branch information
nplasterer committed Oct 17, 2024
1 parent c7fe699 commit 585d6aa
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions xmtp_mls/src/storage/encrypted_store/v2_conversation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,24 +74,24 @@ impl DbConnection {
.optional()?;

if maybe_inserted_conversation.is_none() {
let existing_conversation: StoredV2Conversation = dsl::v2_conversations.find(v2_conversation.id).first(conn)?;
if existing_conversation.welcome_id == v2_conversation.welcome_id {
let existing_conversation: StoredV2Conversation = dsl::v2_conversations.find(v2_conversation.topic).first(conn)?;
if existing_conversation.topic == v2_conversation.topic {
tracing::info!("V2 Conversation invite already exists");
// Error so OpenMLS db transaction are rolled back on duplicate welcomes
return Err(StorageError::Duplicate(DuplicateItem::WelcomeId(
existing_group.welcome_id,
existing_conversation.topic,
)));
} else {
tracing::info!("V2 Conversation already exists");
return Ok(existing_group);
return Ok(existing_conversation);
}
} else {
tracing::info!("V2 Conversation is inserted");
}

match maybe_inserted_conversation {
Some(v2_conversation) => Ok(v2_conversation),
None => Ok(dsl::v2_conversations.find(v2_conversation.id).first(conn)?),
None => Ok(dsl::v2_conversations.find(v2_conversation.topic).first(conn)?),
}
})?;

Expand Down

0 comments on commit 585d6aa

Please sign in to comment.