Resolve recipients before uploading story attachment

Move recipient resolution ahead of the attachment upload so that an
empty contact list is caught early without wasting bandwidth on an
upload that would reach nobody.
This commit is contained in:
Tony Cebzanov 2026-07-09 09:35:43 -04:00
parent 4ccad0321f
commit d6b321dc19

View File

@ -841,13 +841,6 @@ public class ManagerImpl implements Manager {
throw new AttachmentInvalidException(attachment,
new IOException("Stories only support image and video attachments"));
}
final var uploadedAttachment = context.getAttachmentHelper().uploadAttachment(attachment);
final var storyMessage = SignalServiceStoryMessage.forFileAttachment(account.getProfileKey().serialize(),
null,
uploadedAttachment,
allowsReplies,
List.of());
final var timestamp = getNextMessageTimestamp();
final var recipients = account.getRecipientStore()
.getRecipients(true, Optional.of(false), Set.of(), Optional.empty());
@ -857,6 +850,18 @@ public class ManagerImpl implements Manager {
.map(r -> r.getRecipientId())
.collect(Collectors.toSet());
if (recipientIds.isEmpty()) {
throw new IOException("No eligible contacts found for story delivery");
}
final var uploadedAttachment = context.getAttachmentHelper().uploadAttachment(attachment);
final var storyMessage = SignalServiceStoryMessage.forFileAttachment(account.getProfileKey().serialize(),
null,
uploadedAttachment,
allowsReplies,
List.of());
final var timestamp = getNextMessageTimestamp();
final var sendResults = context.getSendHelper()
.sendStoryMessage(storyMessage, timestamp, recipientIds, allowsReplies);