Compare commits

...

1 Commits

Author SHA1 Message Date
Hocuri
ce6e766c72 --wip-- [skip ci] 2024-11-14 17:15:39 +01:00
3 changed files with 21 additions and 5 deletions

View File

@@ -175,6 +175,7 @@ async fn set_msg_id_reaction(
contact_id: ContactId,
timestamp: i64,
reaction: &Reaction,
rfc724_mid: Option<&str>,
) -> Result<()> {
if reaction.is_empty() {
// Simply remove the record instead of setting it to empty string.
@@ -191,11 +192,11 @@ async fn set_msg_id_reaction(
context
.sql
.execute(
"INSERT INTO reactions (msg_id, contact_id, reaction)
VALUES (?1, ?2, ?3)
"INSERT INTO reactions (msg_id, contact_id, reaction, rfc724_mid)
VALUES (?1, ?2, ?3, ?4)
ON CONFLICT(msg_id, contact_id)
DO UPDATE SET reaction=excluded.reaction",
(msg_id, contact_id, reaction.as_str()),
DO UPDATE SET reaction=excluded.reaction, rfc724_mid=excluded.rfc724_mid",
(msg_id, contact_id, reaction.as_str(), rfc724_mid),
)
.await?;
let mut chat = Chat::load_from_db(context, chat_id).await?;
@@ -245,6 +246,7 @@ pub async fn send_reaction(context: &Context, msg_id: MsgId, reaction: &str) ->
ContactId::SELF,
reaction_msg.timestamp_sort,
&reaction,
None,
)
.await?;
Ok(reaction_msg_id)
@@ -276,9 +278,13 @@ pub(crate) async fn set_msg_reaction(
timestamp: i64,
reaction: Reaction,
is_incoming_fresh: bool,
rfc724_mid: Option<&str>,
) -> Result<()> {
if let Some((msg_id, _)) = rfc724_mid_exists(context, in_reply_to).await? {
set_msg_id_reaction(context, msg_id, chat_id, contact_id, timestamp, &reaction).await?;
set_msg_id_reaction(
context, msg_id, chat_id, contact_id, timestamp, &reaction, rfc724_mid,
)
.await?;
if is_incoming_fresh
&& !reaction.is_empty()

View File

@@ -1482,6 +1482,7 @@ async fn add_parts(
sort_timestamp,
Reaction::from(reaction_str.as_str()),
is_incoming_fresh,
Some(rfc724_mid),
)
.await?;
}

View File

@@ -1068,6 +1068,15 @@ CREATE INDEX msgs_status_updates_index2 ON msgs_status_updates (uid);
migration_version,
)
.await?;
inc_and_check(&mut migration_version, 124)?;
if dbversion < migration_version {
sql.execute_migration(
"ALTER TABLE reactions ADD COLUMN rfc724_mid TEXT;",
migration_version,
)
.await?;
}
}
let new_version = sql