mirror of
https://github.com/chatmail/core.git
synced 2026-05-08 09:26:29 +03:00
refactor: do not check for is_trash() in get_last_reaction_if_newer_than()
`Message::load_from_db_optional` does not return trashed messages anymore.
This commit is contained in:
@@ -338,44 +338,43 @@ impl Chat {
|
|||||||
context: &Context,
|
context: &Context,
|
||||||
timestamp: i64,
|
timestamp: i64,
|
||||||
) -> Result<Option<(Message, ContactId, String)>> {
|
) -> Result<Option<(Message, ContactId, String)>> {
|
||||||
if let Some(reaction_timestamp) = self.param.get_i64(Param::LastReactionTimestamp) {
|
if self
|
||||||
if reaction_timestamp > timestamp {
|
.param
|
||||||
let reaction_msg_id = MsgId::new(
|
.get_i64(Param::LastReactionTimestamp)
|
||||||
self.param
|
.filter(|&reaction_timestamp| reaction_timestamp > timestamp)
|
||||||
.get_int(Param::LastReactionMsgId)
|
.is_none()
|
||||||
.unwrap_or_default() as u32,
|
{
|
||||||
);
|
return Ok(None);
|
||||||
// The message reacted to may be deleted physically (`load_from_db()` fails) or marked as a tombstone (`is_trash()`).
|
};
|
||||||
// These are no errors as `Param::LastReaction*` are just weak pointers.
|
let reaction_msg_id = MsgId::new(
|
||||||
// Instead, just return `Ok(None)` and let the caller create another summary.
|
self.param
|
||||||
if let Some(reaction_msg) =
|
.get_int(Param::LastReactionMsgId)
|
||||||
Message::load_from_db_optional(context, reaction_msg_id).await?
|
.unwrap_or_default() as u32,
|
||||||
{
|
);
|
||||||
if !reaction_msg.chat_id.is_trash() {
|
let Some(reaction_msg) = Message::load_from_db_optional(context, reaction_msg_id).await?
|
||||||
let reaction_contact_id = ContactId::new(
|
else {
|
||||||
self.param
|
// The message reacted to may be deleted.
|
||||||
.get_int(Param::LastReactionContactId)
|
// These are no errors as `Param::LastReaction*` are just weak pointers.
|
||||||
.unwrap_or_default() as u32,
|
// Instead, just return `Ok(None)` and let the caller create another summary.
|
||||||
);
|
return Ok(None);
|
||||||
if let Some(reaction) = context
|
};
|
||||||
.sql
|
let reaction_contact_id = ContactId::new(
|
||||||
.query_row_optional(
|
self.param
|
||||||
r#"SELECT reaction FROM reactions WHERE msg_id=? AND contact_id=?"#,
|
.get_int(Param::LastReactionContactId)
|
||||||
(reaction_msg.id, reaction_contact_id),
|
.unwrap_or_default() as u32,
|
||||||
|row| {
|
);
|
||||||
let reaction: String = row.get(0)?;
|
if let Some(reaction) = context
|
||||||
Ok(reaction)
|
.sql
|
||||||
},
|
.query_get_value(
|
||||||
)
|
"SELECT reaction FROM reactions WHERE msg_id=? AND contact_id=?",
|
||||||
.await?
|
(reaction_msg.id, reaction_contact_id),
|
||||||
{
|
)
|
||||||
return Ok(Some((reaction_msg, reaction_contact_id, reaction)));
|
.await?
|
||||||
}
|
{
|
||||||
}
|
Ok(Some((reaction_msg, reaction_contact_id, reaction)))
|
||||||
}
|
} else {
|
||||||
}
|
Ok(None)
|
||||||
}
|
}
|
||||||
Ok(None)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user