mirror of
https://github.com/chatmail/core.git
synced 2026-05-05 14:26:30 +03:00
Merge pull request #1705 from deltachat/seen_ephemeral_timer
Start ephemeral timer immediately for already seen messages
This commit is contained in:
@@ -622,7 +622,7 @@ async fn add_parts(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Extract ephemeral timer from the message.
|
// Extract ephemeral timer from the message.
|
||||||
let mut timer = if let Some(value) = mime_parser.get(HeaderDef::EphemeralTimer) {
|
let mut ephemeral_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) => {
|
||||||
@@ -649,14 +649,17 @@ async fn add_parts(
|
|||||||
if !*hidden
|
if !*hidden
|
||||||
&& !location_kml_is
|
&& !location_kml_is
|
||||||
&& !is_mdn
|
&& !is_mdn
|
||||||
&& (*chat_id).get_ephemeral_timer(context).await? != timer
|
&& (*chat_id).get_ephemeral_timer(context).await? != ephemeral_timer
|
||||||
|
{
|
||||||
|
match (*chat_id)
|
||||||
|
.inner_set_ephemeral_timer(context, ephemeral_timer)
|
||||||
|
.await
|
||||||
{
|
{
|
||||||
match (*chat_id).inner_set_ephemeral_timer(context, timer).await {
|
|
||||||
Ok(()) => {
|
Ok(()) => {
|
||||||
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,
|
||||||
stock_ephemeral_timer_changed(context, timer, from_id).await,
|
stock_ephemeral_timer_changed(context, ephemeral_timer, from_id).await,
|
||||||
);
|
);
|
||||||
|
|
||||||
// Do not delete the system message itself.
|
// Do not delete the system message itself.
|
||||||
@@ -665,12 +668,12 @@ async fn add_parts(
|
|||||||
// to 1 week, and then changed to 1 hour: after 1
|
// to 1 week, and then changed to 1 hour: after 1
|
||||||
// hour, only the message about the change to 1
|
// hour, only the message about the change to 1
|
||||||
// week is left.
|
// week is left.
|
||||||
timer = EphemeralTimer::Disabled;
|
ephemeral_timer = EphemeralTimer::Disabled;
|
||||||
} else {
|
} else {
|
||||||
chat::add_info_msg(
|
chat::add_info_msg(
|
||||||
context,
|
context,
|
||||||
*chat_id,
|
*chat_id,
|
||||||
stock_ephemeral_timer_changed(context, timer, from_id).await,
|
stock_ephemeral_timer_changed(context, ephemeral_timer, from_id).await,
|
||||||
)
|
)
|
||||||
.await;
|
.await;
|
||||||
}
|
}
|
||||||
@@ -686,14 +689,9 @@ async fn add_parts(
|
|||||||
|
|
||||||
// correct message_timestamp, it should not be used before,
|
// correct message_timestamp, it should not be used before,
|
||||||
// however, we cannot do this earlier as we need from_id to be set
|
// however, we cannot do this earlier as we need from_id to be set
|
||||||
|
let in_fresh = state == MessageState::InFresh;
|
||||||
let rcvd_timestamp = time();
|
let rcvd_timestamp = time();
|
||||||
let sort_timestamp = calc_sort_timestamp(
|
let sort_timestamp = calc_sort_timestamp(context, *sent_timestamp, *chat_id, in_fresh).await;
|
||||||
context,
|
|
||||||
*sent_timestamp,
|
|
||||||
*chat_id,
|
|
||||||
state == MessageState::InFresh,
|
|
||||||
)
|
|
||||||
.await;
|
|
||||||
*sent_timestamp = std::cmp::min(*sent_timestamp, rcvd_timestamp);
|
*sent_timestamp = std::cmp::min(*sent_timestamp, rcvd_timestamp);
|
||||||
|
|
||||||
// unarchive chat
|
// unarchive chat
|
||||||
@@ -745,8 +743,8 @@ async fn add_parts(
|
|||||||
"INSERT INTO msgs \
|
"INSERT INTO msgs \
|
||||||
(rfc724_mid, server_folder, server_uid, chat_id, from_id, to_id, timestamp, \
|
(rfc724_mid, server_folder, server_uid, chat_id, from_id, to_id, timestamp, \
|
||||||
timestamp_sent, timestamp_rcvd, type, state, msgrmsg, txt, txt_raw, param, \
|
timestamp_sent, timestamp_rcvd, type, state, msgrmsg, txt, txt_raw, param, \
|
||||||
bytes, hidden, mime_headers, mime_in_reply_to, mime_references, error, ephemeral_timer) \
|
bytes, hidden, mime_headers, mime_in_reply_to, mime_references, error, ephemeral_timer, ephemeral_timestamp) \
|
||||||
VALUES (?,?,?,?,?,?, ?,?,?,?,?,?, ?,?,?,?,?,?, ?,?, ?,?);",
|
VALUES (?,?,?,?,?,?, ?,?,?,?,?,?, ?,?,?,?,?,?, ?,?, ?,?,?);",
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
let is_location_kml = location_kml_is
|
let is_location_kml = location_kml_is
|
||||||
@@ -768,6 +766,15 @@ async fn add_parts(
|
|||||||
part.param.set_int(Param::Cmd, is_system_message as i32);
|
part.param.set_int(Param::Cmd, is_system_message as i32);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let ephemeral_timestamp = if in_fresh {
|
||||||
|
0
|
||||||
|
} else {
|
||||||
|
match ephemeral_timer {
|
||||||
|
EphemeralTimer::Disabled => 0,
|
||||||
|
EphemeralTimer::Enabled { duration } => rcvd_timestamp + i64::from(duration)
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
stmt.execute(paramsv![
|
stmt.execute(paramsv![
|
||||||
rfc724_mid,
|
rfc724_mid,
|
||||||
server_folder,
|
server_folder,
|
||||||
@@ -791,7 +798,8 @@ async fn add_parts(
|
|||||||
mime_in_reply_to,
|
mime_in_reply_to,
|
||||||
mime_references,
|
mime_references,
|
||||||
part.error,
|
part.error,
|
||||||
timer
|
ephemeral_timer,
|
||||||
|
ephemeral_timestamp
|
||||||
])?;
|
])?;
|
||||||
|
|
||||||
drop(stmt);
|
drop(stmt);
|
||||||
|
|||||||
Reference in New Issue
Block a user