41
41
import org .thoughtcrime .securesms .attachments .MmsNotificationAttachment ;
42
42
import org .thoughtcrime .securesms .contactshare .Contact ;
43
43
import org .thoughtcrime .securesms .database .documents .IdentityKeyMismatch ;
44
- import org .thoughtcrime .securesms .database .documents .IdentityKeyMismatchList ;
44
+ import org .thoughtcrime .securesms .database .documents .IdentityKeyMismatchSet ;
45
45
import org .thoughtcrime .securesms .database .documents .NetworkFailure ;
46
- import org .thoughtcrime .securesms .database .documents .NetworkFailureList ;
46
+ import org .thoughtcrime .securesms .database .documents .NetworkFailureSet ;
47
47
import org .thoughtcrime .securesms .database .helpers .SQLCipherOpenHelper ;
48
48
import org .thoughtcrime .securesms .database .model .MediaMmsMessageRecord ;
49
49
import org .thoughtcrime .securesms .database .model .Mention ;
56
56
import org .thoughtcrime .securesms .database .model .databaseprotos .BodyRangeList ;
57
57
import org .thoughtcrime .securesms .dependencies .ApplicationDependencies ;
58
58
import org .thoughtcrime .securesms .groups .GroupMigrationMembershipChange ;
59
- import org .thoughtcrime .securesms .jobs .ThreadUpdateJob ;
60
59
import org .thoughtcrime .securesms .jobs .TrimThreadJob ;
61
60
import org .thoughtcrime .securesms .linkpreview .LinkPreview ;
62
61
import org .thoughtcrime .securesms .mms .IncomingMediaMessage ;
@@ -603,16 +602,16 @@ public boolean hasMeaningfulMessage(long threadId) {
603
602
@ Override
604
603
public void addFailures (long messageId , List <NetworkFailure > failure ) {
605
604
try {
606
- addToDocument (messageId , NETWORK_FAILURE , failure , NetworkFailureList .class );
605
+ addToDocument (messageId , NETWORK_FAILURE , failure , NetworkFailureSet .class );
607
606
} catch (IOException e ) {
608
607
Log .w (TAG , e );
609
608
}
610
609
}
611
610
612
611
@ Override
613
- public void removeFailure (long messageId , NetworkFailure failure ) {
612
+ public void setNetworkFailures (long messageId , Set < NetworkFailure > failures ) {
614
613
try {
615
- removeFromDocument ( messageId , NETWORK_FAILURE , failure , NetworkFailureList . class );
614
+ setDocument ( databaseHelper . getSignalWritableDatabase (), messageId , NETWORK_FAILURE , new NetworkFailureSet ( failures ) );
616
615
} catch (IOException e ) {
617
616
Log .w (TAG , e );
618
617
}
@@ -1175,26 +1174,26 @@ public OutgoingMediaMessage getOutgoingMessage(long messageId)
1175
1174
.sorted (new DatabaseAttachment .DisplayOrderComparator ())
1176
1175
.map (a -> (Attachment )a ).toList ();
1177
1176
1178
- Recipient recipient = Recipient .resolved (RecipientId .from (recipientId ));
1179
- List <NetworkFailure > networkFailures = new LinkedList <>();
1180
- List <IdentityKeyMismatch > mismatches = new LinkedList <>();
1181
- QuoteModel quote = null ;
1177
+ Recipient recipient = Recipient .resolved (RecipientId .from (recipientId ));
1178
+ Set <NetworkFailure > networkFailures = new HashSet <>();
1179
+ Set <IdentityKeyMismatch > mismatches = new HashSet <>();
1180
+ QuoteModel quote = null ;
1182
1181
1183
1182
if (quoteId > 0 && quoteAuthor > 0 && (!TextUtils .isEmpty (quoteText ) || !quoteAttachments .isEmpty ())) {
1184
1183
quote = new QuoteModel (quoteId , RecipientId .from (quoteAuthor ), quoteText , quoteMissing , quoteAttachments , quoteMentions );
1185
1184
}
1186
1185
1187
1186
if (!TextUtils .isEmpty (mismatchDocument )) {
1188
1187
try {
1189
- mismatches = JsonUtils .fromJson (mismatchDocument , IdentityKeyMismatchList .class ).getList ();
1188
+ mismatches = JsonUtils .fromJson (mismatchDocument , IdentityKeyMismatchSet .class ).getItems ();
1190
1189
} catch (IOException e ) {
1191
1190
Log .w (TAG , e );
1192
1191
}
1193
1192
}
1194
1193
1195
1194
if (!TextUtils .isEmpty (networkDocument )) {
1196
1195
try {
1197
- networkFailures = JsonUtils .fromJson (networkDocument , NetworkFailureList .class ).getList ();
1196
+ networkFailures = JsonUtils .fromJson (networkDocument , NetworkFailureSet .class ).getItems ();
1198
1197
} catch (IOException e ) {
1199
1198
Log .w (TAG , e );
1200
1199
}
@@ -1975,8 +1974,8 @@ public MessageRecord getCurrent() {
1975
1974
slideDeck ,
1976
1975
slideDeck .getSlides ().size (),
1977
1976
message .isSecure () ? MmsSmsColumns .Types .getOutgoingEncryptedMessageType () : MmsSmsColumns .Types .getOutgoingSmsMessageType (),
1978
- new LinkedList <> (),
1979
- new LinkedList <> (),
1977
+ Collections . emptySet (),
1978
+ Collections . emptySet (),
1980
1979
message .getSubscriptionId (),
1981
1980
message .getExpiresIn (),
1982
1981
System .currentTimeMillis (),
@@ -2110,16 +2109,16 @@ private MediaMmsMessageRecord getMediaMmsMessageRecord(Cursor cursor) {
2110
2109
}
2111
2110
}
2112
2111
2113
- Recipient recipient = Recipient .live (RecipientId .from (recipientId )).get ();
2114
- List <IdentityKeyMismatch > mismatches = getMismatchedIdentities (mismatchDocument );
2115
- List <NetworkFailure > networkFailures = getFailures (networkDocument );
2116
- List <DatabaseAttachment > attachments = DatabaseFactory .getAttachmentDatabase (context ).getAttachments (cursor );
2117
- List <Contact > contacts = getSharedContacts (cursor , attachments );
2118
- Set <Attachment > contactAttachments = Stream .of (contacts ).map (Contact ::getAvatarAttachment ).withoutNulls ().collect (Collectors .toSet ());
2119
- List <LinkPreview > previews = getLinkPreviews (cursor , attachments );
2120
- Set <Attachment > previewAttachments = Stream .of (previews ).filter (lp -> lp .getThumbnail ().isPresent ()).map (lp -> lp .getThumbnail ().get ()).collect (Collectors .toSet ());
2121
- SlideDeck slideDeck = buildSlideDeck (context , Stream .of (attachments ).filterNot (contactAttachments ::contains ).filterNot (previewAttachments ::contains ).toList ());
2122
- Quote quote = getQuote (cursor );
2112
+ Recipient recipient = Recipient .live (RecipientId .from (recipientId )).get ();
2113
+ Set <IdentityKeyMismatch > mismatches = getMismatchedIdentities (mismatchDocument );
2114
+ Set <NetworkFailure > networkFailures = getFailures (networkDocument );
2115
+ List <DatabaseAttachment > attachments = DatabaseFactory .getAttachmentDatabase (context ).getAttachments (cursor );
2116
+ List <Contact > contacts = getSharedContacts (cursor , attachments );
2117
+ Set <Attachment > contactAttachments = Stream .of (contacts ).map (Contact ::getAvatarAttachment ).withoutNulls ().collect (Collectors .toSet ());
2118
+ List <LinkPreview > previews = getLinkPreviews (cursor , attachments );
2119
+ Set <Attachment > previewAttachments = Stream .of (previews ).filter (lp -> lp .getThumbnail ().isPresent ()).map (lp -> lp .getThumbnail ().get ()).collect (Collectors .toSet ());
2120
+ SlideDeck slideDeck = buildSlideDeck (context , Stream .of (attachments ).filterNot (contactAttachments ::contains ).filterNot (previewAttachments ::contains ).toList ());
2121
+ Quote quote = getQuote (cursor );
2123
2122
2124
2123
return new MediaMmsMessageRecord (id , recipient , recipient ,
2125
2124
addressDeviceId , dateSent , dateReceived , dateServer , deliveryReceiptCount ,
@@ -2129,28 +2128,28 @@ private MediaMmsMessageRecord getMediaMmsMessageRecord(Cursor cursor) {
2129
2128
remoteDelete , mentionsSelf , notifiedTimestamp , viewedReceiptCount , receiptTimestamp );
2130
2129
}
2131
2130
2132
- private List <IdentityKeyMismatch > getMismatchedIdentities (String document ) {
2131
+ private Set <IdentityKeyMismatch > getMismatchedIdentities (String document ) {
2133
2132
if (!TextUtils .isEmpty (document )) {
2134
2133
try {
2135
- return JsonUtils .fromJson (document , IdentityKeyMismatchList .class ).getList ();
2134
+ return JsonUtils .fromJson (document , IdentityKeyMismatchSet .class ).getItems ();
2136
2135
} catch (IOException e ) {
2137
2136
Log .w (TAG , e );
2138
2137
}
2139
2138
}
2140
2139
2141
- return new LinkedList <> ();
2140
+ return Collections . emptySet ();
2142
2141
}
2143
2142
2144
- private List <NetworkFailure > getFailures (String document ) {
2143
+ private Set <NetworkFailure > getFailures (String document ) {
2145
2144
if (!TextUtils .isEmpty (document )) {
2146
2145
try {
2147
- return JsonUtils .fromJson (document , NetworkFailureList .class ).getList ();
2146
+ return JsonUtils .fromJson (document , NetworkFailureSet .class ).getItems ();
2148
2147
} catch (IOException ioe ) {
2149
2148
Log .w (TAG , ioe );
2150
2149
}
2151
2150
}
2152
2151
2153
- return new LinkedList <> ();
2152
+ return Collections . emptySet ();
2154
2153
}
2155
2154
2156
2155
public static SlideDeck buildSlideDeck (@ NonNull Context context , @ NonNull List <DatabaseAttachment > attachments ) {
0 commit comments