Fix issue where forwarded link previews weren't marked uploaded.

fork-5.53.8
Greyson Parrelli 2021-01-21 14:33:32 -05:00
rodzic 93d99287eb
commit 105c8c9745
4 zmienionych plików z 22 dodań i 4 usunięć

Wyświetl plik

@ -141,7 +141,7 @@ public final class MmsSendJob extends SendJob {
final MmsSendResult result = getSendResult(sendConf, pdu);
database.markAsSent(messageId, false);
markAttachmentsUploaded(messageId, message.getAttachments());
markAttachmentsUploaded(messageId, message);
Log.i(TAG, "Sent message: " + messageId);
} catch (UndeliverableMessageException | IOException e) {

Wyświetl plik

@ -232,7 +232,7 @@ public final class PushGroupSendJob extends PushSendJob {
if (existingNetworkFailures.isEmpty() && networkFailures.isEmpty() && identityMismatches.isEmpty() && existingIdentityMismatches.isEmpty()) {
database.markAsSent(messageId, true);
markAttachmentsUploaded(messageId, message.getAttachments());
markAttachmentsUploaded(messageId, message);
if (message.getExpiresIn() > 0 && !message.isExpirationUpdate()) {
database.markExpireStarted(messageId);

Wyświetl plik

@ -129,7 +129,7 @@ public class PushMediaSendJob extends PushSendJob {
boolean unidentified = deliver(message);
database.markAsSent(messageId, true);
markAttachmentsUploaded(messageId, message.getAttachments());
markAttachmentsUploaded(messageId, message);
database.markUnidentified(messageId, unidentified);
if (recipient.isSelf()) {

Wyświetl plik

@ -2,15 +2,23 @@ package org.thoughtcrime.securesms.jobs;
import androidx.annotation.NonNull;
import com.annimon.stream.Stream;
import org.signal.core.util.logging.Log;
import org.thoughtcrime.securesms.BuildConfig;
import org.thoughtcrime.securesms.TextSecureExpiredException;
import org.thoughtcrime.securesms.attachments.Attachment;
import org.thoughtcrime.securesms.contactshare.Contact;
import org.thoughtcrime.securesms.database.AttachmentDatabase;
import org.thoughtcrime.securesms.database.DatabaseFactory;
import org.thoughtcrime.securesms.jobmanager.Job;
import org.thoughtcrime.securesms.keyvalue.SignalStore;
import org.thoughtcrime.securesms.linkpreview.LinkPreview;
import org.thoughtcrime.securesms.mms.OutgoingMediaMessage;
import org.thoughtcrime.securesms.util.Util;
import java.lang.reflect.Array;
import java.util.LinkedList;
import java.util.List;
public abstract class SendJob extends BaseJob {
@ -37,7 +45,17 @@ public abstract class SendJob extends BaseJob {
protected abstract void onSend() throws Exception;
protected void markAttachmentsUploaded(long messageId, @NonNull List<Attachment> attachments) {
protected void markAttachmentsUploaded(long messageId, @NonNull OutgoingMediaMessage message) {
List<Attachment> attachments = new LinkedList<>();
attachments.addAll(message.getAttachments());
attachments.addAll(Stream.of(message.getLinkPreviews()).map(lp -> lp.getThumbnail().orNull()).withoutNulls().toList());
attachments.addAll(Stream.of(message.getSharedContacts()).map(Contact::getAvatarAttachment).withoutNulls().toList());
if (message.getOutgoingQuote() != null) {
attachments.addAll(message.getOutgoingQuote().getAttachments());
}
AttachmentDatabase database = DatabaseFactory.getAttachmentDatabase(context);
for (Attachment attachment : attachments) {