aboutsummaryrefslogtreecommitdiff
path: root/src/plugins
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2023-02-13 17:39:55 +0100
committerdec05eba <dec05eba@protonmail.com>2023-02-13 17:39:55 +0100
commit0d4670e094f32ef7dc5d3752b749107b0fb8317c (patch)
tree6f80f2ec8d4ef192d43ddc26ba90af384ec4b007 /src/plugins
parent37c38b085b56701410818efae8811c1f7983a335 (diff)
Matrix: better reply notification. Only mark as reply if it's a direct reply to you
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/Matrix.cpp19
1 files changed, 14 insertions, 5 deletions
diff --git a/src/plugins/Matrix.cpp b/src/plugins/Matrix.cpp
index 04062f3..062d16a 100644
--- a/src/plugins/Matrix.cpp
+++ b/src/plugins/Matrix.cpp
@@ -826,7 +826,7 @@ namespace QuickMedia {
if(message->body_is_formatted)
return formatted_text_to_qm_text(matrix, message->body.c_str(), message->body.size(), allow_formatted_text, image_max_size);
else
- return message->body;
+ return message->body; // TODO: Remove > <@ formatting?
}
std::string pantalaimon_url_to_homeserver_url(Matrix *matrix, const std::string &url) {
@@ -2657,6 +2657,15 @@ namespace QuickMedia {
}
bool message_contains_user_mention(Matrix *matrix, const Message *message, const std::string &username, const std::string &user_id) {
+ if(message->body_is_formatted) {
+ if(message->body.find("href=\"https://matrix.to/#/" + user_id + "\"") != std::string::npos)
+ return true;
+ } else {
+ const std::string mention_str = "> <" + user_id + ">";
+ if(string_starts_with(message->body, mention_str.c_str()))
+ return true;
+ }
+
const std::string formatted_text = message_to_qm_text(matrix, message, false);
return message_contains_user_mention(formatted_text, username) || message_contains_user_mention(formatted_text, user_id) || (power_level_is_at_least_admin(message->user->power_level, message->user->room) && message_contains_user_mention(formatted_text, "@room"));
}
@@ -2725,10 +2734,10 @@ namespace QuickMedia {
// TODO: Is @room ok? shouldn't we also check if the user has permission to do @room? (only when notifications are limited to @mentions)
// TODO: Is comparing against read marker timestamp ok enough?
if(message_is_timeline(message.get()) && me && message->timestamp > read_marker_message_timestamp && may_have_unread_notifications) {
- message->notification_mentions_me = message_contains_user_mention(message->body, my_display_name)
- || message_contains_user_mention(message->body, me->user_id)
- || (has_unread_notifications && message_contains_user_mention(message->body, "@room")); // TODO: ...
- //|| (power_level_is_at_least_admin(message->user->power_level, room_data) && message_contains_user_mention(message->body, "@room"));
+ const std::string message_str = message_to_qm_text(this, message.get(), false);
+ message->notification_mentions_me = message_contains_user_mention(this, message.get(), my_display_name, me->user_id)
+ || (has_unread_notifications && message_contains_user_mention(message_str, "@room")); // TODO: ...
+ //|| (power_level_is_at_least_admin(message->user->power_level, room_data) && message_contains_user_mention(message_str, "@room"));
}
}