aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2023-06-25 01:29:05 +0200
committerdec05eba <dec05eba@protonmail.com>2023-06-25 01:29:05 +0200
commit2dd6c6f4b648af951d08ddd503dbb2ada8ddf5b6 (patch)
treee6562f057a152e5b63011c61916342c1645d9fe8
parent3f17b05161885ab773984a735a4161493e846fb6 (diff)
Matrix: remove reply formatting from image save name in reply image messages
-rw-r--r--plugins/Matrix.hpp1
-rw-r--r--src/QuickMedia.cpp2
-rw-r--r--src/plugins/Matrix.cpp2
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<std::string> 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) {