Check if there is an attachment available before trying to send it to a story.

fork-5.53.8
Alex Hart 2022-03-24 11:05:48 -03:00 zatwierdzone przez Greyson Parrelli
rodzic f6f4e6fde7
commit a7a4972013
2 zmienionych plików z 6 dodań i 2 usunięć

Wyświetl plik

@ -177,8 +177,10 @@ public final class PushDistributionListSendJob extends PushSendJob {
final SignalServiceStoryMessage storyMessage;
if (message.getStoryType().isTextStory()) {
storyMessage = SignalServiceStoryMessage.forTextAttachment(Recipient.self().getProfileKey(), null, StorySendUtil.deserializeBodyToStoryTextAttachment(message, this::getPreviewsFor), message.getStoryType().isStoryWithReplies());
} else {
} else if (!attachmentPointers.isEmpty()) {
storyMessage = SignalServiceStoryMessage.forFileAttachment(Recipient.self().getProfileKey(), null, attachmentPointers.get(0), message.getStoryType().isStoryWithReplies());
} else {
throw new UndeliverableMessageException("No attachment on non-text story.");
}
return GroupSendUtil.sendStoryMessage(context, message.getRecipient().requireDistributionListId(), destinations, isRecipientUpdate, new MessageId(messageId, true), message.getSentTimeMillis(), storyMessage);
} catch (ServerRejectedException e) {

Wyświetl plik

@ -253,8 +253,10 @@ public final class PushGroupSendJob extends PushSendJob {
final SignalServiceStoryMessage storyMessage;
if (message.getStoryType().isTextStory()) {
storyMessage = SignalServiceStoryMessage.forTextAttachment(Recipient.self().getProfileKey(), groupContext, StorySendUtil.deserializeBodyToStoryTextAttachment(message, this::getPreviewsFor), message.getStoryType().isStoryWithReplies());
} else {
} else if (!attachmentPointers.isEmpty()) {
storyMessage = SignalServiceStoryMessage.forFileAttachment(Recipient.self().getProfileKey(), groupContext, attachmentPointers.get(0), message.getStoryType().isStoryWithReplies());
} else {
throw new UndeliverableMessageException("No attachment on non-text story.");
}
return GroupSendUtil.sendGroupStoryMessage(context, groupId.requireV2(), destinations, isRecipientUpdate, new MessageId(messageId, true), message.getSentTimeMillis(), storyMessage);