diff options
author | dec05eba <dec05eba@protonmail.com> | 2020-11-19 10:16:05 +0100 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2020-11-19 10:16:05 +0100 |
commit | 9aa8c291e775083078efe93d0bc42390955ae61a (patch) | |
tree | 3d997db844e6c4796a91dc1e5eb1b2124a50100a /src/plugins | |
parent | ff1390601c8b7b4fbec87f3f23a76495118eff91 (diff) |
Matrix: cache get_message_by_id, temporary remove fetching additional messages which corrupts messages
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/Matrix.cpp | 19 |
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; } |