Add calls table to store SDPs separately from message params

Co-authored-by: link2xt <18373967+link2xt@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot]
2025-11-06 20:06:47 +00:00
parent abece73db1
commit c556b07380
4 changed files with 142 additions and 27 deletions

View File

@@ -921,6 +921,28 @@ pub async fn housekeeping(context: &Context) -> Result<()> {
.log_err(context)
.ok();
// Delete call SDPs for ended calls (older than 24 hours) or orphaned calls.
// Ended calls have Param::Arg4 (H=timestamp) set in their params.
// We clean up calls that ended more than 24 hours ago to protect privacy
// as SDPs contain IP addresses.
context
.sql
.execute(
"DELETE FROM calls WHERE msg_id IN (
SELECT calls.msg_id FROM calls
LEFT JOIN msgs ON calls.msg_id = msgs.id
WHERE msgs.id IS NULL
OR msgs.chat_id = ?
OR (msgs.param LIKE '%H=%'
AND msgs.timestamp_sent < ?)
)",
(DC_CHAT_ID_TRASH, time() - 86400),
)
.await
.context("Failed to delete old call SDPs")
.log_err(context)
.ok();
info!(context, "Housekeeping done.");
Ok(())
}