Skip to content

Commit ceee02c

Browse files
committed
mls-sqlite-storage: update save group SQL to handle conflicts
Pull-Request: #854 Signed-off-by: Yuki Kishimoto <[email protected]>
1 parent 7edeac7 commit ceee02c

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

crates/nostr-mls-sqlite-storage/src/groups.rs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,20 @@ impl GroupStorage for NostrMlsSqliteStorage {
8787

8888
conn_guard
8989
.execute(
90-
"INSERT OR REPLACE INTO groups
90+
"INSERT INTO groups
9191
(mls_group_id, nostr_group_id, name, description, admin_pubkeys, last_message_id,
9292
last_message_at, group_type, epoch, state)
93-
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
93+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
94+
ON CONFLICT(mls_group_id) DO UPDATE SET
95+
nostr_group_id = excluded.nostr_group_id,
96+
name = excluded.name,
97+
description = excluded.description,
98+
admin_pubkeys = excluded.admin_pubkeys,
99+
last_message_id = excluded.last_message_id,
100+
last_message_at = excluded.last_message_at,
101+
group_type = excluded.group_type,
102+
epoch = excluded.epoch,
103+
state = excluded.state",
94104
params![
95105
&group.mls_group_id.as_slice(),
96106
&group.nostr_group_id,

0 commit comments

Comments
 (0)