aboutsummaryrefslogtreecommitdiff
path: root/src/plugins/Matrix.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/Matrix.cpp')
-rw-r--r--src/plugins/Matrix.cpp16
1 files changed, 11 insertions, 5 deletions
diff --git a/src/plugins/Matrix.cpp b/src/plugins/Matrix.cpp
index 35f5302..ff0d498 100644
--- a/src/plugins/Matrix.cpp
+++ b/src/plugins/Matrix.cpp
@@ -462,7 +462,7 @@ 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)
if(has_unread_notifications && me)
- new_message->mentions_me = message_contains_user_mention(new_message->body, me->display_name) || message_contains_user_mention(new_message->body, "@room");
+ new_message->mentions_me = message_contains_user_mention(new_message->body, me->display_name) || message_contains_user_mention(new_message->body, me->user_id) || message_contains_user_mention(new_message->body, "@room");
new_messages.push_back(std::move(new_message));
}
@@ -978,17 +978,23 @@ namespace QuickMedia {
static std::string create_body_for_message_reply(const Message *message, const std::string &body) {
return "> <" + message->user->user_id + "> " + block_quote(get_reply_message(message)) + "\n\n" + body;
}
+
+ static std::string extract_homeserver_from_room_id(const std::string &room_id) {
+ size_t sep_index = room_id.find(':');
+ if(sep_index != std::string::npos)
+ return room_id.substr(sep_index + 1);
+ return "";
+ }
- static std::string create_formatted_body_for_message_reply(const Message *message, const std::string &body) {
+ static std::string create_formatted_body_for_message_reply(RoomData *room, const Message *message, const std::string &body) {
std::string formatted_body = body;
std::string related_to_body = get_reply_message(message);
html_escape_sequences(formatted_body);
html_escape_sequences(related_to_body);
- // TODO: Fix invalid.url, etc to use same as element. This is required to navigate to reply message in element mobile.
// TODO: Add keybind to navigate to the reply message, which would also depend on this formatting.
return "<mx-reply>"
"<blockquote>"
- "<a href=\"https://invalid.url\">In reply to</a>"
+ "<a href=\"https://matrix.to/#/" + room->id + "/" + message->event_id + "?via=" + extract_homeserver_from_room_id(room->id) + "\">In reply to</a>"
"<a href=\"https://matrix.to/#/" + message->user->user_id + "\">" + message->user->user_id + "</a><br>" + std::move(related_to_body) +
"</blockquote>"
"</mx-reply>" + std::move(formatted_body);
@@ -1018,7 +1024,7 @@ namespace QuickMedia {
relates_to_json.AddMember("m.in_reply_to", std::move(in_reply_to_json), relates_to_json.GetAllocator());
std::string message_reply_body = create_body_for_message_reply(relates_to_message_raw, body); // Yes, the reply is to the edited message but the event_id reference is to the original message...
- std::string formatted_message_reply_body = create_formatted_body_for_message_reply(relates_to_message_raw, body);
+ std::string formatted_message_reply_body = create_formatted_body_for_message_reply(room, relates_to_message_raw, body);
rapidjson::Document request_data(rapidjson::kObjectType);
request_data.AddMember("msgtype", "m.text", request_data.GetAllocator()); // TODO: Allow image reply? element doesn't do that but we could!