aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/plugins/Matrix.cpp33
1 files changed, 3 insertions, 30 deletions
diff --git a/src/plugins/Matrix.cpp b/src/plugins/Matrix.cpp
index f9bfe30..5dfd1d1 100644
--- a/src/plugins/Matrix.cpp
+++ b/src/plugins/Matrix.cpp
@@ -137,37 +137,10 @@ namespace QuickMedia {
}
PluginResult Matrix::get_joined_rooms(Rooms &rooms) {
- std::vector<CommandArg> additional_args = {
- { "-H", "Authorization: Bearer " + access_token }
- };
-
- rapidjson::Document json_root;
- DownloadResult download_result = download_json(json_root, homeserver + "/_matrix/client/r0/joined_rooms", std::move(additional_args), true);
- if(download_result != DownloadResult::OK) return download_result_to_plugin_result(download_result);
-
- if(!json_root.IsObject())
- return PluginResult::ERR;
-
- const rapidjson::Value &joined_rooms_json = GetMember(json_root, "joined_rooms");
- if(!joined_rooms_json.IsArray())
- return PluginResult::ERR;
-
- for(const rapidjson::Value &room_id_json : joined_rooms_json.GetArray()) {
- if(!room_id_json.IsString())
- continue;
-
- std::string room_id_str = room_id_json.GetString();
- auto room = get_room_by_id(room_id_str);
- if(!room) {
- room = std::make_shared<RoomData>();
- room->id = room_id_json.GetString();
- add_room(std::move(room));
- fprintf(stderr, "Missing room %s from /sync, adding in joined_rooms\n", room_id_str.c_str());
- }
-
- rooms.push_back(room);
+ std::lock_guard<std::mutex> lock(room_data_mutex);
+ for(auto &it : room_data_by_id) {
+ rooms.push_back(it.second);
}
-
return PluginResult::OK;
}