mirror of
https://github.com/chatmail/core.git
synced 2026-05-08 17:36:29 +03:00
fix: display correct timer value for ephemeral timer changes
The timer change should not disappear, but should display correct timer change.
This commit is contained in:
@@ -128,31 +128,33 @@ async fn test_stock_ephemeral_messages() {
|
|||||||
/// Test enabling and disabling ephemeral timer remotely.
|
/// Test enabling and disabling ephemeral timer remotely.
|
||||||
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
||||||
async fn test_ephemeral_enable_disable() -> Result<()> {
|
async fn test_ephemeral_enable_disable() -> Result<()> {
|
||||||
let alice = TestContext::new_alice().await;
|
let mut tcm = TestContextManager::new();
|
||||||
let bob = TestContext::new_bob().await;
|
let alice = &tcm.alice().await;
|
||||||
|
let bob = &tcm.bob().await;
|
||||||
|
|
||||||
let chat_alice = alice.create_chat(&bob).await.id;
|
let chat_alice = alice.create_chat(bob).await.id;
|
||||||
let chat_bob = bob.create_chat(&alice).await.id;
|
let chat_bob = bob.create_chat(alice).await.id;
|
||||||
|
|
||||||
chat_alice
|
chat_alice
|
||||||
.set_ephemeral_timer(&alice.ctx, Timer::Enabled { duration: 60 })
|
.set_ephemeral_timer(alice, Timer::Enabled { duration: 60 })
|
||||||
.await?;
|
.await?;
|
||||||
let sent = alice.pop_sent_msg().await;
|
let sent = alice.pop_sent_msg().await;
|
||||||
bob.recv_msg(&sent).await;
|
let bob_received_message = bob.recv_msg(&sent).await;
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
chat_bob.get_ephemeral_timer(&bob.ctx).await?,
|
bob_received_message.text,
|
||||||
|
"Message deletion timer is set to 1 minute by alice@example.org."
|
||||||
|
);
|
||||||
|
assert_eq!(
|
||||||
|
chat_bob.get_ephemeral_timer(bob).await?,
|
||||||
Timer::Enabled { duration: 60 }
|
Timer::Enabled { duration: 60 }
|
||||||
);
|
);
|
||||||
|
|
||||||
chat_alice
|
chat_alice
|
||||||
.set_ephemeral_timer(&alice.ctx, Timer::Disabled)
|
.set_ephemeral_timer(alice, Timer::Disabled)
|
||||||
.await?;
|
.await?;
|
||||||
let sent = alice.pop_sent_msg().await;
|
let sent = alice.pop_sent_msg().await;
|
||||||
bob.recv_msg(&sent).await;
|
bob.recv_msg(&sent).await;
|
||||||
assert_eq!(
|
assert_eq!(chat_bob.get_ephemeral_timer(bob).await?, Timer::Disabled);
|
||||||
chat_bob.get_ephemeral_timer(&bob.ctx).await?,
|
|
||||||
Timer::Disabled
|
|
||||||
);
|
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1835,6 +1835,8 @@ async fn add_parts(
|
|||||||
{
|
{
|
||||||
Some(stock_str::msg_location_enabled_by(context, from_id).await)
|
Some(stock_str::msg_location_enabled_by(context, from_id).await)
|
||||||
} else if mime_parser.is_system_message == SystemMessage::EphemeralTimerChanged {
|
} else if mime_parser.is_system_message == SystemMessage::EphemeralTimerChanged {
|
||||||
|
let better_msg = stock_ephemeral_timer_changed(context, ephemeral_timer, from_id).await;
|
||||||
|
|
||||||
// Do not delete the system message itself.
|
// Do not delete the system message itself.
|
||||||
//
|
//
|
||||||
// This prevents confusion when timer is changed
|
// This prevents confusion when timer is changed
|
||||||
@@ -1843,7 +1845,7 @@ async fn add_parts(
|
|||||||
// week is left.
|
// week is left.
|
||||||
ephemeral_timer = EphemeralTimer::Disabled;
|
ephemeral_timer = EphemeralTimer::Disabled;
|
||||||
|
|
||||||
Some(stock_ephemeral_timer_changed(context, ephemeral_timer, from_id).await)
|
Some(better_msg)
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user