mirror of
https://github.com/AsamK/signal-cli.git
synced 2026-11-29 08:55:48 +00:00
Support receiving admin delete messages
This commit is contained in:
1 parent
54ff59737e
commit
6d22ceef24
7 files changed
+73
-10
No files matched your search
@@ -122,7 +122,8 @@ public record MessageEnvelope(
|
||||
List<Preview> previews,
|
||||
List<TextStyle> textStyles,
|
||||
Optional<PinMessage> pinMessage,
|
||||
Optional<UnpinMessage> unpinMessage
|
||||
Optional<UnpinMessage> unpinMessage,
|
||||
Optional<AdminDelete> adminDelete
|
||||
) {
|
||||
|
||||
static Data from(
|
||||
@@ -173,8 +174,8 @@ public record MessageEnvelope(
|
||||
.map(a -> a.stream().filter(r -> r.style != null).map(TextStyle::from).toList())
|
||||
.orElse(List.of()),
|
||||
dataMessage.getPinnedMessage().map(p -> PinMessage.from(p, recipientResolver, addressResolver)),
|
||||
dataMessage.getUnpinnedMessage()
|
||||
.map(p -> UnpinMessage.from(p, recipientResolver, addressResolver)));
|
||||
dataMessage.getUnpinnedMessage().map(p -> UnpinMessage.from(p, recipientResolver, addressResolver)),
|
||||
dataMessage.getAdminDelete().map(p -> AdminDelete.from(p, recipientResolver, addressResolver)));
|
||||
}
|
||||
|
||||
public record GroupContext(GroupId groupId, boolean isGroupUpdate, int revision) {
|
||||
@@ -602,6 +603,18 @@ public record MessageEnvelope(
|
||||
}
|
||||
}
|
||||
|
||||
public record AdminDelete(RecipientAddress targetAuthor, long targetSentTimestamp) {
|
||||
|
||||
static AdminDelete from(
|
||||
SignalServiceDataMessage.AdminDelete adminDelete,
|
||||
RecipientResolver recipientResolver,
|
||||
RecipientAddressResolver addressResolver
|
||||
) {
|
||||
return new AdminDelete(addressResolver.resolveRecipientAddress(recipientResolver.resolveRecipient(
|
||||
adminDelete.getTargetAuthor())).toApiRecipientAddress(), adminDelete.getTargetSentTimestamp());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public record Edit(long targetSentTimestamp, Data dataMessage) {
|
||||
|
||||
@@ -709,15 +709,21 @@ public final class IncomingMessageHandler {
|
||||
}
|
||||
}
|
||||
|
||||
var groupId = GroupUtils.getGroupId(groupContext);
|
||||
var group = context.getGroupHelper().getGroup(groupId);
|
||||
final var message = content.getDataMessage().orElse(null);
|
||||
|
||||
final var recipientId = account.getRecipientResolver().resolveRecipient(source);
|
||||
|
||||
final var groupId = GroupUtils.getGroupId(groupContext);
|
||||
final var group = context.getGroupHelper().getGroup(groupId);
|
||||
|
||||
if (message != null && message.getAdminDelete().isPresent() && (group == null || !group.isAdmin(recipientId))) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (group == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
final var message = content.getDataMessage().orElse(null);
|
||||
|
||||
final var recipientId = account.getRecipientResolver().resolveRecipient(source);
|
||||
if (!group.isMember(recipientId) && !(
|
||||
group.isPendingMember(recipientId) && message != null && message.isGroupV2Update()
|
||||
)) {
|
||||
|
||||
Reference in new issue
Block a user