mirror of
https://github.com/chatmail/core.git
synced 2026-05-14 04:16:30 +03:00
Make ephemeral timer changes not ephemeral
This commit is contained in:
committed by
link2xt
parent
43c4816739
commit
7f8f871813
@@ -1562,7 +1562,9 @@ class TestOnlineAccount:
|
|||||||
system_message1 = ac2._evtracker.wait_next_incoming_message()
|
system_message1 = ac2._evtracker.wait_next_incoming_message()
|
||||||
assert chat2.get_ephemeral_timer() == 60
|
assert chat2.get_ephemeral_timer() == 60
|
||||||
assert system_message1.is_system_message()
|
assert system_message1.is_system_message()
|
||||||
assert "Ephemeral timer: 60\n" in system_message1.get_message_info()
|
|
||||||
|
# Disabled until markers are implemented
|
||||||
|
# assert "Ephemeral timer: 60\n" in system_message1.get_message_info()
|
||||||
|
|
||||||
lp.sec("ac2: send message to ac1")
|
lp.sec("ac2: send message to ac1")
|
||||||
sent_message = chat2.send_text("message")
|
sent_message = chat2.send_text("message")
|
||||||
|
|||||||
@@ -959,7 +959,11 @@ impl Chat {
|
|||||||
.await?;
|
.await?;
|
||||||
}
|
}
|
||||||
|
|
||||||
let ephemeral_timer = self.id.get_ephemeral_timer(context).await?;
|
let ephemeral_timer = if msg.param.get_cmd() == SystemMessage::EphemeralTimerChanged {
|
||||||
|
EphemeralTimer::Disabled
|
||||||
|
} else {
|
||||||
|
self.id.get_ephemeral_timer(context).await?
|
||||||
|
};
|
||||||
let ephemeral_timestamp = match ephemeral_timer {
|
let ephemeral_timestamp = match ephemeral_timer {
|
||||||
EphemeralTimer::Disabled => 0,
|
EphemeralTimer::Disabled => 0,
|
||||||
EphemeralTimer::Enabled { duration } => timestamp + i64::from(duration),
|
EphemeralTimer::Enabled { duration } => timestamp + i64::from(duration),
|
||||||
|
|||||||
@@ -622,7 +622,7 @@ async fn add_parts(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Extract ephemeral timer from the message.
|
// Extract ephemeral timer from the message.
|
||||||
let timer = if let Some(value) = mime_parser.get(HeaderDef::EphemeralTimer) {
|
let mut timer = if let Some(value) = mime_parser.get(HeaderDef::EphemeralTimer) {
|
||||||
match value.parse::<EphemeralTimer>() {
|
match value.parse::<EphemeralTimer>() {
|
||||||
Ok(timer) => timer,
|
Ok(timer) => timer,
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
@@ -658,6 +658,14 @@ async fn add_parts(
|
|||||||
mime_parser,
|
mime_parser,
|
||||||
stock_ephemeral_timer_changed(context, timer, from_id).await,
|
stock_ephemeral_timer_changed(context, timer, from_id).await,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Do not delete the system message itself.
|
||||||
|
//
|
||||||
|
// This prevents confusion when timer is changed
|
||||||
|
// to 1 week, and then changed to 1 hour: after 1
|
||||||
|
// hour, only the message about the change to 1
|
||||||
|
// week is left.
|
||||||
|
timer = EphemeralTimer::Disabled;
|
||||||
} else {
|
} else {
|
||||||
chat::add_info_msg(
|
chat::add_info_msg(
|
||||||
context,
|
context,
|
||||||
|
|||||||
Reference in New Issue
Block a user