diff options
author | dec05eba <dec05eba@protonmail.com> | 2023-01-10 11:31:51 +0100 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2023-01-10 11:31:51 +0100 |
commit | eb6295751d07b8ee173317234daee8acf6b07a5f (patch) | |
tree | 44a6b8e5258f7b6c826946e38a84c51170bab7ca /src/plugins | |
parent | 665c015988ce5a27f48f61ffdc0fc579075f6ddf (diff) |
Matrix: use room messages for notifications intead of notifications api (synapse cache issue)
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/Matrix.cpp | 22 |
1 files changed, 6 insertions, 16 deletions
diff --git a/src/plugins/Matrix.cpp b/src/plugins/Matrix.cpp index 56f4e73..de49409 100644 --- a/src/plugins/Matrix.cpp +++ b/src/plugins/Matrix.cpp @@ -693,11 +693,6 @@ namespace QuickMedia { invites_page->remove_body_item_by_room_id(room_id); } - void MatrixQuickMedia::add_unread_notification(MatrixNotification notification) { - if(notifications_shown.insert(notification.event_id).second) - show_notification("QuickMedia matrix - " + notification.sender_user_id + " (" + notification.room->get_name() + ")", notification.body); - } - void MatrixQuickMedia::add_user(MatrixEventUserInfo user_info) { auto &users = users_by_room[user_info.room]; const bool new_user = users.insert(std::make_pair(user_info.user_id, user_info)).second; @@ -1672,9 +1667,11 @@ namespace QuickMedia { return; } + const bool cache_updated = get_file_type(get_cache_dir().join("matrix").join("updated-cache-version1")) == FileType::REGULAR; + bool overwrite_cache = !cache_updated; std::ifstream sync_cache_file_stream; sync_cache_file_stream.open(matrix_cache_dir.data.c_str(), std::ifstream::in | std::ifstream::binary); - if(sync_cache_file_stream.good() && get_file_type(get_cache_dir().join("matrix").join("updated-cache-version1")) == FileType::REGULAR) { + if(sync_cache_file_stream.good() && cache_updated) { rapidjson::Document doc; std::string line; while(std::getline(sync_cache_file_stream, line)) { @@ -1792,15 +1789,7 @@ namespace QuickMedia { // TODO: This ignores new rooms that are not part of the previous sync message. Fix this. notification_thread = std::thread([this]() { - get_previous_notifications([this](const MatrixNotification ¬ification) { - if(notification.read) - return; - - MatrixDelegate *delegate = this->delegate; - ui_thread_tasks.push([delegate, notification] { - delegate->add_unread_notification(std::move(notification)); - }); - }); + get_previous_notifications([](const MatrixNotification&) {}); finished_fetching_notifications = true; }); } @@ -1821,7 +1810,8 @@ namespace QuickMedia { // Then the daemon will do the sync and matrix processes will ask that daemon for the cached data // and fetch previous messages etc themselves. if(!matrix_instance_already_running) { - sync_cache_file = fopen(matrix_cache_dir.data.c_str(), "ab"); + sync_cache_file = fopen(matrix_cache_dir.data.c_str(), overwrite_cache ? "wb" : "ab"); + overwrite_cache = false; if(sync_cache_file) { if(json_root.IsObject()) { rapidjson::StringBuffer buffer; |