Fix mention notifications are not updated after message change and not removed after a message is deleted (#9847)
@ConradIrwin This is a followup for #9035 as agreed. Release Notes: - Fixed mention notifications are updated when channel message is updated. And mention notifications are removed when message is removed. --------- Co-authored-by: Bennet Bo Fenner <53836821+bennetbo@users.noreply.github.com>
This commit is contained in:
parent
fe7b12c444
commit
754547f349
8 changed files with 297 additions and 24 deletions
|
@ -3388,14 +3388,30 @@ async fn remove_channel_message(
|
|||
) -> Result<()> {
|
||||
let channel_id = ChannelId::from_proto(request.channel_id);
|
||||
let message_id = MessageId::from_proto(request.message_id);
|
||||
let connection_ids = session
|
||||
let (connection_ids, existing_notification_ids) = session
|
||||
.db()
|
||||
.await
|
||||
.remove_channel_message(channel_id, message_id, session.user_id())
|
||||
.await?;
|
||||
broadcast(Some(session.connection_id), connection_ids, |connection| {
|
||||
session.peer.send(connection, request.clone())
|
||||
});
|
||||
|
||||
broadcast(
|
||||
Some(session.connection_id),
|
||||
connection_ids,
|
||||
move |connection| {
|
||||
session.peer.send(connection, request.clone())?;
|
||||
|
||||
for notification_id in &existing_notification_ids {
|
||||
session.peer.send(
|
||||
connection,
|
||||
proto::DeleteNotification {
|
||||
notification_id: (*notification_id).to_proto(),
|
||||
},
|
||||
)?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
},
|
||||
);
|
||||
response.send(proto::Ack {})?;
|
||||
Ok(())
|
||||
}
|
||||
|
@ -3414,6 +3430,8 @@ async fn update_channel_message(
|
|||
notifications,
|
||||
reply_to_message_id,
|
||||
timestamp,
|
||||
deleted_mention_notification_ids,
|
||||
updated_mention_notifications,
|
||||
} = session
|
||||
.db()
|
||||
.await
|
||||
|
@ -3456,7 +3474,27 @@ async fn update_channel_message(
|
|||
channel_id: channel_id.to_proto(),
|
||||
message: Some(message.clone()),
|
||||
},
|
||||
)
|
||||
)?;
|
||||
|
||||
for notification_id in &deleted_mention_notification_ids {
|
||||
session.peer.send(
|
||||
connection,
|
||||
proto::DeleteNotification {
|
||||
notification_id: (*notification_id).to_proto(),
|
||||
},
|
||||
)?;
|
||||
}
|
||||
|
||||
for notification in &updated_mention_notifications {
|
||||
session.peer.send(
|
||||
connection,
|
||||
proto::UpdateNotification {
|
||||
notification: Some(notification.clone()),
|
||||
},
|
||||
)?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
},
|
||||
);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue