From ba4d1c98440616aad97ef26170da0127b12722b0 Mon Sep 17 00:00:00 2001 From: Greyson Parrelli Date: Wed, 25 Aug 2021 14:20:49 -0400 Subject: [PATCH] Add a failsafe to prevent non-admin sends in announcement groups. --- .../org/thoughtcrime/securesms/jobs/PushGroupSendJob.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app/src/main/java/org/thoughtcrime/securesms/jobs/PushGroupSendJob.java b/app/src/main/java/org/thoughtcrime/securesms/jobs/PushGroupSendJob.java index 4e095a501..0650dae3d 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/jobs/PushGroupSendJob.java +++ b/app/src/main/java/org/thoughtcrime/securesms/jobs/PushGroupSendJob.java @@ -173,6 +173,12 @@ public final class PushGroupSendJob extends PushSendJob { throw new MmsException("No GV1 messages can be sent anymore!"); } + Optional groupRecord = DatabaseFactory.getGroupDatabase(context).getGroup(groupRecipient.requireGroupId()); + + if (groupRecord.isPresent() && groupRecord.get().isAnnouncementGroup() && !groupRecord.get().isAdmin(Recipient.self())) { + throw new MmsException("Non-admins cannot send messages in announcement groups!"); + } + try { log(TAG, String.valueOf(message.getSentTimeMillis()), "Sending message: " + messageId + ", Recipient: " + message.getRecipient().getId() + ", Thread: " + threadId + ", Attachments: " + buildAttachmentString(message.getAttachments()));