aboutsummaryrefslogtreecommitdiff
path: root/src/plugins/Matrix.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/Matrix.cpp')
-rw-r--r--src/plugins/Matrix.cpp19
1 files changed, 13 insertions, 6 deletions
diff --git a/src/plugins/Matrix.cpp b/src/plugins/Matrix.cpp
index 1e35d9e..f6a91e7 100644
--- a/src/plugins/Matrix.cpp
+++ b/src/plugins/Matrix.cpp
@@ -1005,7 +1005,7 @@ namespace QuickMedia {
{ "-H", "Authorization: Bearer " + access_token },
{ "-m", "35" }
};
-
+#if 0
sync_additional_messages_thread = std::thread([this]() {
std::vector<CommandArg> additional_args = {
{ "-H", "Authorization: Bearer " + access_token },
@@ -1031,7 +1031,7 @@ namespace QuickMedia {
additional_messages_queue.pop_wait();
parse_sync_response(json_root, true);
});
-
+#endif
const rapidjson::Value *next_batch_json;
PluginResult result;
bool initial_sync = true;
@@ -2743,13 +2743,20 @@ namespace QuickMedia {
char url[512];
snprintf(url, sizeof(url), "%s/_matrix/client/r0/rooms/%s/event/%s", homeserver.c_str(), room->id.c_str(), event_id.c_str());
#endif
- std::string err_msg;
- rapidjson::Document json_root;
- DownloadResult download_result = download_json(json_root, url, std::move(additional_args), true, &err_msg);
+ std::string response;
+ DownloadResult download_result = download_to_string_cache(url, response, std::move(additional_args), use_tor, true);
if(download_result != DownloadResult::OK) return nullptr;
+ rapidjson::Document json_root;
+ rapidjson::ParseResult parse_result = json_root.Parse(response.c_str(), response.size());
+ if(parse_result.IsError()) {
+ fprintf(stderr, "Failed to get message by id %s\n", event_id.c_str());
+ room->fetched_messages_by_event_id.insert(std::make_pair(event_id, nullptr));
+ return nullptr;
+ }
+
if(!json_root.IsObject()) {
- fprintf(stderr, "Failed to get message by id %s, error: %s\n", event_id.c_str(), err_msg.c_str());
+ fprintf(stderr, "Failed to get message by id %s\n", event_id.c_str());
room->fetched_messages_by_event_id.insert(std::make_pair(event_id, nullptr));
return nullptr;
}