Fix unused variable warning and run cargo fmt

Co-authored-by: link2xt <18373967+link2xt@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot]
2025-11-07 00:07:51 +00:00
parent 94c373368c
commit ac78f76602
4 changed files with 25 additions and 31 deletions

View File

@@ -138,7 +138,7 @@ impl CallInfo {
let now = time(); let now = time();
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?;
// Store ended timestamp in calls table. If no entry exists yet, create one. // Store ended timestamp in calls table. If no entry exists yet, create one.
context context
.sql .sql
@@ -163,7 +163,7 @@ impl CallInfo {
self.msg.param.set_i64(CALL_ENDED_TIMESTAMP, now); self.msg.param.set_i64(CALL_ENDED_TIMESTAMP, now);
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?;
// Store ended timestamp in calls table. If no entry exists yet, create one. // Store ended timestamp in calls table. If no entry exists yet, create one.
context context
.sql .sql
@@ -217,7 +217,7 @@ impl Context {
call_sdp_offer: Some(place_call_info.clone()), call_sdp_offer: Some(place_call_info.clone()),
..Default::default() ..Default::default()
}; };
call.id = send_msg(self, chat_id, &mut call).await?; call.id = send_msg(self, chat_id, &mut call).await?;
// For outgoing calls, we don't store our own offer SDP in the database. // For outgoing calls, we don't store our own offer SDP in the database.
@@ -434,7 +434,8 @@ impl Context {
// Store SDP answer in calls table for outgoing calls // Store SDP answer in calls table for outgoing calls
// (for incoming calls, we've already replaced our offer with our answer in accept_incoming_call) // (for incoming calls, we've already replaced our offer with our answer in accept_incoming_call)
if let Some(answer_sdp) = mime_message.get_header(HeaderDef::ChatWebrtcAccepted) { if let Some(answer_sdp) = mime_message.get_header(HeaderDef::ChatWebrtcAccepted)
{
self.sql self.sql
.execute( .execute(
"INSERT OR REPLACE INTO calls (msg_id, sdp) VALUES (?, ?)", "INSERT OR REPLACE INTO calls (msg_id, sdp) VALUES (?, ?)",
@@ -539,11 +540,9 @@ impl Context {
// For outgoing calls (after acceptance), the SDP is the answer from the other side. // For outgoing calls (after acceptance), the SDP is the answer from the other side.
let sdp = self let sdp = self
.sql .sql
.query_row_optional( .query_row_optional("SELECT sdp FROM calls WHERE msg_id=?", (call.id,), |row| {
"SELECT sdp FROM calls WHERE msg_id=?", row.get::<_, String>(0)
(call.id,), })
|row| row.get::<_, String>(0),
)
.await? .await?
.unwrap_or_default(); .unwrap_or_default();

View File

@@ -680,7 +680,6 @@ async fn test_housekeeping_deletes_old_call_sdps() -> Result<()> {
use crate::sql::housekeeping; use crate::sql::housekeeping;
let alice = TestContext::new_alice().await; let alice = TestContext::new_alice().await;
let bob = alice.create_chat_with_contact("", "bob@example.net").await;
// Simulate receiving an incoming call from Bob // Simulate receiving an incoming call from Bob
let received_call = receive_imf( let received_call = receive_imf(
@@ -697,17 +696,15 @@ async fn test_housekeeping_deletes_old_call_sdps() -> Result<()> {
) )
.await? .await?
.unwrap(); .unwrap();
let call_id = received_call.msg_ids[0]; let call_id = received_call.msg_ids[0];
// Verify SDP is stored in calls table for incoming call // Verify SDP is stored in calls table for incoming call
let sdp_before: Option<String> = alice let sdp_before: Option<String> = alice
.sql .sql
.query_row_optional( .query_row_optional("SELECT sdp FROM calls WHERE msg_id=?", (call_id,), |row| {
"SELECT sdp FROM calls WHERE msg_id=?", row.get(0)
(call_id,), })
|row| row.get(0),
)
.await?; .await?;
assert!(sdp_before.is_some()); assert!(sdp_before.is_some());
@@ -721,11 +718,9 @@ async fn test_housekeeping_deletes_old_call_sdps() -> Result<()> {
// SDP should still be there after ending // SDP should still be there after ending
let sdp_after_end: Option<String> = alice let sdp_after_end: Option<String> = alice
.sql .sql
.query_row_optional( .query_row_optional("SELECT sdp FROM calls WHERE msg_id=?", (call_id,), |row| {
"SELECT sdp FROM calls WHERE msg_id=?", row.get(0)
(call_id,), })
|row| row.get(0),
)
.await?; .await?;
assert!(sdp_after_end.is_some()); assert!(sdp_after_end.is_some());
@@ -738,11 +733,9 @@ async fn test_housekeeping_deletes_old_call_sdps() -> Result<()> {
// Verify SDP has been deleted from calls table // Verify SDP has been deleted from calls table
let sdp_after_housekeeping: Option<String> = alice let sdp_after_housekeeping: Option<String> = alice
.sql .sql
.query_row_optional( .query_row_optional("SELECT sdp FROM calls WHERE msg_id=?", (call_id,), |row| {
"SELECT sdp FROM calls WHERE msg_id=?", row.get(0)
(call_id,), })
|row| row.get(0),
)
.await?; .await?;
assert_eq!(sdp_after_housekeeping, None); assert_eq!(sdp_after_housekeeping, None);

View File

@@ -443,7 +443,7 @@ pub struct Message {
pub(crate) location_id: u32, pub(crate) location_id: u32,
pub(crate) error: Option<String>, pub(crate) error: Option<String>,
pub(crate) param: Params, pub(crate) param: Params,
/// SDP offer for outgoing calls. /// SDP offer for outgoing calls.
/// This field is used to pass the SDP offer to the database /// This field is used to pass the SDP offer to the database
/// without storing it in message parameters. /// without storing it in message parameters.

View File

@@ -1692,7 +1692,7 @@ impl MimeFactory {
|row| row.get(0), |row| row.get(0),
) )
.await?; .await?;
if let Some(quoted_msg_id) = quoted_msg_id { if let Some(quoted_msg_id) = quoted_msg_id {
// For CallAccepted messages, retrieve the SDP (which is our answer) // For CallAccepted messages, retrieve the SDP (which is our answer)
let answer_sdp = context let answer_sdp = context
@@ -1704,8 +1704,10 @@ impl MimeFactory {
) )
.await? .await?
.flatten() .flatten()
.or_else(|| msg.param.get(Param::WebrtcAccepted).map(|s| s.to_string())); .or_else(|| {
msg.param.get(Param::WebrtcAccepted).map(|s| s.to_string())
});
if let Some(answer_sdp) = answer_sdp { if let Some(answer_sdp) = answer_sdp {
headers.push(( headers.push((
"Chat-Webrtc-Accepted", "Chat-Webrtc-Accepted",
@@ -1760,7 +1762,7 @@ impl MimeFactory {
} else { } else {
msg.param.get(Param::WebrtcRoom).map(|s| s.to_string()) msg.param.get(Param::WebrtcRoom).map(|s| s.to_string())
}; };
if let Some(offer_sdp) = offer_sdp { if let Some(offer_sdp) = offer_sdp {
headers.push(( headers.push((
"Chat-Webrtc-Room", "Chat-Webrtc-Room",