aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2022-11-16 00:49:15 +0100
committerdec05eba <dec05eba@protonmail.com>2022-11-16 00:49:15 +0100
commitceddf6d67b43a99c774132baf099f4a58daa613e (patch)
tree947878335834a2d3a68123cdac6237f30abadc24 /src
parentc2429d4c7dd6edf3bb931bdf41de665beebe9c14 (diff)
Matrix: fix read marker when running multiple instances of quickmedia on the same account at the same time
Diffstat (limited to 'src')
-rw-r--r--src/plugins/Matrix.cpp15
1 files changed, 9 insertions, 6 deletions
diff --git a/src/plugins/Matrix.cpp b/src/plugins/Matrix.cpp
index ec883df..186be72 100644
--- a/src/plugins/Matrix.cpp
+++ b/src/plugins/Matrix.cpp
@@ -5189,9 +5189,14 @@ namespace QuickMedia {
PluginResult Matrix::set_qm_last_read_message_timestamp(RoomData *room, int64_t timestamp) {
rapidjson::Document request_data(rapidjson::kObjectType);
- qm_read_markers_by_room_cache[room->id] = timestamp;
- for(const auto &[key, val] : qm_read_markers_by_room_cache) {
- request_data.AddMember(rapidjson::Value(key.c_str(), request_data.GetAllocator()).Move(), val, request_data.GetAllocator());
+ {
+ std::lock_guard<std::recursive_mutex> lock(room_data_mutex);
+ load_qm_read_markers_from_account_data(); // TODO: Only do this if multiple instances of quickmedia matrix is running (on the same account)
+ qm_read_markers_by_room_cache[room->id] = timestamp;
+ room->read_marker_event_timestamp = timestamp;
+ for(const auto &[key, val] : qm_read_markers_by_room_cache) {
+ request_data.AddMember(rapidjson::Value(key.c_str(), request_data.GetAllocator()).Move(), val, request_data.GetAllocator());
+ }
}
rapidjson::StringBuffer buffer;
@@ -5210,8 +5215,6 @@ namespace QuickMedia {
if(download_result != DownloadResult::OK)
return download_result_to_plugin_result(download_result);
- room->read_marker_event_timestamp = timestamp;
- qm_read_markers_by_room_cache[room->id] = timestamp;
return PluginResult::OK;
}
@@ -5232,8 +5235,8 @@ namespace QuickMedia {
if(!json_root.IsObject())
return;
- qm_read_markers_by_room_cache.clear();
std::lock_guard<std::recursive_mutex> lock(room_data_mutex);
+ qm_read_markers_by_room_cache.clear();
for(auto const &obj : json_root.GetObject()) {
if(!obj.name.IsString() || !obj.value.IsInt64())
continue;