aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2020-11-24 08:46:13 +0100
committerdec05eba <dec05eba@protonmail.com>2020-11-24 08:46:13 +0100
commitba97f72453b76942b6eba9c6f2134b64cb1304c5 (patch)
treecea91b102683930f3dde6f6dd02ea3b107c00028 /src
parentb9404b292b1ee8c5dd4868f4fef9629f1d66d39f (diff)
Matrix: fix user display name when added by invite (state_key)
Diffstat (limited to 'src')
-rw-r--r--src/plugins/Matrix.cpp17
1 files changed, 12 insertions, 5 deletions
diff --git a/src/plugins/Matrix.cpp b/src/plugins/Matrix.cpp
index 291787f..653569d 100644
--- a/src/plugins/Matrix.cpp
+++ b/src/plugins/Matrix.cpp
@@ -456,8 +456,12 @@ namespace QuickMedia {
static std::string message_to_room_description_text(Message *message) {
if(message->type == MessageType::REACTION)
return "Reacted with: " + extract_first_line_elipses(message->body, 150);
+ else if(message->related_event_type == RelatedEventType::REPLY)
+ return extract_first_line_elipses(remove_reply_formatting(message->body), 150);
+ else if(message->related_event_type == RelatedEventType::EDIT)
+ return "Edited: " + extract_first_line_elipses(message->body, 150);
else
- return extract_first_line_elipses(message_get_body_remove_formatting(message), 150);
+ return extract_first_line_elipses(message->body, 150);
}
void MatrixQuickMedia::update_room_description(RoomData *room, Messages &new_messages, bool is_initial_sync, bool sync_is_cache) {
@@ -1496,16 +1500,19 @@ namespace QuickMedia {
if(!type_json.IsString() || strcmp(type_json.GetString(), "m.room.member") != 0)
continue;
- const rapidjson::Value &sender_json = GetMember(event_item_json, "sender");
- if(!sender_json.IsString())
+ const rapidjson::Value *sender_json = &GetMember(event_item_json, "sender");
+ if(!sender_json->IsString())
continue;
+
+ const rapidjson::Value *state_key_json = &GetMember(event_item_json, "state_key");
+ if(state_key_json->IsString() && state_key_json->GetStringLength() != 0)
+ sender_json = state_key_json;
const rapidjson::Value &content_json = GetMember(event_item_json, "content");
if(!content_json.IsObject())
continue;
- std::string sender_json_str = sender_json.GetString();
- parse_user_info(content_json, sender_json_str, room_data);
+ parse_user_info(content_json, sender_json->GetString(), room_data);
}
}