aboutsummaryrefslogtreecommitdiff
path: root/src/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/Matrix.cpp34
1 files changed, 32 insertions, 2 deletions
diff --git a/src/plugins/Matrix.cpp b/src/plugins/Matrix.cpp
index f6a91e7..f17da30 100644
--- a/src/plugins/Matrix.cpp
+++ b/src/plugins/Matrix.cpp
@@ -715,7 +715,15 @@ namespace QuickMedia {
}
for(auto &room_body_item : it.second) {
- tag_data->room_body_items.push_back(room_body_item);
+ bool already_exists = false;
+ for(auto &body_it : tag_data->room_body_items) {
+ if(body_it->userdata == room_body_item->userdata) {
+ already_exists = true;
+ break;
+ }
+ }
+ if(!already_exists)
+ tag_data->room_body_items.push_back(room_body_item);
}
}
add_room_body_items_by_tags.clear();
@@ -2744,7 +2752,22 @@ namespace QuickMedia {
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 response;
- DownloadResult download_result = download_to_string_cache(url, response, std::move(additional_args), use_tor, true);
+ DownloadResult download_result = download_to_string_cache(url, response, std::move(additional_args), use_tor, true, [](std::string &response) {
+ rapidjson::Document json_root;
+ rapidjson::ParseResult parse_result = json_root.Parse(response.c_str(), response.size());
+ if(parse_result.IsError() || !json_root.IsObject())
+ return false;
+
+ const rapidjson::Value &errcode_json = GetMember(json_root, "errcode");
+ if(errcode_json.IsString()) {
+ if(strcmp(errcode_json.GetString(), "M_FORBIDDEN") == 0)
+ return true;
+ else
+ return false;
+ }
+
+ return true;
+ });
if(download_result != DownloadResult::OK) return nullptr;
rapidjson::Document json_root;
@@ -2761,6 +2784,13 @@ namespace QuickMedia {
return nullptr;
}
+ const rapidjson::Value &errcode_json = GetMember(json_root, "errcode");
+ if(errcode_json.IsString() && strcmp(errcode_json.GetString(), "M_FORBIDDEN") == 0) {
+ fprintf(stderr, "You donm't have permission to access event %s\n", event_id.c_str());
+ room->fetched_messages_by_event_id.insert(std::make_pair(event_id, nullptr));
+ return nullptr;
+ }
+
const rapidjson::Value &error_json = GetMember(json_root, "error");
if(error_json.IsString()) {
fprintf(stderr, "Matrix::get_message_by_id, error: %s\n", error_json.GetString());