diff options
author | dec05eba <dec05eba@protonmail.com> | 2021-01-09 06:31:55 +0100 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2021-01-09 06:31:55 +0100 |
commit | 0910f4ce6883981c232811ee4d71da4a93e20845 (patch) | |
tree | ad267fb2eb850391514cfb6e76ec2df687962854 /src/plugins | |
parent | 8074309e58110bf6ea99ead65e6b1cca8ca0a40d (diff) |
Matrix: add reject invite and unban messages
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/Matrix.cpp | 33 |
1 files changed, 29 insertions, 4 deletions
diff --git a/src/plugins/Matrix.cpp b/src/plugins/Matrix.cpp index a07d050..c87d604 100644 --- a/src/plugins/Matrix.cpp +++ b/src/plugins/Matrix.cpp @@ -1892,10 +1892,35 @@ namespace QuickMedia { body = user_display_name + " joined the room"; } } else if(strcmp(membership_json.GetString(), "leave") == 0) { - if(sent_by_somebody_else) - body = user_display_name + " was kicked from the room by " + sender_display_name; - else - body = user_display_name + " left the room"; + if(sent_by_somebody_else) { + bool unbanned = false; + if(unsigned_json.IsObject()) { + const rapidjson::Value &prev_content_json = GetMember(unsigned_json, "prev_content"); + if(prev_content_json.IsObject()) { + const rapidjson::Value &prev_membership_json = GetMember(prev_content_json, "membership"); + if(prev_membership_json.IsString() && strcmp(prev_membership_json.GetString(), "ban") == 0) { + body = user_display_name + " was unbanned from the room by " + sender_display_name; + unbanned = true; + } + } + } + if(!unbanned) + body = user_display_name + " was kicked from the room by " + sender_display_name; + } else { + bool invite = false; + if(unsigned_json.IsObject()) { + const rapidjson::Value &prev_content_json = GetMember(unsigned_json, "prev_content"); + if(prev_content_json.IsObject()) { + const rapidjson::Value &prev_membership_json = GetMember(prev_content_json, "membership"); + if(prev_membership_json.IsString() && strcmp(prev_membership_json.GetString(), "invite") == 0) { + body = user_display_name + " rejected the invitation"; + invite = true; + } + } + } + if(!invite) + body = user_display_name + " left the room"; + } if(!reason_str.empty()) body += ", reason: " + reason_str; } else if(strcmp(membership_json.GetString(), "invite") == 0) { |