mirror of
https://github.com/chatmail/core.git
synced 2026-04-21 23:46:31 +03:00
Always translate EphemeralTimerChanged message
An EphemeralTimerChanged message with the same timer as already set can be received when there are large delays or lost messages. Even though inner_set_ephemeral_timer should not be called in this case, because it emits an event indicating timer change, system message will be added to the chat, so it should be translated with set_better_msg in any case.
This commit is contained in:
@@ -663,11 +663,24 @@ async fn add_parts(
|
|||||||
&& !is_mdn
|
&& !is_mdn
|
||||||
&& (*chat_id).get_ephemeral_timer(context).await? != ephemeral_timer
|
&& (*chat_id).get_ephemeral_timer(context).await? != ephemeral_timer
|
||||||
{
|
{
|
||||||
match (*chat_id)
|
if let Err(err) = (*chat_id)
|
||||||
.inner_set_ephemeral_timer(context, ephemeral_timer)
|
.inner_set_ephemeral_timer(context, ephemeral_timer)
|
||||||
.await
|
.await
|
||||||
{
|
{
|
||||||
Ok(()) => {
|
warn!(
|
||||||
|
context,
|
||||||
|
"failed to modify timer for chat {}: {}", chat_id, err
|
||||||
|
);
|
||||||
|
} else if mime_parser.is_system_message != SystemMessage::EphemeralTimerChanged {
|
||||||
|
chat::add_info_msg(
|
||||||
|
context,
|
||||||
|
*chat_id,
|
||||||
|
stock_ephemeral_timer_changed(context, ephemeral_timer, from_id).await,
|
||||||
|
)
|
||||||
|
.await;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if mime_parser.is_system_message == SystemMessage::EphemeralTimerChanged {
|
if mime_parser.is_system_message == SystemMessage::EphemeralTimerChanged {
|
||||||
set_better_msg(
|
set_better_msg(
|
||||||
mime_parser,
|
mime_parser,
|
||||||
@@ -681,22 +694,6 @@ async fn add_parts(
|
|||||||
// hour, only the message about the change to 1
|
// hour, only the message about the change to 1
|
||||||
// week is left.
|
// week is left.
|
||||||
ephemeral_timer = EphemeralTimer::Disabled;
|
ephemeral_timer = EphemeralTimer::Disabled;
|
||||||
} else {
|
|
||||||
chat::add_info_msg(
|
|
||||||
context,
|
|
||||||
*chat_id,
|
|
||||||
stock_ephemeral_timer_changed(context, ephemeral_timer, from_id).await,
|
|
||||||
)
|
|
||||||
.await;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Err(err) => {
|
|
||||||
warn!(
|
|
||||||
context,
|
|
||||||
"failed to modify timer for chat {}: {}", chat_id, err
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// correct message_timestamp, it should not be used before,
|
// correct message_timestamp, it should not be used before,
|
||||||
|
|||||||
Reference in New Issue
Block a user