mirror of
https://github.com/chatmail/core.git
synced 2026-04-17 21:46:35 +03:00
Fix unused variable warning and run cargo fmt
Co-authored-by: link2xt <18373967+link2xt@users.noreply.github.com>
This commit is contained in:
17
src/calls.rs
17
src/calls.rs
@@ -138,7 +138,7 @@ impl CallInfo {
|
||||
let now = time();
|
||||
self.msg.param.set_i64(CALL_ENDED_TIMESTAMP, now);
|
||||
self.msg.update_param(context).await?;
|
||||
|
||||
|
||||
// Store ended timestamp in calls table. If no entry exists yet, create one.
|
||||
context
|
||||
.sql
|
||||
@@ -163,7 +163,7 @@ impl CallInfo {
|
||||
self.msg.param.set_i64(CALL_ENDED_TIMESTAMP, now);
|
||||
self.msg.param.set_i64(CALL_CANCELED_TIMESTAMP, now);
|
||||
self.msg.update_param(context).await?;
|
||||
|
||||
|
||||
// Store ended timestamp in calls table. If no entry exists yet, create one.
|
||||
context
|
||||
.sql
|
||||
@@ -217,7 +217,7 @@ impl Context {
|
||||
call_sdp_offer: Some(place_call_info.clone()),
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
|
||||
call.id = send_msg(self, chat_id, &mut call).await?;
|
||||
|
||||
// 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
|
||||
// (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
|
||||
.execute(
|
||||
"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.
|
||||
let sdp = self
|
||||
.sql
|
||||
.query_row_optional(
|
||||
"SELECT sdp FROM calls WHERE msg_id=?",
|
||||
(call.id,),
|
||||
|row| row.get::<_, String>(0),
|
||||
)
|
||||
.query_row_optional("SELECT sdp FROM calls WHERE msg_id=?", (call.id,), |row| {
|
||||
row.get::<_, String>(0)
|
||||
})
|
||||
.await?
|
||||
.unwrap_or_default();
|
||||
|
||||
|
||||
@@ -680,7 +680,6 @@ async fn test_housekeeping_deletes_old_call_sdps() -> Result<()> {
|
||||
use crate::sql::housekeeping;
|
||||
|
||||
let alice = TestContext::new_alice().await;
|
||||
let bob = alice.create_chat_with_contact("", "bob@example.net").await;
|
||||
|
||||
// Simulate receiving an incoming call from Bob
|
||||
let received_call = receive_imf(
|
||||
@@ -697,17 +696,15 @@ async fn test_housekeeping_deletes_old_call_sdps() -> Result<()> {
|
||||
)
|
||||
.await?
|
||||
.unwrap();
|
||||
|
||||
|
||||
let call_id = received_call.msg_ids[0];
|
||||
|
||||
// Verify SDP is stored in calls table for incoming call
|
||||
let sdp_before: Option<String> = alice
|
||||
.sql
|
||||
.query_row_optional(
|
||||
"SELECT sdp FROM calls WHERE msg_id=?",
|
||||
(call_id,),
|
||||
|row| row.get(0),
|
||||
)
|
||||
.query_row_optional("SELECT sdp FROM calls WHERE msg_id=?", (call_id,), |row| {
|
||||
row.get(0)
|
||||
})
|
||||
.await?;
|
||||
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
|
||||
let sdp_after_end: Option<String> = alice
|
||||
.sql
|
||||
.query_row_optional(
|
||||
"SELECT sdp FROM calls WHERE msg_id=?",
|
||||
(call_id,),
|
||||
|row| row.get(0),
|
||||
)
|
||||
.query_row_optional("SELECT sdp FROM calls WHERE msg_id=?", (call_id,), |row| {
|
||||
row.get(0)
|
||||
})
|
||||
.await?;
|
||||
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
|
||||
let sdp_after_housekeeping: Option<String> = alice
|
||||
.sql
|
||||
.query_row_optional(
|
||||
"SELECT sdp FROM calls WHERE msg_id=?",
|
||||
(call_id,),
|
||||
|row| row.get(0),
|
||||
)
|
||||
.query_row_optional("SELECT sdp FROM calls WHERE msg_id=?", (call_id,), |row| {
|
||||
row.get(0)
|
||||
})
|
||||
.await?;
|
||||
assert_eq!(sdp_after_housekeeping, None);
|
||||
|
||||
|
||||
@@ -443,7 +443,7 @@ pub struct Message {
|
||||
pub(crate) location_id: u32,
|
||||
pub(crate) error: Option<String>,
|
||||
pub(crate) param: Params,
|
||||
|
||||
|
||||
/// SDP offer for outgoing calls.
|
||||
/// This field is used to pass the SDP offer to the database
|
||||
/// without storing it in message parameters.
|
||||
|
||||
@@ -1692,7 +1692,7 @@ impl MimeFactory {
|
||||
|row| row.get(0),
|
||||
)
|
||||
.await?;
|
||||
|
||||
|
||||
if let Some(quoted_msg_id) = quoted_msg_id {
|
||||
// For CallAccepted messages, retrieve the SDP (which is our answer)
|
||||
let answer_sdp = context
|
||||
@@ -1704,8 +1704,10 @@ impl MimeFactory {
|
||||
)
|
||||
.await?
|
||||
.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 {
|
||||
headers.push((
|
||||
"Chat-Webrtc-Accepted",
|
||||
@@ -1760,7 +1762,7 @@ impl MimeFactory {
|
||||
} else {
|
||||
msg.param.get(Param::WebrtcRoom).map(|s| s.to_string())
|
||||
};
|
||||
|
||||
|
||||
if let Some(offer_sdp) = offer_sdp {
|
||||
headers.push((
|
||||
"Chat-Webrtc-Room",
|
||||
|
||||
Reference in New Issue
Block a user