mirror of
https://github.com/chatmail/core.git
synced 2026-05-03 21:36:29 +03:00
fix: If there was no chat description, and it's set to be an empty string, don't send out a "chat description changed" message (#7879)
fix #7877 The bug was: If there is no chat description, and the chat description is set to an empty string, the INSERT statement inserted a row with an empty chat description, and therefore from the view of the INSERT statement, something changed. This PR fixes this by simply loading the chat description first, and comparing it.
This commit is contained in:
15
src/chat.rs
15
src/chat.rs
@@ -4248,20 +4248,19 @@ async fn set_chat_description_ex(
|
||||
bail!("Cannot set chat description; self not in group");
|
||||
}
|
||||
|
||||
let affected_rows = context
|
||||
let old_description = get_chat_description(context, chat_id).await?;
|
||||
if old_description == new_description {
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
context
|
||||
.sql
|
||||
.execute(
|
||||
"INSERT INTO chats_descriptions(chat_id, description) VALUES(?, ?)
|
||||
ON CONFLICT(chat_id) DO UPDATE
|
||||
SET description=excluded.description WHERE description<>excluded.description",
|
||||
"INSERT OR REPLACE INTO chats_descriptions(chat_id, description) VALUES(?, ?)",
|
||||
(chat_id, &new_description),
|
||||
)
|
||||
.await?;
|
||||
|
||||
if affected_rows == 0 {
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
if chat.is_promoted() {
|
||||
let mut msg = Message::new(Viewtype::Text);
|
||||
msg.text =
|
||||
|
||||
Reference in New Issue
Block a user