mirror of
https://github.com/oxen-io/session-android.git
synced 2025-07-19 01:28:30 +00:00
Drop messages with mentions not sent to V2 Groups.
This commit is contained in:
parent
100359e38d
commit
e70a8ae6a0
@ -345,10 +345,11 @@ public final class SignalServiceContent {
|
|||||||
boolean endSession = ((content.getFlags() & SignalServiceProtos.DataMessage.Flags.END_SESSION_VALUE ) != 0);
|
boolean endSession = ((content.getFlags() & SignalServiceProtos.DataMessage.Flags.END_SESSION_VALUE ) != 0);
|
||||||
boolean expirationUpdate = ((content.getFlags() & SignalServiceProtos.DataMessage.Flags.EXPIRATION_TIMER_UPDATE_VALUE) != 0);
|
boolean expirationUpdate = ((content.getFlags() & SignalServiceProtos.DataMessage.Flags.EXPIRATION_TIMER_UPDATE_VALUE) != 0);
|
||||||
boolean profileKeyUpdate = ((content.getFlags() & SignalServiceProtos.DataMessage.Flags.PROFILE_KEY_UPDATE_VALUE ) != 0);
|
boolean profileKeyUpdate = ((content.getFlags() & SignalServiceProtos.DataMessage.Flags.PROFILE_KEY_UPDATE_VALUE ) != 0);
|
||||||
SignalServiceDataMessage.Quote quote = createQuote(content);
|
boolean isGroupV2 = groupInfoV2 != null;
|
||||||
|
SignalServiceDataMessage.Quote quote = createQuote(content, isGroupV2);
|
||||||
List<SharedContact> sharedContacts = createSharedContacts(content);
|
List<SharedContact> sharedContacts = createSharedContacts(content);
|
||||||
List<SignalServiceDataMessage.Preview> previews = createPreviews(content);
|
List<SignalServiceDataMessage.Preview> previews = createPreviews(content);
|
||||||
List<SignalServiceDataMessage.Mention> mentions = createMentions(content.getBodyRangesList(), content.getBody());
|
List<SignalServiceDataMessage.Mention> mentions = createMentions(content.getBodyRangesList(), content.getBody(), isGroupV2);
|
||||||
SignalServiceDataMessage.Sticker sticker = createSticker(content);
|
SignalServiceDataMessage.Sticker sticker = createSticker(content);
|
||||||
SignalServiceDataMessage.Reaction reaction = createReaction(content);
|
SignalServiceDataMessage.Reaction reaction = createReaction(content);
|
||||||
SignalServiceDataMessage.RemoteDelete remoteDelete = createRemoteDelete(content);
|
SignalServiceDataMessage.RemoteDelete remoteDelete = createRemoteDelete(content);
|
||||||
@ -648,7 +649,7 @@ public final class SignalServiceContent {
|
|||||||
Optional.<byte[]>absent());
|
Optional.<byte[]>absent());
|
||||||
}
|
}
|
||||||
|
|
||||||
private static SignalServiceDataMessage.Quote createQuote(SignalServiceProtos.DataMessage content) throws ProtocolInvalidMessageException {
|
private static SignalServiceDataMessage.Quote createQuote(SignalServiceProtos.DataMessage content, boolean isGroupV2) throws ProtocolInvalidMessageException {
|
||||||
if (!content.hasQuote()) return null;
|
if (!content.hasQuote()) return null;
|
||||||
|
|
||||||
List<SignalServiceDataMessage.Quote.QuotedAttachment> attachments = new LinkedList<>();
|
List<SignalServiceDataMessage.Quote.QuotedAttachment> attachments = new LinkedList<>();
|
||||||
@ -666,7 +667,7 @@ public final class SignalServiceContent {
|
|||||||
address,
|
address,
|
||||||
content.getQuote().getText(),
|
content.getQuote().getText(),
|
||||||
attachments,
|
attachments,
|
||||||
createMentions(content.getQuote().getBodyRangesList(), content.getQuote().getText()));
|
createMentions(content.getQuote().getBodyRangesList(), content.getQuote().getText(), isGroupV2));
|
||||||
} else {
|
} else {
|
||||||
Log.w(TAG, "Quote was missing an author! Returning null.");
|
Log.w(TAG, "Quote was missing an author! Returning null.");
|
||||||
return null;
|
return null;
|
||||||
@ -695,7 +696,7 @@ public final class SignalServiceContent {
|
|||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static List<SignalServiceDataMessage.Mention> createMentions(List<SignalServiceProtos.DataMessage.BodyRange> bodyRanges, String body) throws ProtocolInvalidMessageException {
|
private static List<SignalServiceDataMessage.Mention> createMentions(List<SignalServiceProtos.DataMessage.BodyRange> bodyRanges, String body, boolean isGroupV2) throws ProtocolInvalidMessageException {
|
||||||
if (bodyRanges == null || bodyRanges.isEmpty() || body == null) {
|
if (bodyRanges == null || bodyRanges.isEmpty() || body == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -713,6 +714,10 @@ public final class SignalServiceContent {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (mentions.size() > 0 && !isGroupV2) {
|
||||||
|
throw new ProtocolInvalidMessageException(new InvalidMessageException("Mentions received in non-GV2 message"), null, 0);
|
||||||
|
}
|
||||||
|
|
||||||
return mentions;
|
return mentions;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user