kopia lustrzana https://github.com/ryukoposting/Signal-Android
Dedupe network and identity failures.
rodzic
e01381379c
commit
a385cb0b68
|
@ -17,7 +17,7 @@ import net.sqlcipher.database.SQLiteStatement;
|
|||
import org.signal.core.util.logging.Log;
|
||||
import org.thoughtcrime.securesms.database.documents.Document;
|
||||
import org.thoughtcrime.securesms.database.documents.IdentityKeyMismatch;
|
||||
import org.thoughtcrime.securesms.database.documents.IdentityKeyMismatchList;
|
||||
import org.thoughtcrime.securesms.database.documents.IdentityKeyMismatchSet;
|
||||
import org.thoughtcrime.securesms.database.documents.NetworkFailure;
|
||||
import org.thoughtcrime.securesms.database.helpers.SQLCipherOpenHelper;
|
||||
import org.thoughtcrime.securesms.database.model.MessageId;
|
||||
|
@ -138,7 +138,7 @@ public abstract class MessageDatabase extends Database implements MmsSmsColumns
|
|||
public abstract @NonNull List<MarkedMessageInfo> setIncomingMessagesViewed(@NonNull List<Long> messageIds);
|
||||
|
||||
public abstract void addFailures(long messageId, List<NetworkFailure> failure);
|
||||
public abstract void removeFailure(long messageId, NetworkFailure failure);
|
||||
public abstract void setNetworkFailures(long messageId, Set<NetworkFailure> failures);
|
||||
|
||||
public abstract @NonNull Pair<Long, Long> insertReceivedCall(@NonNull RecipientId address, boolean isVideoOffer);
|
||||
public abstract @NonNull Pair<Long, Long> insertOutgoingCall(@NonNull RecipientId address, boolean isVideoOffer);
|
||||
|
@ -395,7 +395,7 @@ public abstract class MessageDatabase extends Database implements MmsSmsColumns
|
|||
try {
|
||||
addToDocument(messageId, MISMATCHED_IDENTITIES,
|
||||
new IdentityKeyMismatch(recipientId, identityKey),
|
||||
IdentityKeyMismatchList.class);
|
||||
IdentityKeyMismatchSet.class);
|
||||
} catch (IOException e) {
|
||||
Log.w(TAG, e);
|
||||
}
|
||||
|
@ -405,7 +405,15 @@ public abstract class MessageDatabase extends Database implements MmsSmsColumns
|
|||
try {
|
||||
removeFromDocument(messageId, MISMATCHED_IDENTITIES,
|
||||
new IdentityKeyMismatch(recipientId, identityKey),
|
||||
IdentityKeyMismatchList.class);
|
||||
IdentityKeyMismatchSet.class);
|
||||
} catch (IOException e) {
|
||||
Log.w(TAG, e);
|
||||
}
|
||||
}
|
||||
|
||||
public void setMismatchedIdentities(long messageId, @NonNull Set<IdentityKeyMismatch> mismatches) {
|
||||
try {
|
||||
setDocument(databaseHelper.getSignalWritableDatabase(), messageId, MISMATCHED_IDENTITIES, new IdentityKeyMismatchSet(mismatches));
|
||||
} catch (IOException e) {
|
||||
Log.w(TAG, e);
|
||||
}
|
||||
|
@ -458,7 +466,7 @@ public abstract class MessageDatabase extends Database implements MmsSmsColumns
|
|||
|
||||
try {
|
||||
D document = getDocument(database, messageId, column, clazz);
|
||||
Iterator<I> iterator = document.getList().iterator();
|
||||
Iterator<I> iterator = document.getItems().iterator();
|
||||
|
||||
while (iterator.hasNext()) {
|
||||
I item = iterator.next();
|
||||
|
@ -490,7 +498,7 @@ public abstract class MessageDatabase extends Database implements MmsSmsColumns
|
|||
|
||||
try {
|
||||
T document = getDocument(database, messageId, column, clazz);
|
||||
document.getList().addAll(objects);
|
||||
document.getItems().addAll(objects);
|
||||
setDocument(database, messageId, column, document);
|
||||
|
||||
database.setTransactionSuccessful();
|
||||
|
@ -499,7 +507,7 @@ public abstract class MessageDatabase extends Database implements MmsSmsColumns
|
|||
}
|
||||
}
|
||||
|
||||
private void setDocument(SQLiteDatabase database, long messageId, String column, Document document) throws IOException {
|
||||
protected void setDocument(SQLiteDatabase database, long messageId, String column, Document document) throws IOException {
|
||||
ContentValues contentValues = new ContentValues();
|
||||
|
||||
if (document == null || document.size() == 0) {
|
||||
|
|
|
@ -41,9 +41,9 @@ import org.thoughtcrime.securesms.attachments.DatabaseAttachment;
|
|||
import org.thoughtcrime.securesms.attachments.MmsNotificationAttachment;
|
||||
import org.thoughtcrime.securesms.contactshare.Contact;
|
||||
import org.thoughtcrime.securesms.database.documents.IdentityKeyMismatch;
|
||||
import org.thoughtcrime.securesms.database.documents.IdentityKeyMismatchList;
|
||||
import org.thoughtcrime.securesms.database.documents.IdentityKeyMismatchSet;
|
||||
import org.thoughtcrime.securesms.database.documents.NetworkFailure;
|
||||
import org.thoughtcrime.securesms.database.documents.NetworkFailureList;
|
||||
import org.thoughtcrime.securesms.database.documents.NetworkFailureSet;
|
||||
import org.thoughtcrime.securesms.database.helpers.SQLCipherOpenHelper;
|
||||
import org.thoughtcrime.securesms.database.model.MediaMmsMessageRecord;
|
||||
import org.thoughtcrime.securesms.database.model.Mention;
|
||||
|
@ -56,7 +56,6 @@ import org.thoughtcrime.securesms.database.model.SmsMessageRecord;
|
|||
import org.thoughtcrime.securesms.database.model.databaseprotos.BodyRangeList;
|
||||
import org.thoughtcrime.securesms.dependencies.ApplicationDependencies;
|
||||
import org.thoughtcrime.securesms.groups.GroupMigrationMembershipChange;
|
||||
import org.thoughtcrime.securesms.jobs.ThreadUpdateJob;
|
||||
import org.thoughtcrime.securesms.jobs.TrimThreadJob;
|
||||
import org.thoughtcrime.securesms.linkpreview.LinkPreview;
|
||||
import org.thoughtcrime.securesms.mms.IncomingMediaMessage;
|
||||
|
@ -603,16 +602,16 @@ public class MmsDatabase extends MessageDatabase {
|
|||
@Override
|
||||
public void addFailures(long messageId, List<NetworkFailure> failure) {
|
||||
try {
|
||||
addToDocument(messageId, NETWORK_FAILURE, failure, NetworkFailureList.class);
|
||||
addToDocument(messageId, NETWORK_FAILURE, failure, NetworkFailureSet.class);
|
||||
} catch (IOException e) {
|
||||
Log.w(TAG, e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeFailure(long messageId, NetworkFailure failure) {
|
||||
public void setNetworkFailures(long messageId, Set<NetworkFailure> failures) {
|
||||
try {
|
||||
removeFromDocument(messageId, NETWORK_FAILURE, failure, NetworkFailureList.class);
|
||||
setDocument(databaseHelper.getSignalWritableDatabase(), messageId, NETWORK_FAILURE, new NetworkFailureSet(failures));
|
||||
} catch (IOException e) {
|
||||
Log.w(TAG, e);
|
||||
}
|
||||
|
@ -1175,10 +1174,10 @@ public class MmsDatabase extends MessageDatabase {
|
|||
.sorted(new DatabaseAttachment.DisplayOrderComparator())
|
||||
.map(a -> (Attachment)a).toList();
|
||||
|
||||
Recipient recipient = Recipient.resolved(RecipientId.from(recipientId));
|
||||
List<NetworkFailure> networkFailures = new LinkedList<>();
|
||||
List<IdentityKeyMismatch> mismatches = new LinkedList<>();
|
||||
QuoteModel quote = null;
|
||||
Recipient recipient = Recipient.resolved(RecipientId.from(recipientId));
|
||||
Set<NetworkFailure> networkFailures = new HashSet<>();
|
||||
Set<IdentityKeyMismatch> mismatches = new HashSet<>();
|
||||
QuoteModel quote = null;
|
||||
|
||||
if (quoteId > 0 && quoteAuthor > 0 && (!TextUtils.isEmpty(quoteText) || !quoteAttachments.isEmpty())) {
|
||||
quote = new QuoteModel(quoteId, RecipientId.from(quoteAuthor), quoteText, quoteMissing, quoteAttachments, quoteMentions);
|
||||
|
@ -1186,7 +1185,7 @@ public class MmsDatabase extends MessageDatabase {
|
|||
|
||||
if (!TextUtils.isEmpty(mismatchDocument)) {
|
||||
try {
|
||||
mismatches = JsonUtils.fromJson(mismatchDocument, IdentityKeyMismatchList.class).getList();
|
||||
mismatches = JsonUtils.fromJson(mismatchDocument, IdentityKeyMismatchSet.class).getItems();
|
||||
} catch (IOException e) {
|
||||
Log.w(TAG, e);
|
||||
}
|
||||
|
@ -1194,7 +1193,7 @@ public class MmsDatabase extends MessageDatabase {
|
|||
|
||||
if (!TextUtils.isEmpty(networkDocument)) {
|
||||
try {
|
||||
networkFailures = JsonUtils.fromJson(networkDocument, NetworkFailureList.class).getList();
|
||||
networkFailures = JsonUtils.fromJson(networkDocument, NetworkFailureSet.class).getItems();
|
||||
} catch (IOException e) {
|
||||
Log.w(TAG, e);
|
||||
}
|
||||
|
@ -1975,8 +1974,8 @@ public class MmsDatabase extends MessageDatabase {
|
|||
slideDeck,
|
||||
slideDeck.getSlides().size(),
|
||||
message.isSecure() ? MmsSmsColumns.Types.getOutgoingEncryptedMessageType() : MmsSmsColumns.Types.getOutgoingSmsMessageType(),
|
||||
new LinkedList<>(),
|
||||
new LinkedList<>(),
|
||||
Collections.emptySet(),
|
||||
Collections.emptySet(),
|
||||
message.getSubscriptionId(),
|
||||
message.getExpiresIn(),
|
||||
System.currentTimeMillis(),
|
||||
|
@ -2110,16 +2109,16 @@ public class MmsDatabase extends MessageDatabase {
|
|||
}
|
||||
}
|
||||
|
||||
Recipient recipient = Recipient.live(RecipientId.from(recipientId)).get();
|
||||
List<IdentityKeyMismatch> mismatches = getMismatchedIdentities(mismatchDocument);
|
||||
List<NetworkFailure> networkFailures = getFailures(networkDocument);
|
||||
List<DatabaseAttachment> attachments = DatabaseFactory.getAttachmentDatabase(context).getAttachments(cursor);
|
||||
List<Contact> contacts = getSharedContacts(cursor, attachments);
|
||||
Set<Attachment> contactAttachments = Stream.of(contacts).map(Contact::getAvatarAttachment).withoutNulls().collect(Collectors.toSet());
|
||||
List<LinkPreview> previews = getLinkPreviews(cursor, attachments);
|
||||
Set<Attachment> previewAttachments = Stream.of(previews).filter(lp -> lp.getThumbnail().isPresent()).map(lp -> lp.getThumbnail().get()).collect(Collectors.toSet());
|
||||
SlideDeck slideDeck = buildSlideDeck(context, Stream.of(attachments).filterNot(contactAttachments::contains).filterNot(previewAttachments::contains).toList());
|
||||
Quote quote = getQuote(cursor);
|
||||
Recipient recipient = Recipient.live(RecipientId.from(recipientId)).get();
|
||||
Set<IdentityKeyMismatch> mismatches = getMismatchedIdentities(mismatchDocument);
|
||||
Set<NetworkFailure> networkFailures = getFailures(networkDocument);
|
||||
List<DatabaseAttachment> attachments = DatabaseFactory.getAttachmentDatabase(context).getAttachments(cursor);
|
||||
List<Contact> contacts = getSharedContacts(cursor, attachments);
|
||||
Set<Attachment> contactAttachments = Stream.of(contacts).map(Contact::getAvatarAttachment).withoutNulls().collect(Collectors.toSet());
|
||||
List<LinkPreview> previews = getLinkPreviews(cursor, attachments);
|
||||
Set<Attachment> previewAttachments = Stream.of(previews).filter(lp -> lp.getThumbnail().isPresent()).map(lp -> lp.getThumbnail().get()).collect(Collectors.toSet());
|
||||
SlideDeck slideDeck = buildSlideDeck(context, Stream.of(attachments).filterNot(contactAttachments::contains).filterNot(previewAttachments::contains).toList());
|
||||
Quote quote = getQuote(cursor);
|
||||
|
||||
return new MediaMmsMessageRecord(id, recipient, recipient,
|
||||
addressDeviceId, dateSent, dateReceived, dateServer, deliveryReceiptCount,
|
||||
|
@ -2129,28 +2128,28 @@ public class MmsDatabase extends MessageDatabase {
|
|||
remoteDelete, mentionsSelf, notifiedTimestamp, viewedReceiptCount, receiptTimestamp);
|
||||
}
|
||||
|
||||
private List<IdentityKeyMismatch> getMismatchedIdentities(String document) {
|
||||
private Set<IdentityKeyMismatch> getMismatchedIdentities(String document) {
|
||||
if (!TextUtils.isEmpty(document)) {
|
||||
try {
|
||||
return JsonUtils.fromJson(document, IdentityKeyMismatchList.class).getList();
|
||||
return JsonUtils.fromJson(document, IdentityKeyMismatchSet.class).getItems();
|
||||
} catch (IOException e) {
|
||||
Log.w(TAG, e);
|
||||
}
|
||||
}
|
||||
|
||||
return new LinkedList<>();
|
||||
return Collections.emptySet();
|
||||
}
|
||||
|
||||
private List<NetworkFailure> getFailures(String document) {
|
||||
private Set<NetworkFailure> getFailures(String document) {
|
||||
if (!TextUtils.isEmpty(document)) {
|
||||
try {
|
||||
return JsonUtils.fromJson(document, NetworkFailureList.class).getList();
|
||||
return JsonUtils.fromJson(document, NetworkFailureSet.class).getItems();
|
||||
} catch (IOException ioe) {
|
||||
Log.w(TAG, ioe);
|
||||
}
|
||||
}
|
||||
|
||||
return new LinkedList<>();
|
||||
return Collections.emptySet();
|
||||
}
|
||||
|
||||
public static SlideDeck buildSlideDeck(@NonNull Context context, @NonNull List<DatabaseAttachment> attachments) {
|
||||
|
|
|
@ -33,7 +33,7 @@ import net.sqlcipher.database.SQLiteStatement;
|
|||
|
||||
import org.signal.core.util.logging.Log;
|
||||
import org.thoughtcrime.securesms.database.documents.IdentityKeyMismatch;
|
||||
import org.thoughtcrime.securesms.database.documents.IdentityKeyMismatchList;
|
||||
import org.thoughtcrime.securesms.database.documents.IdentityKeyMismatchSet;
|
||||
import org.thoughtcrime.securesms.database.documents.NetworkFailure;
|
||||
import org.thoughtcrime.securesms.database.helpers.SQLCipherOpenHelper;
|
||||
import org.thoughtcrime.securesms.database.model.GroupCallUpdateDetailsUtil;
|
||||
|
@ -45,7 +45,6 @@ import org.thoughtcrime.securesms.database.model.databaseprotos.GroupCallUpdateD
|
|||
import org.thoughtcrime.securesms.database.model.databaseprotos.ProfileChangeDetails;
|
||||
import org.thoughtcrime.securesms.dependencies.ApplicationDependencies;
|
||||
import org.thoughtcrime.securesms.groups.GroupMigrationMembershipChange;
|
||||
import org.thoughtcrime.securesms.jobs.ThreadUpdateJob;
|
||||
import org.thoughtcrime.securesms.jobs.TrimThreadJob;
|
||||
import org.thoughtcrime.securesms.mms.IncomingMediaMessage;
|
||||
import org.thoughtcrime.securesms.mms.MmsException;
|
||||
|
@ -1548,7 +1547,7 @@ public class SmsDatabase extends MessageDatabase {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void removeFailure(long messageId, NetworkFailure failure) {
|
||||
public void setNetworkFailures(long messageId, Set<NetworkFailure> failures) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
|
@ -1642,7 +1641,7 @@ public class SmsDatabase extends MessageDatabase {
|
|||
message.isSecureMessage() ? MmsSmsColumns.Types.getOutgoingEncryptedMessageType() : MmsSmsColumns.Types.getOutgoingSmsMessageType(),
|
||||
threadId,
|
||||
0,
|
||||
new LinkedList<>(),
|
||||
new HashSet<>(),
|
||||
message.getSubscriptionId(),
|
||||
message.getExpiresIn(),
|
||||
System.currentTimeMillis(),
|
||||
|
@ -1704,8 +1703,8 @@ public class SmsDatabase extends MessageDatabase {
|
|||
readReceiptCount = 0;
|
||||
}
|
||||
|
||||
List<IdentityKeyMismatch> mismatches = getMismatches(mismatchDocument);
|
||||
Recipient recipient = Recipient.live(RecipientId.from(recipientId)).get();
|
||||
Set<IdentityKeyMismatch> mismatches = getMismatches(mismatchDocument);
|
||||
Recipient recipient = Recipient.live(RecipientId.from(recipientId)).get();
|
||||
|
||||
return new SmsMessageRecord(messageId, body, recipient,
|
||||
recipient,
|
||||
|
@ -1717,16 +1716,16 @@ public class SmsDatabase extends MessageDatabase {
|
|||
notifiedTimestamp, receiptTimestamp);
|
||||
}
|
||||
|
||||
private List<IdentityKeyMismatch> getMismatches(String document) {
|
||||
private Set<IdentityKeyMismatch> getMismatches(String document) {
|
||||
try {
|
||||
if (!TextUtils.isEmpty(document)) {
|
||||
return JsonUtils.fromJson(document, IdentityKeyMismatchList.class).getList();
|
||||
return JsonUtils.fromJson(document, IdentityKeyMismatchSet.class).getItems();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
Log.w(TAG, e);
|
||||
}
|
||||
|
||||
return new LinkedList<>();
|
||||
return Collections.emptySet();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
package org.thoughtcrime.securesms.database.documents;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public interface Document<T> {
|
||||
|
||||
public int size();
|
||||
public List<T> getList();
|
||||
|
||||
int size();
|
||||
Set<T> getItems();
|
||||
}
|
||||
|
|
|
@ -3,19 +3,21 @@ package org.thoughtcrime.securesms.database.documents;
|
|||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public class IdentityKeyMismatchList implements Document<IdentityKeyMismatch> {
|
||||
public class IdentityKeyMismatchSet implements Document<IdentityKeyMismatch> {
|
||||
|
||||
@JsonProperty(value = "m")
|
||||
private List<IdentityKeyMismatch> mismatches;
|
||||
private Set<IdentityKeyMismatch> mismatches;
|
||||
|
||||
public IdentityKeyMismatchList() {
|
||||
this.mismatches = new LinkedList<>();
|
||||
public IdentityKeyMismatchSet() {
|
||||
this.mismatches = new HashSet<>();
|
||||
}
|
||||
|
||||
public IdentityKeyMismatchList(List<IdentityKeyMismatch> mismatches) {
|
||||
public IdentityKeyMismatchSet(Set<IdentityKeyMismatch> mismatches) {
|
||||
this.mismatches = mismatches;
|
||||
}
|
||||
|
||||
|
@ -27,7 +29,7 @@ public class IdentityKeyMismatchList implements Document<IdentityKeyMismatch> {
|
|||
|
||||
@Override
|
||||
@JsonIgnore
|
||||
public List<IdentityKeyMismatch> getList() {
|
||||
public Set<IdentityKeyMismatch> getItems() {
|
||||
return mismatches;
|
||||
}
|
||||
}
|
|
@ -3,19 +3,21 @@ package org.thoughtcrime.securesms.database.documents;
|
|||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public class NetworkFailureList implements Document<NetworkFailure> {
|
||||
public class NetworkFailureSet implements Document<NetworkFailure> {
|
||||
|
||||
@JsonProperty(value = "l")
|
||||
private List<NetworkFailure> failures;
|
||||
private Set<NetworkFailure> failures;
|
||||
|
||||
public NetworkFailureList() {
|
||||
this.failures = new LinkedList<>();
|
||||
public NetworkFailureSet() {
|
||||
this.failures = new HashSet<>();
|
||||
}
|
||||
|
||||
public NetworkFailureList(List<NetworkFailure> failures) {
|
||||
public NetworkFailureSet(Set<NetworkFailure> failures) {
|
||||
this.failures = failures;
|
||||
}
|
||||
|
||||
|
@ -27,7 +29,7 @@ public class NetworkFailureList implements Document<NetworkFailure> {
|
|||
|
||||
@Override
|
||||
@JsonIgnore
|
||||
public List<NetworkFailure> getList() {
|
||||
public Set<NetworkFailure> getItems() {
|
||||
return failures;
|
||||
}
|
||||
}
|
|
@ -40,8 +40,8 @@ public class InMemoryMessageRecord extends MessageRecord {
|
|||
0,
|
||||
0,
|
||||
type,
|
||||
Collections.emptyList(),
|
||||
Collections.emptyList(),
|
||||
Collections.emptySet(),
|
||||
Collections.emptySet(),
|
||||
-1,
|
||||
0,
|
||||
System.currentTimeMillis(),
|
||||
|
|
|
@ -72,8 +72,8 @@ public class MediaMmsMessageRecord extends MmsMessageRecord {
|
|||
@NonNull SlideDeck slideDeck,
|
||||
int partCount,
|
||||
long mailbox,
|
||||
List<IdentityKeyMismatch> mismatches,
|
||||
List<NetworkFailure> failures,
|
||||
Set<IdentityKeyMismatch> mismatches,
|
||||
Set<NetworkFailure> failures,
|
||||
int subscriptionId,
|
||||
long expiresIn,
|
||||
long expireStarted,
|
||||
|
|
|
@ -61,6 +61,7 @@ import java.util.ArrayList;
|
|||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
|
@ -75,27 +76,27 @@ public abstract class MessageRecord extends DisplayRecord {
|
|||
|
||||
private static final String TAG = Log.tag(MessageRecord.class);
|
||||
|
||||
private final Recipient individualRecipient;
|
||||
private final int recipientDeviceId;
|
||||
private final long id;
|
||||
private final List<IdentityKeyMismatch> mismatches;
|
||||
private final List<NetworkFailure> networkFailures;
|
||||
private final int subscriptionId;
|
||||
private final long expiresIn;
|
||||
private final long expireStarted;
|
||||
private final boolean unidentified;
|
||||
private final List<ReactionRecord> reactions;
|
||||
private final long serverTimestamp;
|
||||
private final boolean remoteDelete;
|
||||
private final long notifiedTimestamp;
|
||||
private final long receiptTimestamp;
|
||||
private final Recipient individualRecipient;
|
||||
private final int recipientDeviceId;
|
||||
private final long id;
|
||||
private final Set<IdentityKeyMismatch> mismatches;
|
||||
private final Set<NetworkFailure> networkFailures;
|
||||
private final int subscriptionId;
|
||||
private final long expiresIn;
|
||||
private final long expireStarted;
|
||||
private final boolean unidentified;
|
||||
private final List<ReactionRecord> reactions;
|
||||
private final long serverTimestamp;
|
||||
private final boolean remoteDelete;
|
||||
private final long notifiedTimestamp;
|
||||
private final long receiptTimestamp;
|
||||
|
||||
MessageRecord(long id, String body, Recipient conversationRecipient,
|
||||
Recipient individualRecipient, int recipientDeviceId,
|
||||
long dateSent, long dateReceived, long dateServer, long threadId,
|
||||
int deliveryStatus, int deliveryReceiptCount, long type,
|
||||
List<IdentityKeyMismatch> mismatches,
|
||||
List<NetworkFailure> networkFailures,
|
||||
Set<IdentityKeyMismatch> mismatches,
|
||||
Set<NetworkFailure> networkFailures,
|
||||
int subscriptionId, long expiresIn, long expireStarted,
|
||||
int readReceiptCount, boolean unidentified,
|
||||
@NonNull List<ReactionRecord> reactions, boolean remoteDelete, long notifiedTimestamp,
|
||||
|
@ -512,11 +513,11 @@ public abstract class MessageRecord extends DisplayRecord {
|
|||
return type;
|
||||
}
|
||||
|
||||
public List<IdentityKeyMismatch> getIdentityKeyMismatches() {
|
||||
public Set<IdentityKeyMismatch> getIdentityKeyMismatches() {
|
||||
return mismatches;
|
||||
}
|
||||
|
||||
public List<NetworkFailure> getNetworkFailures() {
|
||||
public Set<NetworkFailure> getNetworkFailures() {
|
||||
return networkFailures;
|
||||
}
|
||||
|
||||
|
|
|
@ -14,6 +14,7 @@ import org.thoughtcrime.securesms.recipients.Recipient;
|
|||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public abstract class MmsMessageRecord extends MessageRecord {
|
||||
|
||||
|
@ -27,8 +28,8 @@ public abstract class MmsMessageRecord extends MessageRecord {
|
|||
MmsMessageRecord(long id, String body, Recipient conversationRecipient,
|
||||
Recipient individualRecipient, int recipientDeviceId, long dateSent,
|
||||
long dateReceived, long dateServer, long threadId, int deliveryStatus, int deliveryReceiptCount,
|
||||
long type, List<IdentityKeyMismatch> mismatches,
|
||||
List<NetworkFailure> networkFailures, int subscriptionId, long expiresIn,
|
||||
long type, Set<IdentityKeyMismatch> mismatches,
|
||||
Set<NetworkFailure> networkFailures, int subscriptionId, long expiresIn,
|
||||
long expireStarted, boolean viewOnce,
|
||||
@NonNull SlideDeck slideDeck, int readReceiptCount,
|
||||
@Nullable Quote quote, @NonNull List<Contact> contacts,
|
||||
|
|
|
@ -28,6 +28,7 @@ import org.thoughtcrime.securesms.mms.SlideDeck;
|
|||
import org.thoughtcrime.securesms.recipients.Recipient;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedList;
|
||||
|
||||
/**
|
||||
|
@ -56,7 +57,7 @@ public class NotificationMmsMessageRecord extends MmsMessageRecord {
|
|||
{
|
||||
super(id, "", conversationRecipient, individualRecipient, recipientDeviceId,
|
||||
dateSent, dateReceived, -1, threadId, Status.STATUS_NONE, deliveryReceiptCount, mailbox,
|
||||
new LinkedList<>(), new LinkedList<>(), subscriptionId,
|
||||
new HashSet<>(), new HashSet<>(), subscriptionId,
|
||||
0, 0, false, slideDeck, readReceiptCount, null, Collections.emptyList(), Collections.emptyList(), false,
|
||||
Collections.emptyList(), false, 0, viewedReceiptCount, receiptTimestamp);
|
||||
|
||||
|
|
|
@ -29,8 +29,10 @@ import org.thoughtcrime.securesms.database.SmsDatabase;
|
|||
import org.thoughtcrime.securesms.database.documents.IdentityKeyMismatch;
|
||||
import org.thoughtcrime.securesms.recipients.Recipient;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* The message record model which represents standard SMS messages.
|
||||
|
@ -48,7 +50,7 @@ public class SmsMessageRecord extends MessageRecord {
|
|||
long dateSent, long dateReceived, long dateServer,
|
||||
int deliveryReceiptCount,
|
||||
long type, long threadId,
|
||||
int status, List<IdentityKeyMismatch> mismatches,
|
||||
int status, Set<IdentityKeyMismatch> mismatches,
|
||||
int subscriptionId, long expiresIn, long expireStarted,
|
||||
int readReceiptCount, boolean unidentified,
|
||||
@NonNull List<ReactionRecord> reactions, boolean remoteDelete,
|
||||
|
@ -56,7 +58,7 @@ public class SmsMessageRecord extends MessageRecord {
|
|||
{
|
||||
super(id, body, recipient, individualRecipient, recipientDeviceId,
|
||||
dateSent, dateReceived, dateServer, threadId, status, deliveryReceiptCount, type,
|
||||
mismatches, new LinkedList<>(), subscriptionId,
|
||||
mismatches, new HashSet<>(), subscriptionId,
|
||||
expiresIn, expireStarted, readReceiptCount, unidentified, reactions, remoteDelete, notifiedTimestamp, 0, receiptTimestamp);
|
||||
}
|
||||
|
||||
|
|
|
@ -150,11 +150,11 @@ public final class PushGroupSendJob extends PushSendJob {
|
|||
{
|
||||
SignalLocalMetrics.GroupMessageSend.onJobStarted(messageId);
|
||||
|
||||
MessageDatabase database = DatabaseFactory.getMmsDatabase(context);
|
||||
OutgoingMediaMessage message = database.getOutgoingMessage(messageId);
|
||||
long threadId = database.getMessageRecord(messageId).getThreadId();
|
||||
List<NetworkFailure> existingNetworkFailures = message.getNetworkFailures();
|
||||
List<IdentityKeyMismatch> existingIdentityMismatches = message.getIdentityKeyMismatches();
|
||||
MessageDatabase database = DatabaseFactory.getMmsDatabase(context);
|
||||
OutgoingMediaMessage message = database.getOutgoingMessage(messageId);
|
||||
long threadId = database.getMessageRecord(messageId).getThreadId();
|
||||
Set<NetworkFailure> existingNetworkFailures = message.getNetworkFailures();
|
||||
Set<IdentityKeyMismatch> existingIdentityMismatches = message.getIdentityKeyMismatches();
|
||||
|
||||
ApplicationDependencies.getJobManager().cancelAllInQueue(TypingSendJob.getQueue(threadId));
|
||||
|
||||
|
@ -183,8 +183,8 @@ public final class PushGroupSendJob extends PushSendJob {
|
|||
List<Recipient> target;
|
||||
|
||||
if (filterRecipient != null) target = Collections.singletonList(Recipient.resolved(filterRecipient));
|
||||
else if (!existingNetworkFailures.isEmpty()) target = Stream.of(existingNetworkFailures).map(nf -> Recipient.resolved(nf.getRecipientId(context))).toList();
|
||||
else target = getGroupMessageRecipients(groupRecipient.requireGroupId(), messageId);
|
||||
else if (!existingNetworkFailures.isEmpty()) target = Stream.of(existingNetworkFailures).map(nf -> nf.getRecipientId(context)).distinct().map(Recipient::resolved).toList();
|
||||
else target = Stream.of(getGroupMessageRecipients(groupRecipient.requireGroupId(), messageId)).distinctBy(Recipient::getId).toList();
|
||||
|
||||
RecipientAccessList accessList = new RecipientAccessList(target);
|
||||
|
||||
|
@ -206,23 +206,11 @@ public final class PushGroupSendJob extends PushSendJob {
|
|||
recipientDatabase.markUnregistered(unregistered.getId());
|
||||
}
|
||||
|
||||
for (NetworkFailure resolvedFailure : resolvedNetworkFailures) {
|
||||
database.removeFailure(messageId, resolvedFailure);
|
||||
existingNetworkFailures.remove(resolvedFailure);
|
||||
}
|
||||
existingNetworkFailures.removeAll(resolvedNetworkFailures);
|
||||
database.setNetworkFailures(messageId, existingNetworkFailures);
|
||||
|
||||
for (IdentityKeyMismatch resolvedIdentity : resolvedIdentityFailures) {
|
||||
database.removeMismatchedIdentity(messageId, resolvedIdentity.getRecipientId(context), resolvedIdentity.getIdentityKey());
|
||||
existingIdentityMismatches.remove(resolvedIdentity);
|
||||
}
|
||||
|
||||
if (!networkFailures.isEmpty()) {
|
||||
database.addFailures(messageId, networkFailures);
|
||||
}
|
||||
|
||||
for (IdentityKeyMismatch mismatch : identityMismatches) {
|
||||
database.addMismatchedIdentity(messageId, mismatch.getRecipientId(context), mismatch.getIdentityKey());
|
||||
}
|
||||
existingIdentityMismatches.removeAll(resolvedIdentityFailures);
|
||||
database.setMismatchedIdentities(messageId, existingIdentityMismatches);
|
||||
|
||||
DatabaseFactory.getGroupReceiptDatabase(context).setUnidentified(successUnidentifiedStatus, messageId);
|
||||
|
||||
|
|
|
@ -201,7 +201,7 @@ class MediaSelectionRepository(context: Context) {
|
|||
isViewOnce,
|
||||
ThreadDatabase.DistributionTypes.DEFAULT,
|
||||
null, emptyList(), emptyList(),
|
||||
mentions, emptyList(), emptyList()
|
||||
mentions, mutableSetOf(), mutableSetOf()
|
||||
)
|
||||
messages.add(OutgoingSecureMediaMessage(message))
|
||||
|
||||
|
|
|
@ -1359,7 +1359,7 @@ public final class MessageContentProcessor {
|
|||
sharedContacts.or(Collections.emptyList()),
|
||||
previews.or(Collections.emptyList()),
|
||||
mentions.or(Collections.emptyList()),
|
||||
Collections.emptyList(), Collections.emptyList());
|
||||
Collections.emptySet(), Collections.emptySet());
|
||||
|
||||
mediaMessage = new OutgoingSecureMediaMessage(mediaMessage);
|
||||
|
||||
|
|
|
@ -13,8 +13,10 @@ import org.thoughtcrime.securesms.database.model.Mention;
|
|||
import org.thoughtcrime.securesms.linkpreview.LinkPreview;
|
||||
import org.thoughtcrime.securesms.recipients.Recipient;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public class OutgoingMediaMessage {
|
||||
|
||||
|
@ -28,11 +30,11 @@ public class OutgoingMediaMessage {
|
|||
private final boolean viewOnce;
|
||||
private final QuoteModel outgoingQuote;
|
||||
|
||||
private final List<NetworkFailure> networkFailures = new LinkedList<>();
|
||||
private final List<IdentityKeyMismatch> identityKeyMismatches = new LinkedList<>();
|
||||
private final List<Contact> contacts = new LinkedList<>();
|
||||
private final List<LinkPreview> linkPreviews = new LinkedList<>();
|
||||
private final List<Mention> mentions = new LinkedList<>();
|
||||
private final Set<NetworkFailure> networkFailures = new HashSet<>();
|
||||
private final Set<IdentityKeyMismatch> identityKeyMismatches = new HashSet<>();
|
||||
private final List<Contact> contacts = new LinkedList<>();
|
||||
private final List<LinkPreview> linkPreviews = new LinkedList<>();
|
||||
private final List<Mention> mentions = new LinkedList<>();
|
||||
|
||||
public OutgoingMediaMessage(Recipient recipient, String message,
|
||||
List<Attachment> attachments, long sentTimeMillis,
|
||||
|
@ -42,8 +44,8 @@ public class OutgoingMediaMessage {
|
|||
@NonNull List<Contact> contacts,
|
||||
@NonNull List<LinkPreview> linkPreviews,
|
||||
@NonNull List<Mention> mentions,
|
||||
@NonNull List<NetworkFailure> networkFailures,
|
||||
@NonNull List<IdentityKeyMismatch> identityKeyMismatches)
|
||||
@NonNull Set<NetworkFailure> networkFailures,
|
||||
@NonNull Set<IdentityKeyMismatch> identityKeyMismatches)
|
||||
{
|
||||
this.recipient = recipient;
|
||||
this.body = message;
|
||||
|
@ -75,7 +77,7 @@ public class OutgoingMediaMessage {
|
|||
slideDeck.asAttachments(),
|
||||
sentTimeMillis, subscriptionId,
|
||||
expiresIn, viewOnce, distributionType, outgoingQuote,
|
||||
contacts, linkPreviews, mentions, new LinkedList<>(), new LinkedList<>());
|
||||
contacts, linkPreviews, mentions, new HashSet<>(), new HashSet<>());
|
||||
}
|
||||
|
||||
public OutgoingMediaMessage(OutgoingMediaMessage that) {
|
||||
|
@ -175,11 +177,11 @@ public class OutgoingMediaMessage {
|
|||
return mentions;
|
||||
}
|
||||
|
||||
public @NonNull List<NetworkFailure> getNetworkFailures() {
|
||||
public @NonNull Set<NetworkFailure> getNetworkFailures() {
|
||||
return networkFailures;
|
||||
}
|
||||
|
||||
public @NonNull List<IdentityKeyMismatch> getIdentityKeyMismatches() {
|
||||
public @NonNull Set<IdentityKeyMismatch> getIdentityKeyMismatches() {
|
||||
return identityKeyMismatches;
|
||||
}
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ public class OutgoingSecureMediaMessage extends OutgoingMediaMessage {
|
|||
@NonNull List<LinkPreview> previews,
|
||||
@NonNull List<Mention> mentions)
|
||||
{
|
||||
super(recipient, body, attachments, sentTimeMillis, -1, expiresIn, viewOnce, distributionType, quote, contacts, previews, mentions, Collections.emptyList(), Collections.emptyList());
|
||||
super(recipient, body, attachments, sentTimeMillis, -1, expiresIn, viewOnce, distributionType, quote, contacts, previews, mentions, Collections.emptySet(), Collections.emptySet());
|
||||
}
|
||||
|
||||
public OutgoingSecureMediaMessage(OutgoingMediaMessage base) {
|
||||
|
|
|
@ -90,8 +90,8 @@ public class RemoteReplyReceiver extends BroadcastReceiver {
|
|||
Collections.emptyList(),
|
||||
Collections.emptyList(),
|
||||
Collections.emptyList(),
|
||||
Collections.emptyList(),
|
||||
Collections.emptyList());
|
||||
Collections.emptySet(),
|
||||
Collections.emptySet());
|
||||
threadId = MessageSender.send(context, reply, -1, false, null, null);
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -38,8 +38,8 @@ object TestMms {
|
|||
emptyList(),
|
||||
emptyList(),
|
||||
emptyList(),
|
||||
emptyList(),
|
||||
emptyList()
|
||||
emptySet(),
|
||||
emptySet()
|
||||
)
|
||||
|
||||
return insertMmsMessage(
|
||||
|
|
Ładowanie…
Reference in New Issue