From 3ec5974210e6441105e10eb892b32acbfe3c3700 Mon Sep 17 00:00:00 2001 From: Mikunj Date: Thu, 9 Apr 2020 09:41:01 +1000 Subject: [PATCH 1/6] Correctly display when user was kicked or added --- .../groups/GroupMessageProcessor.java | 46 +++++++++---------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/src/org/thoughtcrime/securesms/groups/GroupMessageProcessor.java b/src/org/thoughtcrime/securesms/groups/GroupMessageProcessor.java index c9145e77e1..a0dff036ac 100644 --- a/src/org/thoughtcrime/securesms/groups/GroupMessageProcessor.java +++ b/src/org/thoughtcrime/securesms/groups/GroupMessageProcessor.java @@ -146,40 +146,40 @@ public class GroupMessageProcessor { } } - Set
recordMembers = new HashSet<>(groupRecord.getMembers()); - Set
messageMembers = new HashSet<>(); + Set
currentMembers = new HashSet<>(groupRecord.getMembers()); + Set
newMembers = new HashSet<>(); for (String messageMember : group.getMembers().get()) { - messageMembers.add(Address.fromExternal(context, messageMember)); + newMembers.add(Address.fromExternal(context, messageMember)); } - Set
addedMembers = new HashSet<>(messageMembers); - addedMembers.removeAll(recordMembers); + // Added members are the members who are present in newMembers but not in currentMembers + Set
addedMembers = new HashSet<>(newMembers); + addedMembers.removeAll(currentMembers); - Set
missingMembers = new HashSet<>(recordMembers); - missingMembers.removeAll(messageMembers); + // Kicked members are members who are present in currentMembers but not in newMembers + Set
removedMembers = new HashSet<>(currentMembers); + removedMembers.removeAll(newMembers); GroupContext.Builder builder = createGroupContext(group); builder.setType(GroupContext.Type.UPDATE); - if (addedMembers.size() > 0) { - Set
unionMembers = new HashSet<>(recordMembers); - unionMembers.addAll(messageMembers); - database.updateMembers(id, new LinkedList<>(unionMembers)); - - builder.clearMembers(); - - for (Address addedMember : addedMembers) { - builder.addMembers(addedMember.serialize()); - } - } else { - builder.clearMembers(); + // Update our group members if they're different + if (!currentMembers.equals(newMembers)) { + database.updateMembers(id, new LinkedList<>(newMembers)); } - if (missingMembers.size() > 0) { - for (Address removedMember : missingMembers) { - builder.addMembers(removedMember.serialize()); - } + builder.clearMembers(); + + // 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()); + } + + for (Address removedMember : removedMembers) { + builder.addMembers(removedMember.serialize()); } if (group.getName().isPresent() || group.getAvatar().isPresent()) { From 4a36ed333db138a8ae2e067451d9443efd9f55ce Mon Sep 17 00:00:00 2001 From: Mikunj Date: Thu, 9 Apr 2020 10:47:18 +1000 Subject: [PATCH 2/6] Disable chat if we were removed from the group. --- .../securesms/groups/GroupMessageProcessor.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/org/thoughtcrime/securesms/groups/GroupMessageProcessor.java b/src/org/thoughtcrime/securesms/groups/GroupMessageProcessor.java index a0dff036ac..4e53e6273b 100644 --- a/src/org/thoughtcrime/securesms/groups/GroupMessageProcessor.java +++ b/src/org/thoughtcrime/securesms/groups/GroupMessageProcessor.java @@ -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); From f149065a30c8221d05e9df8a44d27ce54a6006b5 Mon Sep 17 00:00:00 2001 From: Mikunj Date: Thu, 9 Apr 2020 13:17:00 +1000 Subject: [PATCH 3/6] Fix GroupDescriptions updating dynamically. This shouldn't happen, rather it should have the snapshot of the group state per message. --- .../groups/GroupMessageProcessor.java | 38 ++++++----- .../securesms/util/GroupUtil.java | 63 +++++++------------ 2 files changed, 45 insertions(+), 56 deletions(-) diff --git a/src/org/thoughtcrime/securesms/groups/GroupMessageProcessor.java b/src/org/thoughtcrime/securesms/groups/GroupMessageProcessor.java index 4e53e6273b..719a7dd7d8 100644 --- a/src/org/thoughtcrime/securesms/groups/GroupMessageProcessor.java +++ b/src/org/thoughtcrime/securesms/groups/GroupMessageProcessor.java @@ -137,13 +137,25 @@ public class GroupMessageProcessor { GroupDatabase database = DatabaseFactory.getGroupDatabase(context); String id = GroupUtil.getEncodedId(group); - // Only update group if admin sent the message + String masterHexEncodedPublicKey = TextSecurePreferences.getMasterHexEncodedPublicKey(context); + String ourHexEncodedPublicKey = masterHexEncodedPublicKey != null ? masterHexEncodedPublicKey : TextSecurePreferences.getLocalNumber(context); + if (group.getGroupType() == SignalServiceGroup.GroupType.SIGNAL) { + // Only update group if admin sent the message String hexEncodedPublicKey = getMasterHexEncodedPublicKey(context, content.getSender()); if (!groupRecord.getAdmins().contains(Address.fromSerialized(hexEncodedPublicKey))) { Log.d("Loki - Group Message", "Received a group update message from a non-admin user for " + id +". Ignoring."); return null; } + + // We should only process update message if we were in the group + Address ourAddress = Address.fromSerialized(ourHexEncodedPublicKey); + if (!groupRecord.getMembers().contains(ourAddress) && + !group.getMembers().or(Collections.emptyList()).contains(ourHexEncodedPublicKey)) { + Log.d("Loki - Group Message", "Received a group update message from a group we are not members in: " + id + " . Ignoring."); + database.setActive(id, false); + return null; + } } Set
currentMembers = new HashSet<>(groupRecord.getMembers()); @@ -169,23 +181,14 @@ public class GroupMessageProcessor { database.updateMembers(id, new LinkedList<>(newMembers)); } - builder.clearMembers(); - // 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()); + builder.addNewMembers(addedMember.serialize()); } for (Address removedMember : removedMembers) { - 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); + builder.addRemovedMembers(removedMember.serialize()); } if (group.getName().isPresent() || group.getAvatar().isPresent()) { @@ -197,10 +200,15 @@ public class GroupMessageProcessor { builder.clearName(); } - if (!groupRecord.isActive()) database.setActive(id, true); + // If we were removed then we need to disable the chat + if (removedMembers.contains(Address.fromSerialized(ourHexEncodedPublicKey))) { + database.setActive(id, false); + } else { + if (!groupRecord.isActive()) database.setActive(id, true); - if (group.getMembers().isPresent()) { - establishSessionsWithMembersIfNeeded(context, group.getMembers().get()); + if (group.getMembers().isPresent()) { + establishSessionsWithMembersIfNeeded(context, group.getMembers().get()); + } } return storeMessage(context, content, group, builder.build(), outgoing); diff --git a/src/org/thoughtcrime/securesms/util/GroupUtil.java b/src/org/thoughtcrime/securesms/util/GroupUtil.java index 907a21217e..0029d5f6a4 100644 --- a/src/org/thoughtcrime/securesms/util/GroupUtil.java +++ b/src/org/thoughtcrime/securesms/util/GroupUtil.java @@ -10,7 +10,6 @@ import com.google.protobuf.ByteString; import org.thoughtcrime.securesms.database.Address; import org.thoughtcrime.securesms.database.DatabaseFactory; import org.thoughtcrime.securesms.database.GroupDatabase; -import org.thoughtcrime.securesms.database.GroupDatabase.GroupRecord; import org.thoughtcrime.securesms.logging.Log; import org.thoughtcrime.securesms.mms.OutgoingGroupMediaMessage; import org.thoughtcrime.securesms.recipients.Recipient; @@ -159,7 +158,7 @@ public class GroupUtil { @NonNull private final Context context; @Nullable private final GroupContext groupContext; - private final List members; + private final List newMembers; private final List removedMembers; private boolean ourDeviceWasRemoved; @@ -167,35 +166,35 @@ public class GroupUtil { this.context = context.getApplicationContext(); this.groupContext = groupContext; - this.members = new LinkedList<>(); + this.newMembers = new LinkedList<>(); this.removedMembers = new LinkedList<>(); this.ourDeviceWasRemoved = false; - if (groupContext != null && !groupContext.getMembersList().isEmpty()) { - List memberList = groupContext.getMembersList(); - List
currentMembers = getCurrentGroupMembers(); + if (groupContext != null) { + List newMembers = groupContext.getNewMembersList(); + for (String member : newMembers) { + this.newMembers.add(this.toRecipient(member)); + } - // Add them to the member or removed members lists - for (String member : memberList) { - Address address = Address.fromSerialized(member); - Recipient recipient = Recipient.from(context, address, true); - if (currentMembers == null || currentMembers.contains(address)) { - this.members.add(recipient); - } else { - this.removedMembers.add(recipient); - } + List removedMembers = groupContext.getRemovedMembersList(); + for (String member : removedMembers) { + this.removedMembers.add(this.toRecipient(member)); } // Check if our device was removed if (!removedMembers.isEmpty()) { String masterHexEncodedPublicKey = TextSecurePreferences.getMasterHexEncodedPublicKey(context); String hexEncodedPublicKey = masterHexEncodedPublicKey != null ? masterHexEncodedPublicKey : TextSecurePreferences.getLocalNumber(context); - Recipient self = Recipient.from(context, Address.fromSerialized(hexEncodedPublicKey), false); - ourDeviceWasRemoved = removedMembers.contains(self); + ourDeviceWasRemoved = removedMembers.contains(hexEncodedPublicKey); } } } + private Recipient toRecipient(String hexEncodedPublicKey) { + Address address = Address.fromSerialized(hexEncodedPublicKey); + return Recipient.from(context, address, false); + } + public String toString(Recipient sender) { // Show the local removed message if (ourDeviceWasRemoved) { @@ -211,10 +210,10 @@ public class GroupUtil { String title = groupContext.getName(); - if (!members.isEmpty()) { + if (!newMembers.isEmpty()) { description.append("\n"); description.append(context.getResources().getQuantityString(R.plurals.GroupUtil_joined_the_group, - members.size(), toString(members))); + newMembers.size(), toString(newMembers))); } if (!removedMembers.isEmpty()) { @@ -224,8 +223,8 @@ public class GroupUtil { } if (title != null && !title.trim().isEmpty()) { - if (!members.isEmpty()) description.append(" "); - else description.append("\n"); + String separator = (!newMembers.isEmpty() || !removedMembers.isEmpty()) ? " " : "\n"; + description.append(separator); description.append(context.getString(R.string.GroupUtil_group_name_is_now, title)); } @@ -233,8 +232,8 @@ public class GroupUtil { } public void addListener(RecipientModifiedListener listener) { - if (!this.members.isEmpty()) { - for (Recipient member : this.members) { + if (!this.newMembers.isEmpty()) { + for (Recipient member : this.newMembers) { member.addListener(listener); } } @@ -252,23 +251,5 @@ public class GroupUtil { return result; } - - private List
getCurrentGroupMembers() { - if (groupContext == null) { return null; } - GroupDatabase groupDatabase = DatabaseFactory.getGroupDatabase(context); - byte[] decodedGroupId = groupContext.getId().toByteArray(); - String signalGroupId = getEncodedId(decodedGroupId, false); - String publicChatId = getEncodedPublicChatId(decodedGroupId); - String rssFeedId = getEncodedRSSFeedId(decodedGroupId); - GroupRecord groupRecord = null; - if (!groupDatabase.isUnknownGroup(signalGroupId)) { - groupRecord = groupDatabase.getGroup(signalGroupId).orNull(); - } else if (!groupDatabase.isUnknownGroup(publicChatId)) { - groupRecord = groupDatabase.getGroup(publicChatId).orNull(); - } else if (!groupDatabase.isUnknownGroup(rssFeedId)) { - groupRecord = groupDatabase.getGroup(rssFeedId).orNull(); - } - return (groupRecord != null) ? groupRecord.getMembers() : null; - } } } From 45220bfa701af4d040bc72df2c6e6032ad91a0c5 Mon Sep 17 00:00:00 2001 From: Mikunj Date: Thu, 9 Apr 2020 13:23:51 +1000 Subject: [PATCH 4/6] Hide input when group is marked as not active. Fix bug where input panel gets shown when you long press a message. --- .../conversation/ConversationActivity.java | 31 ++++++++++--------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/src/org/thoughtcrime/securesms/conversation/ConversationActivity.java b/src/org/thoughtcrime/securesms/conversation/ConversationActivity.java index d1b9136ddd..93819bc5f4 100644 --- a/src/org/thoughtcrime/securesms/conversation/ConversationActivity.java +++ b/src/org/thoughtcrime/securesms/conversation/ConversationActivity.java @@ -317,7 +317,6 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity private Button makeDefaultSmsButton; private Button registerButton; private InputAwareLayout container; - private View composePanel; protected Stub reminderView; private Stub unverifiedBannerView; private Stub groupShareProfileView; @@ -552,7 +551,7 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity updateTitleTextView(recipient); updateSubtitleTextView(); setActionBarColor(recipient.getColor()); - setBlockedUserState(recipient, isSecureText, isDefaultSms); + updateInputUI(recipient, isSecureText, isDefaultSms); setGroupShareProfileReminder(recipient); calculateCharactersRemaining(); @@ -645,7 +644,7 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity updateTitleTextView(recipient); updateSubtitleTextView(); NotificationChannels.updateContactChannelName(this, recipient); - setBlockedUserState(recipient, isSecureText, isDefaultSms); + updateInputUI(recipient, isSecureText, isDefaultSms); supportInvalidateOptionsMenu(); break; case TAKE_PHOTO: @@ -858,6 +857,7 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity searchViewModel.onSearchClosed(); searchNav.setVisibility(View.GONE); inputPanel.setVisibility(View.VISIBLE); + updateInputUI(recipient, isSecureText, isDefaultSms); fragment.onSearchQueryUpdated(null); invalidateOptionsMenu(); return true; @@ -1343,7 +1343,7 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity calculateCharactersRemaining(); supportInvalidateOptionsMenu(); - setBlockedUserState(recipient, isSecureText, isDefaultSms); + updateInputUI(recipient, isSecureText, isDefaultSms); } ///// Initializers @@ -1627,7 +1627,6 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity unblockButton = ViewUtil.findById(this, R.id.unblock_button); makeDefaultSmsButton = ViewUtil.findById(this, R.id.make_default_sms_button); registerButton = ViewUtil.findById(this, R.id.register_button); - composePanel = ViewUtil.findById(this, R.id.bottom_panel); container = ViewUtil.findById(this, R.id.layout_container); reminderView = ViewUtil.findStubById(this, R.id.reminder_stub); unverifiedBannerView = ViewUtil.findStubById(this, R.id.unverified_banner_stub); @@ -1835,7 +1834,7 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity updateTitleTextView(recipient); updateSubtitleTextView(); // titleView.setVerified(identityRecords.isVerified()); - setBlockedUserState(recipient, isSecureText, isDefaultSms); + updateInputUI(recipient, isSecureText, isDefaultSms); setActionBarColor(recipient.getColor()); setGroupShareProfileReminder(recipient); updateReminders(recipient.hasSeenInviteReminder()); @@ -2043,29 +2042,29 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity setStatusBarColor(getResources().getColor(R.color.action_bar_background)); } - private void setBlockedUserState(Recipient recipient, boolean isSecureText, boolean isDefaultSms) { - if (recipient.isGroupRecipient() && recipient.getAddress().isRSSFeed()) { + private void updateInputUI(Recipient recipient, boolean isSecureText, boolean isDefaultSms) { + if (recipient.isGroupRecipient() && !isActiveGroup()) { unblockButton.setVisibility(View.GONE); - composePanel.setVisibility(View.GONE); + inputPanel.setVisibility(View.GONE); makeDefaultSmsButton.setVisibility(View.GONE); registerButton.setVisibility(View.GONE); } else if (recipient.isBlocked()) { unblockButton.setVisibility(View.VISIBLE); - composePanel.setVisibility(View.GONE); + inputPanel.setVisibility(View.GONE); makeDefaultSmsButton.setVisibility(View.GONE); registerButton.setVisibility(View.GONE); } else if (!isSecureText && isPushGroupConversation()) { unblockButton.setVisibility(View.GONE); - composePanel.setVisibility(View.GONE); + inputPanel.setVisibility(View.GONE); makeDefaultSmsButton.setVisibility(View.GONE); registerButton.setVisibility(View.VISIBLE); } else if (!isSecureText && !isDefaultSms) { unblockButton.setVisibility(View.GONE); - composePanel.setVisibility(View.GONE); + inputPanel.setVisibility(View.GONE); makeDefaultSmsButton.setVisibility(View.VISIBLE); registerButton.setVisibility(View.GONE); } else { - composePanel.setVisibility(View.VISIBLE); + inputPanel.setVisibility(View.VISIBLE); unblockButton.setVisibility(View.GONE); makeDefaultSmsButton.setVisibility(View.GONE); registerButton.setVisibility(View.GONE); @@ -2125,7 +2124,7 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity } private boolean isActiveGroup() { - if (!isGroupConversation()) return false; + if (!isGroupConversation() || recipient.getAddress().isRSSFeed()) return false; Optional record = DatabaseFactory.getGroupDatabase(this).getGroup(getRecipient().getAddress().toGroupString()); return record.isPresent() && record.get().isActive(); @@ -2314,7 +2313,7 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity String hint = enabled ? "Message" : "Pending session request"; inputPanel.setHint(hint); inputPanel.setEnabled(enabled); - if (enabled) { + if (enabled && inputPanel.getVisibility() == View.VISIBLE) { inputPanel.composeText.requestFocus(); InputMethodManager inputMethodManager = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE); inputMethodManager.showSoftInput(inputPanel.composeText, 0); @@ -2939,6 +2938,8 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity @Override public void handleReplyMessage(MessageRecord messageRecord) { + if (recipient.isGroupRecipient() && !isActiveGroup()) { return; } + Recipient author; if (messageRecord.isOutgoing()) { From 7d9eafe8fb67ac08f75d0fced6123f833be5465c Mon Sep 17 00:00:00 2001 From: Mikunj Date: Thu, 9 Apr 2020 15:30:29 +1000 Subject: [PATCH 5/6] Ignore closed group messages from users who are not members. --- .../groups/GroupMessageProcessor.java | 3 +-- .../securesms/jobs/PushDecryptJob.java | 23 ++++++++++++++++++- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/src/org/thoughtcrime/securesms/groups/GroupMessageProcessor.java b/src/org/thoughtcrime/securesms/groups/GroupMessageProcessor.java index 719a7dd7d8..29e591ffb2 100644 --- a/src/org/thoughtcrime/securesms/groups/GroupMessageProcessor.java +++ b/src/org/thoughtcrime/securesms/groups/GroupMessageProcessor.java @@ -137,8 +137,7 @@ public class GroupMessageProcessor { GroupDatabase database = DatabaseFactory.getGroupDatabase(context); String id = GroupUtil.getEncodedId(group); - String masterHexEncodedPublicKey = TextSecurePreferences.getMasterHexEncodedPublicKey(context); - String ourHexEncodedPublicKey = masterHexEncodedPublicKey != null ? masterHexEncodedPublicKey : TextSecurePreferences.getLocalNumber(context); + String ourHexEncodedPublicKey = getMasterHexEncodedPublicKey(context, TextSecurePreferences.getLocalNumber(context)); if (group.getGroupType() == SignalServiceGroup.GroupType.SIGNAL) { // Only update group if admin sent the message diff --git a/src/org/thoughtcrime/securesms/jobs/PushDecryptJob.java b/src/org/thoughtcrime/securesms/jobs/PushDecryptJob.java index 29d3a12172..c421e3ba8b 100644 --- a/src/org/thoughtcrime/securesms/jobs/PushDecryptJob.java +++ b/src/org/thoughtcrime/securesms/jobs/PushDecryptJob.java @@ -1895,7 +1895,28 @@ public class PushDecryptJob extends BaseJob implements InjectableType { boolean isGroupActive = groupId.isPresent() && groupDatabase.isActive(groupId.get()); boolean isLeaveMessage = message.getGroupInfo().isPresent() && message.getGroupInfo().get().getType() == SignalServiceGroup.Type.QUIT; - return (isContentMessage && !isGroupActive) || (sender.isBlocked() && !isLeaveMessage); + boolean isClosedGroup = conversation.getAddress().isSignalGroup(); + boolean isGroupMember = true; + + // Only allow messages from members of a group + if (isClosedGroup) { + String senderHexEncodedPublicKey = content.getSender(); + + try { + String masterHexEncodedPublicKey = PromiseUtil.timeout(LokiDeviceLinkUtilities.INSTANCE.getMasterHexEncodedPublicKey(content.getSender()), 5000).get(); + if (masterHexEncodedPublicKey != null) { + senderHexEncodedPublicKey = masterHexEncodedPublicKey; + } + } catch (Exception e) { + e.printStackTrace(); + } + + Recipient senderMaster = Recipient.from(context, Address.fromSerialized(senderHexEncodedPublicKey), false); + + isGroupMember = groupId.isPresent() && groupDatabase.getGroupMembers(groupId.get(), true).contains(senderMaster); + } + + return (isContentMessage && !isGroupActive) || (sender.isBlocked() && !isLeaveMessage) || (isContentMessage && !isGroupMember); } else { return sender.isBlocked(); } From 6ed3a4c3726ead174f073930c3199067d2d9c56d Mon Sep 17 00:00:00 2001 From: nielsandriesse Date: Wed, 15 Apr 2020 15:01:02 +1000 Subject: [PATCH 6/6] Add FIXME --- .../securesms/conversation/ConversationActivity.java | 1 + .../securesms/groups/GroupMessageProcessor.java | 8 ++++---- src/org/thoughtcrime/securesms/jobs/PushDecryptJob.java | 6 +++--- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/org/thoughtcrime/securesms/conversation/ConversationActivity.java b/src/org/thoughtcrime/securesms/conversation/ConversationActivity.java index 93819bc5f4..7721233336 100644 --- a/src/org/thoughtcrime/securesms/conversation/ConversationActivity.java +++ b/src/org/thoughtcrime/securesms/conversation/ConversationActivity.java @@ -2042,6 +2042,7 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity setStatusBarColor(getResources().getColor(R.color.action_bar_background)); } + // FIXME: This name is confusing because we also have updateInputPanel and setInputPanelEnabled private void updateInputUI(Recipient recipient, boolean isSecureText, boolean isDefaultSms) { if (recipient.isGroupRecipient() && !isActiveGroup()) { unblockButton.setVisibility(View.GONE); diff --git a/src/org/thoughtcrime/securesms/groups/GroupMessageProcessor.java b/src/org/thoughtcrime/securesms/groups/GroupMessageProcessor.java index 29e591ffb2..52ffa66183 100644 --- a/src/org/thoughtcrime/securesms/groups/GroupMessageProcessor.java +++ b/src/org/thoughtcrime/securesms/groups/GroupMessageProcessor.java @@ -140,18 +140,18 @@ public class GroupMessageProcessor { String ourHexEncodedPublicKey = getMasterHexEncodedPublicKey(context, TextSecurePreferences.getLocalNumber(context)); if (group.getGroupType() == SignalServiceGroup.GroupType.SIGNAL) { - // Only update group if admin sent the message + // Only update group if the group admin sent the message String hexEncodedPublicKey = getMasterHexEncodedPublicKey(context, content.getSender()); if (!groupRecord.getAdmins().contains(Address.fromSerialized(hexEncodedPublicKey))) { Log.d("Loki - Group Message", "Received a group update message from a non-admin user for " + id +". Ignoring."); return null; } - // We should only process update message if we were in the group + // We should only process update messages if we're in the group Address ourAddress = Address.fromSerialized(ourHexEncodedPublicKey); if (!groupRecord.getMembers().contains(ourAddress) && !group.getMembers().or(Collections.emptyList()).contains(ourHexEncodedPublicKey)) { - Log.d("Loki - Group Message", "Received a group update message from a group we are not members in: " + id + " . Ignoring."); + Log.d("Loki - Group Message", "Received a group update message from a group we are not a member of: " + id + "; ignoring."); database.setActive(id, false); return null; } @@ -181,7 +181,7 @@ 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 + // This will allow us later to iterate over them to check if they left or were added for UI purposes for (Address addedMember : addedMembers) { builder.addNewMembers(addedMember.serialize()); } diff --git a/src/org/thoughtcrime/securesms/jobs/PushDecryptJob.java b/src/org/thoughtcrime/securesms/jobs/PushDecryptJob.java index c421e3ba8b..96d76d818c 100644 --- a/src/org/thoughtcrime/securesms/jobs/PushDecryptJob.java +++ b/src/org/thoughtcrime/securesms/jobs/PushDecryptJob.java @@ -1898,7 +1898,7 @@ public class PushDecryptJob extends BaseJob implements InjectableType { boolean isClosedGroup = conversation.getAddress().isSignalGroup(); boolean isGroupMember = true; - // Only allow messages from members of a group + // Only allow messages from group members if (isClosedGroup) { String senderHexEncodedPublicKey = content.getSender(); @@ -1911,9 +1911,9 @@ public class PushDecryptJob extends BaseJob implements InjectableType { e.printStackTrace(); } - Recipient senderMaster = Recipient.from(context, Address.fromSerialized(senderHexEncodedPublicKey), false); + Recipient senderMasterAddress = Recipient.from(context, Address.fromSerialized(senderHexEncodedPublicKey), false); - isGroupMember = groupId.isPresent() && groupDatabase.getGroupMembers(groupId.get(), true).contains(senderMaster); + isGroupMember = groupId.isPresent() && groupDatabase.getGroupMembers(groupId.get(), true).contains(senderMasterAddress); } return (isContentMessage && !isGroupActive) || (sender.isBlocked() && !isLeaveMessage) || (isContentMessage && !isGroupMember);