mirror of
https://github.com/aljazceru/signal-cli.git
synced 2026-01-06 07:34:31 +01:00
Upload attachment before sending to fix sending attachments to multiple recipients
Fixes #259
This commit is contained in:
@@ -647,7 +647,20 @@ public class Manager implements Signal {
|
||||
throws IOException, EncapsulatedExceptions, AttachmentInvalidException {
|
||||
final SignalServiceDataMessage.Builder messageBuilder = SignalServiceDataMessage.newBuilder().withBody(messageText);
|
||||
if (attachments != null) {
|
||||
messageBuilder.withAttachments(Utils.getSignalServiceAttachments(attachments));
|
||||
List<SignalServiceAttachment> attachmentStreams = Utils.getSignalServiceAttachments(attachments);
|
||||
|
||||
// Upload attachments here, so we only upload once even for multiple recipients
|
||||
SignalServiceMessageSender messageSender = getMessageSender();
|
||||
List<SignalServiceAttachment> attachmentPointers = new ArrayList<>(attachmentStreams.size());
|
||||
for (SignalServiceAttachment attachment : attachmentStreams) {
|
||||
if (attachment.isStream()) {
|
||||
attachmentPointers.add(messageSender.uploadAttachment(attachment.asStream()));
|
||||
} else if (attachment.isPointer()) {
|
||||
attachmentPointers.add(attachment.asPointer());
|
||||
}
|
||||
}
|
||||
|
||||
messageBuilder.withAttachments(attachmentPointers);
|
||||
}
|
||||
messageBuilder.withProfileKey(account.getProfileKey());
|
||||
sendMessageLegacy(messageBuilder, recipients);
|
||||
|
||||
Reference in New Issue
Block a user