api!: consistent spelling of "canceled" with a single "l"

This is how it is spelled in iOS UI and Android APIs.
This commit is contained in:
link2xt
2025-10-01 14:57:22 +00:00
committed by l
parent a668047f75
commit 38e4919be1
9 changed files with 49 additions and 49 deletions

View File

@@ -46,9 +46,9 @@ const STUN_PORT: u16 = 3478;
///
/// It is used to distinguish "ended" calls
/// that are rejected by us from the calls
/// cancelled by the other side
/// canceled by the other side
/// immediately after ringing started.
const CALL_CANCELLED_TIMESTAMP: Param = Param::Arg2;
const CALL_CANCELED_TIMESTAMP: Param = Param::Arg2;
/// Information about the status of a call.
#[derive(Debug, Default)]
@@ -123,14 +123,14 @@ impl CallInfo {
}
/// Returns true if the call is missed
/// because the caller cancelled it
/// because the caller canceled it
/// explicitly before ringing stopped.
///
/// For outgoing calls this means
/// the receiver has rejected the call
/// explicitly.
pub fn is_cancelled(&self) -> bool {
self.msg.param.exists(CALL_CANCELLED_TIMESTAMP)
pub fn is_canceled(&self) -> bool {
self.msg.param.exists(CALL_CANCELED_TIMESTAMP)
}
async fn mark_as_ended(&mut self, context: &Context) -> Result<()> {
@@ -139,17 +139,17 @@ impl CallInfo {
Ok(())
}
/// Explicitly mark the call as cancelled.
/// Explicitly mark the call as canceled.
///
/// For incoming calls this should be called
/// when "call ended" message is received
/// from the caller before we picked up the call.
/// In this case the call becomes "missed" early
/// before the ringing timeout.
async fn mark_as_cancelled(&mut self, context: &Context) -> Result<()> {
async fn mark_as_canceled(&mut self, context: &Context) -> Result<()> {
let now = time();
self.msg.param.set_i64(CALL_ENDED_TIMESTAMP, now);
self.msg.param.set_i64(CALL_CANCELLED_TIMESTAMP, now);
self.msg.param.set_i64(CALL_CANCELED_TIMESTAMP, now);
self.msg.update_param(context).await?;
Ok(())
}
@@ -255,8 +255,8 @@ impl Context {
call.mark_as_ended(self).await?;
call.update_text(self, "Declined call").await?;
} else {
call.mark_as_cancelled(self).await?;
call.update_text(self, "Cancelled call").await?;
call.mark_as_canceled(self).await?;
call.update_text(self, "Canceled call").await?;
}
} else {
call.mark_as_ended(self).await?;
@@ -290,11 +290,11 @@ impl Context {
let mut call = context.load_call_by_id(call_id).await?;
if !call.is_accepted() && !call.is_ended() {
if call.is_incoming() {
call.mark_as_cancelled(&context).await?;
call.mark_as_canceled(&context).await?;
call.update_text(&context, "Missed call").await?;
} else {
call.mark_as_ended(&context).await?;
call.update_text(&context, "Cancelled call").await?;
call.update_text(&context, "Canceled call").await?;
}
context.emit_msgs_changed(call.msg.chat_id, call_id);
context.emit_event(EventType::CallEnded {
@@ -386,14 +386,14 @@ impl Context {
call.mark_as_ended(self).await?;
call.update_text(self, "Declined call").await?;
} else {
call.mark_as_cancelled(self).await?;
call.mark_as_canceled(self).await?;
call.update_text(self, "Missed call").await?;
}
} else {
// outgoing
if from_id == ContactId::SELF {
call.mark_as_cancelled(self).await?;
call.update_text(self, "Cancelled call").await?;
call.mark_as_canceled(self).await?;
call.update_text(self, "Canceled call").await?;
} else {
call.mark_as_ended(self).await?;
call.update_text(self, "Declined call").await?;
@@ -483,13 +483,13 @@ pub enum CallState {
/// that was declined before the timeout.
Declined,
/// Outgoing call that has been cancelled on our side
/// Outgoing call that has been canceled on our side
/// before receiving a response.
///
/// Incoming calls cannot be cancelled,
/// on the receiver side cancelled calls
/// Incoming calls cannot be canceled,
/// on the receiver side canceled calls
/// usually result in missed calls.
Cancelled,
Canceled,
}
/// Returns call state given the message ID.
@@ -504,8 +504,8 @@ pub async fn call_state(context: &Context, msg_id: MsgId) -> Result<CallState> {
} else {
CallState::Active
}
} else if call.is_cancelled() {
// Call was explicitly cancelled
} else if call.is_canceled() {
// Call was explicitly canceled
// by the caller before we picked it up.
CallState::Missed
} else if call.is_ended() {
@@ -523,8 +523,8 @@ pub async fn call_state(context: &Context, msg_id: MsgId) -> Result<CallState> {
} else {
CallState::Active
}
} else if call.is_cancelled() {
CallState::Cancelled
} else if call.is_canceled() {
CallState::Canceled
} else if call.is_ended() || call.is_stale() {
CallState::Declined
} else {

View File

@@ -368,7 +368,7 @@ async fn test_caller_cancels_call() -> Result<()> {
// Alice changes their mind before Bob picks up
alice.end_call(alice_call.id).await?;
assert_text(&alice, alice_call.id, "Cancelled call").await?;
assert_text(&alice, alice_call.id, "Canceled call").await?;
alice
.evtracker
.get_matching(|evt| matches!(evt, EventType::CallEnded { .. }))
@@ -376,18 +376,18 @@ async fn test_caller_cancels_call() -> Result<()> {
let sent3 = alice.pop_sent_msg().await;
assert_eq!(
call_state(&alice, alice_call.id).await?,
CallState::Cancelled
CallState::Canceled
);
alice2.recv_msg_trash(&sent3).await;
assert_text(&alice2, alice2_call.id, "Cancelled call").await?;
assert_text(&alice2, alice2_call.id, "Canceled call").await?;
alice2
.evtracker
.get_matching(|evt| matches!(evt, EventType::CallEnded { .. }))
.await;
assert_eq!(
call_state(&alice2, alice2_call.id).await?,
CallState::Cancelled
CallState::Canceled
);
// Bob receives the ending message

View File

@@ -137,7 +137,7 @@ impl Context {
let res = self
.inner_configure(param)
.race(cancel_channel.recv().map(|_| Err(format_err!("Cancelled"))))
.race(cancel_channel.recv().map(|_| Err(format_err!("Canceled"))))
.await;
self.free_ongoing().await;

View File

@@ -242,7 +242,7 @@ impl BackupProvider {
if let Err(err) = Self::handle_connection(context.clone(), conn, auth_token, dbfile).race(
async {
cancel_token.recv().await.ok();
Err(format_err!("Backup transfer cancelled"))
Err(format_err!("Backup transfer canceled"))
}
).race(
async {
@@ -262,12 +262,12 @@ impl BackupProvider {
}
},
_ = cancel_token.recv() => {
info!(context, "Backup transfer cancelled by the user, stopping accept loop.");
info!(context, "Backup transfer canceled by the user, stopping accept loop.");
context.emit_event(EventType::ImexProgress(0));
break;
}
_ = drop_token.cancelled() => {
info!(context, "Backup transfer cancelled by dropping the provider, stopping accept loop.");
info!(context, "Backup transfer canceled by dropping the provider, stopping accept loop.");
context.emit_event(EventType::ImexProgress(0));
break;
}
@@ -364,7 +364,7 @@ pub async fn get_backup(context: &Context, qr: Qr) -> Result<()> {
let res = get_backup2(context, node_addr, auth_token)
.race(async {
cancel_token.recv().await.ok();
Err(format_err!("Backup reception cancelled"))
Err(format_err!("Backup reception canceled"))
})
.await;
if let Err(ref res) = res {