groupMasterKey);
}
if (group == null) {
- group = groupV2Helper.getDecryptedGroup(groupSecretParams);
+ try {
+ group = groupV2Helper.getDecryptedGroup(groupSecretParams);
+ } catch (NotAGroupMemberException ignored) {
+ }
}
if (group != null) {
storeProfileKeysFromMembers(group);
private GroupInfo getGroup(GroupId groupId, boolean forceUpdate) {
final var group = account.getGroupStore().getGroup(groupId);
- if (group instanceof GroupInfoV2 && (forceUpdate || ((GroupInfoV2) group).getGroup() == null)) {
- final var groupSecretParams = GroupSecretParams.deriveFromMasterKey(((GroupInfoV2) group).getMasterKey());
- ((GroupInfoV2) group).setGroup(groupV2Helper.getDecryptedGroup(groupSecretParams), recipientResolver);
- account.getGroupStore().updateGroup(group);
+ if (group instanceof GroupInfoV2) {
+ final var groupInfoV2 = (GroupInfoV2) group;
+ if (forceUpdate || (!groupInfoV2.isPermissionDenied() && groupInfoV2.getGroup() == null)) {
+ final var groupSecretParams = GroupSecretParams.deriveFromMasterKey(groupInfoV2.getMasterKey());
+ DecryptedGroup decryptedGroup;
+ try {
+ decryptedGroup = groupV2Helper.getDecryptedGroup(groupSecretParams);
+ } catch (NotAGroupMemberException e) {
+ groupInfoV2.setPermissionDenied(true);
+ decryptedGroup = null;
+ }
+ groupInfoV2.setGroup(decryptedGroup, recipientResolver);
+ account.getGroupStore().updateGroup(group);
+ }
}
return group;
}