From ce6e766c72da4e9d4a0518b57291f3e1d4c1524a Mon Sep 17 00:00:00 2001 From: Hocuri Date: Thu, 14 Nov 2024 17:15:39 +0100 Subject: [PATCH] --wip-- [skip ci] --- src/reaction.rs | 16 +++++++++++----- src/receive_imf.rs | 1 + src/sql/migrations.rs | 9 +++++++++ 3 files changed, 21 insertions(+), 5 deletions(-) diff --git a/src/reaction.rs b/src/reaction.rs index 6bb71f2a4..9c486c3b1 100644 --- a/src/reaction.rs +++ b/src/reaction.rs @@ -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() diff --git a/src/receive_imf.rs b/src/receive_imf.rs index f3d513a60..f909eb4f7 100644 --- a/src/receive_imf.rs +++ b/src/receive_imf.rs @@ -1482,6 +1482,7 @@ async fn add_parts( sort_timestamp, Reaction::from(reaction_str.as_str()), is_incoming_fresh, + Some(rfc724_mid), ) .await?; } diff --git a/src/sql/migrations.rs b/src/sql/migrations.rs index 06ed60cdf..be2fd07cc 100644 --- a/src/sql/migrations.rs +++ b/src/sql/migrations.rs @@ -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