From 3bfa7ea4beac7710ac5484c46ce181027131ebf8 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Thu, 12 Jan 2023 22:54:07 +0100 Subject: Matrix: do not trust synapse when it comes to unread messages --- plugins/Matrix.hpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'plugins') diff --git a/plugins/Matrix.hpp b/plugins/Matrix.hpp index 7c2103c..4e3309f 100644 --- a/plugins/Matrix.hpp +++ b/plugins/Matrix.hpp @@ -67,6 +67,7 @@ namespace QuickMedia { std::string text_to_decrypt; }; + // TODO: Remove. Not needed anymore. struct TimestampedDisplayData { std::string data; time_t timestamp = 0; // In milliseconds @@ -83,6 +84,7 @@ namespace QuickMedia { RoomData *room; const mgl::Color display_name_color; const std::string user_id; + int power_level = 0; private: TimestampedDisplayData display_name; TimestampedDisplayData avatar_url; @@ -226,9 +228,9 @@ namespace QuickMedia { bool avatar_is_fallback = false; std::atomic_int64_t last_message_timestamp = 0; - std::atomic_int unread_notification_count = 0; std::atomic_int64_t read_marker_event_timestamp = 0; + int notification_power_level = 50; size_t index = 0; private: std::mutex user_mutex; @@ -324,6 +326,8 @@ namespace QuickMedia { virtual void remove_user(MatrixEventUserInfo user_info) = 0; virtual void set_user_info(MatrixEventUserInfo user_info) = 0; virtual void set_room_info(MatrixEventRoomInfo room_info) = 0; + + virtual void set_room_as_read(RoomData *room) = 0; }; class Matrix; @@ -356,7 +360,7 @@ namespace QuickMedia { void set_room_info(MatrixEventRoomInfo room_info) override; void for_each_user_in_room(RoomData *room, std::function callback); - void set_room_as_read(RoomData *room); + void set_room_as_read(RoomData *room) override; Program *program; Matrix *matrix; @@ -370,6 +374,7 @@ namespace QuickMedia { private: std::map> room_body_item_by_room; std::map> last_message_by_room; + std::map unread_mention_count_by_room; std::unordered_set notifications_shown; UsersByRoom users_by_room; }; @@ -736,6 +741,8 @@ namespace QuickMedia { void async_decrypt_message(std::shared_ptr decrypt_job); + MatrixDelegate* get_delegate(); + // Calls the |MatrixDelegate| pending events. // Should be called from the main (ui) thread void update(); -- cgit v1.2.3