+ if (group instanceof GroupInfoV2) {
+ Pair<DecryptedGroup, GroupChange> groupGroupChangePair = null;
+ if (members != null) {
+ final Set<SignalServiceAddress> newMembers = new HashSet<>(members);
+ newMembers.removeAll(group.getMembers());
+ if (newMembers.size() > 0) {
+ groupGroupChangePair = groupHelper.updateGroupV2((GroupInfoV2) group, newMembers);
+ }
+ }
+ if (groupGroupChangePair == null || name != null || avatarFile != null) {
+ if (groupGroupChangePair != null) {
+ ((GroupInfoV2) group).setGroup(groupGroupChangePair.first());
+ messageBuilder = getGroupUpdateMessageBuilder((GroupInfoV2) group,
+ groupGroupChangePair.second().toByteArray());
+ sendMessage(messageBuilder, group.getMembersWithout(account.getSelfAddress()));
+ }
+
+ groupGroupChangePair = groupHelper.updateGroupV2((GroupInfoV2) group, name, avatarFile);
+ }
+
+ ((GroupInfoV2) group).setGroup(groupGroupChangePair.first());
+ messageBuilder = getGroupUpdateMessageBuilder((GroupInfoV2) group,
+ groupGroupChangePair.second().toByteArray());
+ g = group;
+ } else {
+ GroupInfoV1 gv1 = (GroupInfoV1) group;
+ updateGroupV1(gv1, name, members, avatarFile);
+ messageBuilder = getGroupUpdateMessageBuilder(gv1);
+ g = gv1;