Keep caption when forwarding media with a body to a story.

This commit is contained in:
Alex Hart 2022-04-19 14:15:14 -03:00
parent f038e81ff3
commit 442dde5c40
2 changed files with 13 additions and 1 deletions

View file

@ -9,6 +9,7 @@ import com.annimon.stream.Stream;
import org.signal.core.util.logging.Log;
import org.thoughtcrime.securesms.attachments.Attachment;
import org.thoughtcrime.securesms.attachments.DatabaseAttachment;
import org.thoughtcrime.securesms.database.GroupReceiptDatabase;
import org.thoughtcrime.securesms.database.MessageDatabase;
import org.thoughtcrime.securesms.database.NoSuchMessageException;
@ -99,6 +100,11 @@ public final class PushDistributionListSendJob extends PushSendJob {
throw new AssertionError("Only story messages are currently supported! MessageId: " + messageId);
}
if (!message.getStoryType().isTextStory()) {
DatabaseAttachment storyAttachment = (DatabaseAttachment) message.getAttachments().get(0);
SignalDatabase.attachments().updateAttachmentCaption(storyAttachment.getAttachmentId(), message.getBody());
}
Set<String> attachmentUploadIds = enqueueCompressingAndUploadAttachmentsChains(jobManager, message);
jobManager.add(new PushDistributionListSendJob(messageId, destination, !attachmentUploadIds.isEmpty(), filterRecipientIds), attachmentUploadIds, attachmentUploadIds.isEmpty() ? null : destination.toQueueKey());

View file

@ -41,6 +41,7 @@ import org.thoughtcrime.securesms.sms.OutgoingEncryptedMessage;
import org.thoughtcrime.securesms.sms.OutgoingTextMessage;
import org.thoughtcrime.securesms.stories.Stories;
import org.thoughtcrime.securesms.util.Base64;
import org.thoughtcrime.securesms.util.MediaUtil;
import org.thoughtcrime.securesms.util.MessageUtil;
import org.thoughtcrime.securesms.util.Util;
@ -220,7 +221,12 @@ public final class MultiShareSender {
} else if (canSendAsTextStory) {
outgoingMessages.add(generateTextStory(recipient, multiShareArgs, sentTimestamp, storyType));
} else {
for (final Slide slide : slideDeck.getSlides()) {
List<Slide> storySupportedSlides = slideDeck.getSlides()
.stream()
.filter(it -> MediaUtil.isStorySupportedType(it.getContentType()))
.collect(Collectors.toList());
for (final Slide slide : storySupportedSlides) {
SlideDeck singletonDeck = new SlideDeck();
singletonDeck.addSlide(slide);