+ private void downloadProfileAvatar(
+ SignalServiceAddress address, String avatarPath, ProfileKey profileKey
+ ) {
+ try {
+ avatarStore.storeProfileAvatar(address,
+ outputStream -> retrieveProfileAvatar(avatarPath, profileKey, outputStream));
+ } catch (Throwable e) {
+ logger.warn("Failed to download profile avatar, ignoring: {}", e.getMessage());
+ }
+ }
+
+ public File getAttachmentFile(SignalServiceAttachmentRemoteId attachmentId) {
+ return attachmentStore.getAttachmentFile(attachmentId);
+ }
+
+ private void downloadAttachment(final SignalServiceAttachment attachment) {
+ if (!attachment.isPointer()) {
+ logger.warn("Invalid state, can't store an attachment stream.");
+ }
+
+ SignalServiceAttachmentPointer pointer = attachment.asPointer();
+ if (pointer.getPreview().isPresent()) {
+ final byte[] preview = pointer.getPreview().get();
+ try {
+ attachmentStore.storeAttachmentPreview(pointer.getRemoteId(),
+ outputStream -> outputStream.write(preview, 0, preview.length));
+ } catch (IOException e) {
+ logger.warn("Failed to download attachment preview, ignoring: {}", e.getMessage());
+ }
+ }
+
+ try {
+ attachmentStore.storeAttachment(pointer.getRemoteId(),
+ outputStream -> retrieveAttachmentPointer(pointer, outputStream));
+ } catch (IOException e) {
+ logger.warn("Failed to download attachment ({}), ignoring: {}", pointer.getRemoteId(), e.getMessage());
+ }
+ }
+
+ private void retrieveGroupV2Avatar(
+ GroupSecretParams groupSecretParams, String cdnKey, OutputStream outputStream