mirror of
https://github.com/chatmail/core.git
synced 2026-04-23 00:16:34 +03:00
Use UPSERT for ended_timestamp to avoid replacing SDP data
Co-authored-by: link2xt <18373967+link2xt@users.noreply.github.com>
This commit is contained in:
14
src/calls.rs
14
src/calls.rs
@@ -139,12 +139,13 @@ impl CallInfo {
|
||||
self.msg.param.set_i64(CALL_ENDED_TIMESTAMP, now);
|
||||
self.msg.update_param(context).await?;
|
||||
|
||||
// Also store ended timestamp in calls table
|
||||
// Store ended timestamp in calls table. If no entry exists yet, create one.
|
||||
context
|
||||
.sql
|
||||
.execute(
|
||||
"UPDATE calls SET ended_timestamp=? WHERE msg_id=?",
|
||||
(now, self.msg.id),
|
||||
"INSERT INTO calls (msg_id, ended_timestamp) VALUES (?, ?)
|
||||
ON CONFLICT(msg_id) DO UPDATE SET ended_timestamp=excluded.ended_timestamp",
|
||||
(self.msg.id, now),
|
||||
)
|
||||
.await?;
|
||||
Ok(())
|
||||
@@ -163,12 +164,13 @@ impl CallInfo {
|
||||
self.msg.param.set_i64(CALL_CANCELED_TIMESTAMP, now);
|
||||
self.msg.update_param(context).await?;
|
||||
|
||||
// Also store ended timestamp in calls table
|
||||
// Store ended timestamp in calls table. If no entry exists yet, create one.
|
||||
context
|
||||
.sql
|
||||
.execute(
|
||||
"UPDATE calls SET ended_timestamp=? WHERE msg_id=?",
|
||||
(now, self.msg.id),
|
||||
"INSERT INTO calls (msg_id, ended_timestamp) VALUES (?, ?)
|
||||
ON CONFLICT(msg_id) DO UPDATE SET ended_timestamp=excluded.ended_timestamp",
|
||||
(self.msg.id, now),
|
||||
)
|
||||
.await?;
|
||||
Ok(())
|
||||
|
||||
Reference in New Issue
Block a user