diff options
author | dec05eba <dec05eba@protonmail.com> | 2020-11-09 04:48:40 +0100 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2020-11-09 04:48:40 +0100 |
commit | 58add3408ac8b2c2aeabb22ad00990f297bb6954 (patch) | |
tree | ae7edc563f5f32c4e7a0fd18b448858666fc4f5d | |
parent | 4af367373f6f92b0fc1d79b2871fa942e1eb86fa (diff) |
Matrix: fix display name if using user id for name, add ban/kick reason
-rw-r--r-- | src/plugins/Matrix.cpp | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/src/plugins/Matrix.cpp b/src/plugins/Matrix.cpp index 0c94dd5..e604745 100644 --- a/src/plugins/Matrix.cpp +++ b/src/plugins/Matrix.cpp @@ -99,8 +99,9 @@ namespace QuickMedia { } UserInfo::UserInfo(RoomData *room, std::string user_id) : - room(room), display_name_color(user_id_to_color(user_id)), user_id(std::move(user_id)), display_name(user_id) { - + room(room), display_name_color(user_id_to_color(user_id)), user_id(user_id) + { + display_name = std::move(user_id); } UserInfo::UserInfo(RoomData *room, std::string user_id, std::string display_name, std::string avatar_url) : @@ -1760,6 +1761,10 @@ namespace QuickMedia { std::string user_display_name = room_data->get_user_display_name(user); std::string sender_display_name = room_data->get_user_display_name(user_sender); std::string body; + std::string reason_str; + const rapidjson::Value &reason_json = GetMember(*content_json, "reason"); + if(reason_json.IsString()) + reason_str = std::string(reason_json.GetString(), reason_json.GetStringLength()); const rapidjson::Value &membership_json = GetMember(*content_json, "membership"); if(strcmp(membership_json.GetString(), "join") == 0) { const rapidjson::Value &unsigned_json = GetMember(event_item_json, "unsigned"); @@ -1800,10 +1805,14 @@ namespace QuickMedia { body = user_display_name + " was kicked from the room by " + sender_display_name; else body = user_display_name + " left the room"; + if(!reason_str.empty()) + body += ", reason: " + reason_str; } else if(strcmp(membership_json.GetString(), "invite") == 0) { body = user_display_name + " was invited to the room by " + sender_display_name; } else if(strcmp(membership_json.GetString(), "ban") == 0) { body = user_display_name + " was banned from the room by " + sender_display_name; + if(!reason_str.empty()) + body += ", reason: " + reason_str; } else { body = "unimplemented membership: " + std::string(membership_json.GetString()); } |