mirror of
https://github.com/chatmail/core.git
synced 2026-05-02 04:46:29 +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.param.set_i64(CALL_ENDED_TIMESTAMP, now);
|
||||||
self.msg.update_param(context).await?;
|
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
|
context
|
||||||
.sql
|
.sql
|
||||||
.execute(
|
.execute(
|
||||||
"UPDATE calls SET ended_timestamp=? WHERE msg_id=?",
|
"INSERT INTO calls (msg_id, ended_timestamp) VALUES (?, ?)
|
||||||
(now, self.msg.id),
|
ON CONFLICT(msg_id) DO UPDATE SET ended_timestamp=excluded.ended_timestamp",
|
||||||
|
(self.msg.id, now),
|
||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
Ok(())
|
Ok(())
|
||||||
@@ -163,12 +164,13 @@ impl CallInfo {
|
|||||||
self.msg.param.set_i64(CALL_CANCELED_TIMESTAMP, now);
|
self.msg.param.set_i64(CALL_CANCELED_TIMESTAMP, now);
|
||||||
self.msg.update_param(context).await?;
|
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
|
context
|
||||||
.sql
|
.sql
|
||||||
.execute(
|
.execute(
|
||||||
"UPDATE calls SET ended_timestamp=? WHERE msg_id=?",
|
"INSERT INTO calls (msg_id, ended_timestamp) VALUES (?, ?)
|
||||||
(now, self.msg.id),
|
ON CONFLICT(msg_id) DO UPDATE SET ended_timestamp=excluded.ended_timestamp",
|
||||||
|
(self.msg.id, now),
|
||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|||||||
Reference in New Issue
Block a user