From d5da6e47e14831b865d418faa32f32df4de5af42 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Thu, 19 Nov 2020 17:03:49 +0100 Subject: Matrix: fix too long path in event cache, bug when not using error handler.. --- src/plugins/Matrix.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/Matrix.cpp b/src/plugins/Matrix.cpp index f17da30..b0c83cc 100644 --- a/src/plugins/Matrix.cpp +++ b/src/plugins/Matrix.cpp @@ -4,6 +4,7 @@ #include "../../include/NetUtils.hpp" #include "../../include/Notification.hpp" #include "../../include/Program.hpp" +#include "../../include/base64_url.hpp" #include #include #include @@ -2767,33 +2768,33 @@ namespace QuickMedia { } return true; - }); + }, get_cache_dir().join("matrix").join("events").join(base64_url::encode(event_id))); 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()); + fprintf(stderr, "Failed to get message by id %s, error: %s\n", event_id.c_str(), response.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\n", event_id.c_str()); + fprintf(stderr, "Failed to get message by id %s, error: %s\n", event_id.c_str(), response.c_str()); room->fetched_messages_by_event_id.insert(std::make_pair(event_id, nullptr)); 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()); + fprintf(stderr, "You don'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()); + fprintf(stderr, "Matrix::get_message_by_id for event id: %s, error: %s\n", event_id.c_str(), error_json.GetString()); room->fetched_messages_by_event_id.insert(std::make_pair(event_id, nullptr)); return nullptr; } -- cgit v1.2.3