+ private void fillOrUpdateGroup(final GroupInfo group, final boolean forceUpdate) {
+ if (!(group instanceof GroupInfoV2 groupInfoV2)) {
+ return;
+ }
+
+ if (!forceUpdate && (groupInfoV2.isPermissionDenied() || groupInfoV2.getGroup() != null)) {
+ return;
+ }
+
+ final var groupSecretParams = GroupSecretParams.deriveFromMasterKey(groupInfoV2.getMasterKey());
+ DecryptedGroup decryptedGroup;
+ try {
+ decryptedGroup = context.getGroupV2Helper().getDecryptedGroup(groupSecretParams);
+ } catch (NotAGroupMemberException e) {
+ groupInfoV2.setPermissionDenied(true);
+ account.getGroupStore().updateGroup(group);
+ return;
+ }
+
+ if (decryptedGroup == null) {
+ return;
+ }
+
+ try {
+ storeProfileKeysFromHistory(groupSecretParams, groupInfoV2, decryptedGroup);
+ } catch (NotAGroupMemberException ignored) {
+ }
+ storeProfileKeysFromMembers(decryptedGroup);
+ final var avatar = decryptedGroup.avatar;
+ if (!avatar.isEmpty()) {
+ downloadGroupAvatar(groupInfoV2.getGroupId(), groupSecretParams, avatar);
+ }
+ groupInfoV2.setGroup(decryptedGroup);
+ account.getGroupStore().updateGroup(group);
+ }
+