+ } catch (IOException | InvalidMessageException | MissingConfigurationException e) {
+ logger.warn("Failed to retrieve preview image ({}), ignoring: {}",
+ attachment.getRemoteId(),
+ e.getMessage());
+ }
+ }
+ }
+ }
+ if (message.getQuote().isPresent()) {
+ final SignalServiceDataMessage.Quote quote = message.getQuote().get();
+
+ for (SignalServiceDataMessage.Quote.QuotedAttachment quotedAttachment : quote.getAttachments()) {
+ final SignalServiceAttachment attachment = quotedAttachment.getThumbnail();
+ if (attachment != null && attachment.isPointer()) {
+ try {
+ retrieveAttachment(attachment.asPointer());
+ } catch (IOException | InvalidMessageException | MissingConfigurationException e) {
+ logger.warn("Failed to retrieve quote attachment thumbnail ({}), ignoring: {}",
+ attachment.asPointer().getRemoteId(),
+ e.getMessage());
+ }
+ }
+ }
+ }
+ if (message.getSticker().isPresent()) {
+ final SignalServiceDataMessage.Sticker messageSticker = message.getSticker().get();
+ Sticker sticker = account.getStickerStore().getSticker(messageSticker.getPackId());
+ if (sticker == null) {
+ sticker = new Sticker(messageSticker.getPackId(), messageSticker.getPackKey());
+ account.getStickerStore().updateSticker(sticker);
+ }
+ }
+ return actions;
+ }
+
+ private GroupInfoV2 getOrMigrateGroup(
+ final GroupMasterKey groupMasterKey, final int revision, final byte[] signedGroupChange
+ ) {
+ final GroupSecretParams groupSecretParams = GroupSecretParams.deriveFromMasterKey(groupMasterKey);
+
+ GroupIdV2 groupId = GroupUtils.getGroupIdV2(groupSecretParams);
+ GroupInfo groupInfo = account.getGroupStore().getGroup(groupId);
+ final GroupInfoV2 groupInfoV2;
+ if (groupInfo instanceof GroupInfoV1) {
+ // Received a v2 group message for a v1 group, we need to locally migrate the group
+ account.getGroupStore().deleteGroup(groupInfo.getGroupId());
+ groupInfoV2 = new GroupInfoV2(groupId, groupMasterKey);
+ logger.info("Locally migrated group {} to group v2, id: {}",
+ groupInfo.getGroupId().toBase64(),
+ groupInfoV2.getGroupId().toBase64());
+ } else if (groupInfo instanceof GroupInfoV2) {
+ groupInfoV2 = (GroupInfoV2) groupInfo;
+ } else {
+ groupInfoV2 = new GroupInfoV2(groupId, groupMasterKey);
+ }
+
+ if (groupInfoV2.getGroup() == null || groupInfoV2.getGroup().getRevision() < revision) {
+ DecryptedGroup group = null;
+ if (signedGroupChange != null
+ && groupInfoV2.getGroup() != null
+ && groupInfoV2.getGroup().getRevision() + 1 == revision) {
+ group = groupHelper.getUpdatedDecryptedGroup(groupInfoV2.getGroup(), signedGroupChange, groupMasterKey);
+ }
+ if (group == null) {
+ group = groupHelper.getDecryptedGroup(groupSecretParams);
+ }
+ if (group != null) {
+ storeProfileKeysFromMembers(group);
+ final String avatar = group.getAvatar();
+ if (avatar != null && !avatar.isEmpty()) {
+ try {
+ retrieveGroupAvatar(groupId, groupSecretParams, avatar);
+ } catch (IOException e) {
+ logger.warn("Failed to download group avatar, ignoring: {}", e.getMessage());