Add support for announcement groups.

This commit is contained in:
Greyson Parrelli
2021-07-23 16:22:08 -04:00
parent 1a56924a56
commit 25234496bf
74 changed files with 1109 additions and 208 deletions

View File

@@ -434,11 +434,32 @@ public final class MessageContentProcessor {
return true;
}
if (!groupDatabase.isCurrentMember(groupId, senderRecipient.getId())) {
Optional<GroupRecord> groupRecord = groupDatabase.getGroup(groupId);
if (groupRecord.isPresent() && !groupRecord.get().getMembers().contains(senderRecipient.getId())) {
log(String.valueOf(content.getTimestamp()), "Ignoring GV2 message from member not in group " + groupId);
return true;
}
if (groupRecord.isPresent() && groupRecord.get().isAnnouncementGroup() && !groupRecord.get().getAdmins().contains(senderRecipient)) {
if (content.getDataMessage().isPresent()) {
SignalServiceDataMessage data = content.getDataMessage().get();
if (data.getBody().isPresent() ||
data.getAttachments().isPresent() ||
data.getQuote().isPresent() ||
data.getPreviews().isPresent() ||
data.getMentions().isPresent() ||
data.getSticker().isPresent())
{
Log.w(TAG, "Ignoring message from " + senderRecipient.getId() + " because it has disallowed content, and they're not an admin in an announcement-only group.");
return true;
}
} else if (content.getTypingMessage().isPresent()) {
Log.w(TAG, "Ignoring typing indicator from " + senderRecipient.getId() + " because they're not an admin in an announcement-only group.");
return true;
}
}
return false;
}
@@ -2149,7 +2170,13 @@ public final class MessageContentProcessor {
if (content.getTypingMessage().get().getGroupId().isPresent()) {
GroupId groupId = GroupId.push(content.getTypingMessage().get().getGroupId().get());
Recipient groupRecipient = Recipient.externalPossiblyMigratedGroup(context, groupId);
return groupRecipient.isBlocked() || !groupRecipient.isActiveGroup();
if (groupRecipient.isBlocked() || !groupRecipient.isActiveGroup()) {
return true;
} else {
Optional<GroupRecord> groupRecord = DatabaseFactory.getGroupDatabase(context).getGroup(groupId);
return groupRecord.isPresent() && groupRecord.get().isAnnouncementGroup() && !groupRecord.get().getAdmins().contains(sender);
}
}
}