mirror of
https://github.com/oxen-io/session-android.git
synced 2025-06-09 12:58:34 +00:00
Disallow RecipientId's of zero.
This commit is contained in:
parent
7193252d77
commit
bcecc30d33
@ -623,7 +623,7 @@ public class MmsDatabase extends MessagingDatabase {
|
|||||||
String networkDocument = cursor.getString(cursor.getColumnIndexOrThrow(MmsDatabase.NETWORK_FAILURE));
|
String networkDocument = cursor.getString(cursor.getColumnIndexOrThrow(MmsDatabase.NETWORK_FAILURE));
|
||||||
|
|
||||||
long quoteId = cursor.getLong(cursor.getColumnIndexOrThrow(QUOTE_ID));
|
long quoteId = cursor.getLong(cursor.getColumnIndexOrThrow(QUOTE_ID));
|
||||||
RecipientId quoteAuthor = RecipientId.from(cursor.getLong(cursor.getColumnIndexOrThrow(QUOTE_AUTHOR)));
|
long quoteAuthor = cursor.getLong(cursor.getColumnIndexOrThrow(QUOTE_AUTHOR));
|
||||||
String quoteText = cursor.getString(cursor.getColumnIndexOrThrow(QUOTE_BODY));
|
String quoteText = cursor.getString(cursor.getColumnIndexOrThrow(QUOTE_BODY));
|
||||||
boolean quoteMissing = cursor.getInt(cursor.getColumnIndexOrThrow(QUOTE_MISSING)) == 1;
|
boolean quoteMissing = cursor.getInt(cursor.getColumnIndexOrThrow(QUOTE_MISSING)) == 1;
|
||||||
List<Attachment> quoteAttachments = Stream.of(associatedAttachments).filter(Attachment::isQuote).map(a -> (Attachment)a).toList();
|
List<Attachment> quoteAttachments = Stream.of(associatedAttachments).filter(Attachment::isQuote).map(a -> (Attachment)a).toList();
|
||||||
@ -641,8 +641,8 @@ public class MmsDatabase extends MessagingDatabase {
|
|||||||
List<IdentityKeyMismatch> mismatches = new LinkedList<>();
|
List<IdentityKeyMismatch> mismatches = new LinkedList<>();
|
||||||
QuoteModel quote = null;
|
QuoteModel quote = null;
|
||||||
|
|
||||||
if (quoteId > 0 && (!TextUtils.isEmpty(quoteText) || !quoteAttachments.isEmpty())) {
|
if (quoteId > 0 && quoteAuthor > 0 && (!TextUtils.isEmpty(quoteText) || !quoteAttachments.isEmpty())) {
|
||||||
quote = new QuoteModel(quoteId, quoteAuthor, quoteText, quoteMissing, quoteAttachments);
|
quote = new QuoteModel(quoteId, RecipientId.from(quoteAuthor), quoteText, quoteMissing, quoteAttachments);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!TextUtils.isEmpty(mismatchDocument)) {
|
if (!TextUtils.isEmpty(mismatchDocument)) {
|
||||||
@ -1538,15 +1538,15 @@ public class MmsDatabase extends MessagingDatabase {
|
|||||||
|
|
||||||
private @Nullable Quote getQuote(@NonNull Cursor cursor) {
|
private @Nullable Quote getQuote(@NonNull Cursor cursor) {
|
||||||
long quoteId = cursor.getLong(cursor.getColumnIndexOrThrow(MmsDatabase.QUOTE_ID));
|
long quoteId = cursor.getLong(cursor.getColumnIndexOrThrow(MmsDatabase.QUOTE_ID));
|
||||||
RecipientId quoteAuthor = RecipientId.from(cursor.getLong(cursor.getColumnIndexOrThrow(MmsDatabase.QUOTE_AUTHOR)));
|
long quoteAuthor = cursor.getLong(cursor.getColumnIndexOrThrow(MmsDatabase.QUOTE_AUTHOR));
|
||||||
String quoteText = cursor.getString(cursor.getColumnIndexOrThrow(MmsDatabase.QUOTE_BODY));
|
String quoteText = cursor.getString(cursor.getColumnIndexOrThrow(MmsDatabase.QUOTE_BODY));
|
||||||
boolean quoteMissing = cursor.getInt(cursor.getColumnIndexOrThrow(MmsDatabase.QUOTE_MISSING)) == 1;
|
boolean quoteMissing = cursor.getInt(cursor.getColumnIndexOrThrow(MmsDatabase.QUOTE_MISSING)) == 1;
|
||||||
List<DatabaseAttachment> attachments = DatabaseFactory.getAttachmentDatabase(context).getAttachment(cursor);
|
List<DatabaseAttachment> attachments = DatabaseFactory.getAttachmentDatabase(context).getAttachment(cursor);
|
||||||
List<? extends Attachment> quoteAttachments = Stream.of(attachments).filter(Attachment::isQuote).toList();
|
List<? extends Attachment> quoteAttachments = Stream.of(attachments).filter(Attachment::isQuote).toList();
|
||||||
SlideDeck quoteDeck = new SlideDeck(context, quoteAttachments);
|
SlideDeck quoteDeck = new SlideDeck(context, quoteAttachments);
|
||||||
|
|
||||||
if (quoteId > 0 && !quoteAuthor.isUnknown()) {
|
if (quoteId > 0 && quoteAuthor > 0) {
|
||||||
return new Quote(quoteId, quoteAuthor, quoteText, quoteMissing, quoteDeck);
|
return new Quote(quoteId, RecipientId.from(quoteAuthor), quoteText, quoteMissing, quoteDeck);
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -23,6 +23,10 @@ public class RecipientId implements Parcelable, Comparable<RecipientId> {
|
|||||||
private final long id;
|
private final long id;
|
||||||
|
|
||||||
public static RecipientId from(long id) {
|
public static RecipientId from(long id) {
|
||||||
|
if (id == 0) {
|
||||||
|
throw new AssertionError("Invalid ID!");
|
||||||
|
}
|
||||||
|
|
||||||
return new RecipientId(id);
|
return new RecipientId(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user