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:
copilot-swe-agent[bot]
2025-11-06 22:34:57 +00:00
parent 12b21c6cb3
commit d946979b88

View File

@@ -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(())