mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-20 00:29:11 +01:00
Fix story send issues due to insertion of story sends to database.
This commit is contained in:
committed by
Greyson Parrelli
parent
38b6362b25
commit
5d16d1cd23
@@ -47,6 +47,7 @@ import org.thoughtcrime.securesms.util.Util;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
@@ -78,6 +79,7 @@ public final class MultiShareSender {
|
||||
boolean isMmsEnabled = Util.isMmsCapable(context);
|
||||
String message = multiShareArgs.getDraftText();
|
||||
SlideDeck slideDeck;
|
||||
List<OutgoingMediaMessage> storiesBatch = new LinkedList<>();
|
||||
|
||||
try {
|
||||
slideDeck = buildSlideDeck(context, multiShareArgs);
|
||||
@@ -118,7 +120,7 @@ public final class MultiShareSender {
|
||||
if ((recipient.isMmsGroup() || recipient.getEmail().isPresent()) && !isMmsEnabled) {
|
||||
results.add(new MultiShareSendResult(recipientSearchKey, MultiShareSendResult.Type.MMS_NOT_ENABLED));
|
||||
} else if (hasMmsMedia && transport.isSms() || hasPushMedia && !transport.isSms() || canSendAsTextStory) {
|
||||
sendMediaMessage(context, multiShareArgs, recipient, slideDeck, transport, threadId, forceSms, expiresIn, multiShareArgs.isViewOnce(), subscriptionId, mentions, recipientSearchKey.isStory(), sentTimestamp, canSendAsTextStory);
|
||||
sendMediaMessageOrCollectStoryToBatch(context, multiShareArgs, recipient, slideDeck, transport, threadId, forceSms, expiresIn, multiShareArgs.isViewOnce(), subscriptionId, mentions, recipientSearchKey.isStory(), sentTimestamp, canSendAsTextStory, storiesBatch);
|
||||
results.add(new MultiShareSendResult(recipientSearchKey, MultiShareSendResult.Type.SUCCESS));
|
||||
} else if (recipientSearchKey.isStory()) {
|
||||
results.add(new MultiShareSendResult(recipientSearchKey, MultiShareSendResult.Type.INVALID_SHARE_TO_STORY));
|
||||
@@ -132,6 +134,15 @@ public final class MultiShareSender {
|
||||
ThreadUtil.sleep(5);
|
||||
}
|
||||
|
||||
if (!storiesBatch.isEmpty()) {
|
||||
MessageSender.sendStories(context,
|
||||
storiesBatch.stream()
|
||||
.map(OutgoingSecureMediaMessage::new)
|
||||
.collect(Collectors.toList()),
|
||||
null,
|
||||
null);
|
||||
}
|
||||
|
||||
return new MultiShareSendResultCollection(results);
|
||||
}
|
||||
|
||||
@@ -160,20 +171,21 @@ public final class MultiShareSender {
|
||||
}
|
||||
}
|
||||
|
||||
private static void sendMediaMessage(@NonNull Context context,
|
||||
@NonNull MultiShareArgs multiShareArgs,
|
||||
@NonNull Recipient recipient,
|
||||
@NonNull SlideDeck slideDeck,
|
||||
@NonNull TransportOption transportOption,
|
||||
long threadId,
|
||||
boolean forceSms,
|
||||
long expiresIn,
|
||||
boolean isViewOnce,
|
||||
int subscriptionId,
|
||||
@NonNull List<Mention> validatedMentions,
|
||||
boolean isStory,
|
||||
long sentTimestamp,
|
||||
boolean canSendAsTextStory)
|
||||
private static void sendMediaMessageOrCollectStoryToBatch(@NonNull Context context,
|
||||
@NonNull MultiShareArgs multiShareArgs,
|
||||
@NonNull Recipient recipient,
|
||||
@NonNull SlideDeck slideDeck,
|
||||
@NonNull TransportOption transportOption,
|
||||
long threadId,
|
||||
boolean forceSms,
|
||||
long expiresIn,
|
||||
boolean isViewOnce,
|
||||
int subscriptionId,
|
||||
@NonNull List<Mention> validatedMentions,
|
||||
boolean isStory,
|
||||
long sentTimestamp,
|
||||
boolean canSendAsTextStory,
|
||||
@NonNull List<OutgoingMediaMessage> storiesToBatchSend)
|
||||
{
|
||||
String body = multiShareArgs.getDraftText();
|
||||
if (transportOption.isType(TransportOption.Type.TEXTSECURE) && !forceSms && body != null) {
|
||||
@@ -270,8 +282,9 @@ public final class MultiShareSender {
|
||||
outgoingMessages.add(outgoingMediaMessage);
|
||||
}
|
||||
|
||||
if (shouldSendAsPush(recipient, forceSms))
|
||||
{
|
||||
if (isStory) {
|
||||
storiesToBatchSend.addAll(outgoingMessages);
|
||||
} else if (shouldSendAsPush(recipient, forceSms)) {
|
||||
for (final OutgoingMediaMessage outgoingMessage : outgoingMessages) {
|
||||
MessageSender.send(context, new OutgoingSecureMediaMessage(outgoingMessage), threadId, false, null, null);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user