From 2dd6c6f4b648af951d08ddd503dbb2ada8ddf5b6 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Sun, 25 Jun 2023 01:29:05 +0200 Subject: Matrix: remove reply formatting from image save name in reply image messages --- plugins/Matrix.hpp | 1 + src/QuickMedia.cpp | 2 +- src/plugins/Matrix.cpp | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/plugins/Matrix.hpp b/plugins/Matrix.hpp index 4a25f74..6cc3668 100644 --- a/plugins/Matrix.hpp +++ b/plugins/Matrix.hpp @@ -36,6 +36,7 @@ namespace QuickMedia { // Returns empty string on error std::string extract_user_name_from_email(const std::string &email); std::vector matrix_extract_room_ids(const std::string &str); + std::string remove_reply_formatting(Matrix *matrix, const Message *message, bool keep_formatted = false); struct MatrixChatBodyDecryptJob { enum class DecryptState { diff --git a/src/QuickMedia.cpp b/src/QuickMedia.cpp index 04638f0..a7d9f49 100644 --- a/src/QuickMedia.cpp +++ b/src/QuickMedia.cpp @@ -6763,7 +6763,7 @@ namespace QuickMedia { const char *music_prefix = "🎵 Play "; const char *file_prefix = "💾 Download "; - std::string filename = selected_item_message->body; + std::string filename = remove_reply_formatting(matrix, selected_item_message); if(string_starts_with(filename, video_prefix)) filename.erase(filename.begin(), filename.begin() + strlen(video_prefix)); else if(string_starts_with(filename, music_prefix)) diff --git a/src/plugins/Matrix.cpp b/src/plugins/Matrix.cpp index 9dd4ec9..13c6f4f 100644 --- a/src/plugins/Matrix.cpp +++ b/src/plugins/Matrix.cpp @@ -298,7 +298,7 @@ namespace QuickMedia { return str; } - static std::string remove_reply_formatting(Matrix *matrix, const Message *message, bool keep_formatted = false) { + std::string remove_reply_formatting(Matrix *matrix, const Message *message, bool keep_formatted) { if(!message->body_is_formatted && strncmp(message->body.c_str(), "> <@", 4) == 0) { size_t index = message->body.find("> ", 4); if(index != std::string::npos) { -- cgit v1.2.3