aboutsummaryrefslogtreecommitdiff
path: root/src/plugins
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2020-10-21 06:39:32 +0200
committerdec05eba <dec05eba@protonmail.com>2020-10-21 06:39:32 +0200
commit9a8e2e5c383713f471d5a0f977fbef07a5fc4738 (patch)
treebe0eaad343aa0014d5e07e4dbf6fe91fd318b842 /src/plugins
parentf8b54139f89ef21eb025defd17a5655e41fb9c03 (diff)
Matrix: dont count edit/redacts as new unread messages in a room, update local read marker
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/Matrix.cpp14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/plugins/Matrix.cpp b/src/plugins/Matrix.cpp
index 7de8af9..b6f6f76 100644
--- a/src/plugins/Matrix.cpp
+++ b/src/plugins/Matrix.cpp
@@ -481,14 +481,17 @@ namespace QuickMedia {
room_data->append_messages(new_messages);
}
- std::shared_ptr<Message> read_marker_message;
- if(me)
- read_marker_message = room_data->get_message_by_id(room_data->get_user_read_marker(me));
+ time_t read_marker_message_timestamp = 0;
+ if(me) {
+ auto read_marker_message = room_data->get_message_by_id(room_data->get_user_read_marker(me));
+ if(read_marker_message)
+ read_marker_message_timestamp = read_marker_message->timestamp;
+ }
for(auto &message : new_messages) {
// TODO: Is @room ok? shouldn't we also check if the user has permission to do @room? (only when notifications are limited to @mentions)
// TODO: Is comparing against read marker timestamp ok enough?
- if(has_unread_notifications && me && (!read_marker_message || read_marker_message->timestamp < message->timestamp))
+ if(has_unread_notifications && me && message->timestamp > read_marker_message_timestamp)
message->mentions_me = message_contains_user_mention(message->body, me->display_name) || message_contains_user_mention(message->body, me->user_id) || message_contains_user_mention(message->body, "@room");
}
}
@@ -1609,6 +1612,9 @@ namespace QuickMedia {
if(download_to_string(homeserver + "/_matrix/client/r0/rooms/" + room->id + "/read_markers", server_response, std::move(additional_args), use_tor, true) != DownloadResult::OK)
return PluginResult::NET_ERR;
+ auto me = get_me(room);
+ if(me)
+ room->set_user_read_marker(me, message->event_id);
return PluginResult::OK;
}