Disable chat if we were removed from the group.

This commit is contained in:
Mikunj 2020-04-09 10:47:18 +10:00
parent 3ec5974210
commit 4a36ed333d
1 changed files with 7 additions and 1 deletions

View File

@ -173,7 +173,6 @@ public class GroupMessageProcessor {
// We add any new or removed members to the group context
// This will allow us later to iterate over them to check if they left or were added for UI display
for (Address addedMember : addedMembers) {
builder.addMembers(addedMember.serialize());
}
@ -182,6 +181,13 @@ public class GroupMessageProcessor {
builder.addMembers(removedMember.serialize());
}
// If we were removed then we need to disable the chat
String masterHexEncodedPublicKey = TextSecurePreferences.getMasterHexEncodedPublicKey(context);
String ourHexEncodedPublicKey = masterHexEncodedPublicKey != null ? masterHexEncodedPublicKey : TextSecurePreferences.getLocalNumber(context);
if (removedMembers.contains(Address.fromSerialized(ourHexEncodedPublicKey))) {
database.setActive(id, false);
}
if (group.getName().isPresent() || group.getAvatar().isPresent()) {
SignalServiceAttachment avatar = group.getAvatar().orNull();
database.update(id, group.getName().orNull(), avatar != null ? avatar.asPointer() : null);