- private File getContactAvatarFile(String number) {
- return new File(pathConfig.getAvatarsPath(), "contact-" + number);
- }
-
- private File retrieveContactAvatarAttachment(
- SignalServiceAttachment attachment, String number
- ) throws IOException, InvalidMessageException, MissingConfigurationException {
- IOUtils.createPrivateDirectories(pathConfig.getAvatarsPath());
- if (attachment.isPointer()) {
- SignalServiceAttachmentPointer pointer = attachment.asPointer();
- return retrieveAttachment(pointer, getContactAvatarFile(number), false);
- } else {
- SignalServiceAttachmentStream stream = attachment.asStream();
- return AttachmentUtils.retrieveAttachment(stream, getContactAvatarFile(number));
- }
- }
-
- private File getGroupAvatarFile(GroupId groupId) {
- return new File(pathConfig.getAvatarsPath(), "group-" + groupId.toBase64().replace("/", "_"));
+ private void retrieveContactAvatarAttachment(
+ SignalServiceAttachment attachment, SignalServiceAddress address
+ ) throws IOException {
+ avatarStore.storeContactAvatar(address, outputStream -> retrieveAttachment(attachment, outputStream));