mirror of
https://github.com/AsamK/signal-cli
synced 2025-08-29 18:40:39 +00:00
Ignore group message if the sender is not in the group
This commit is contained in:
parent
f0834c7a47
commit
783c88cb6a
1 changed files with 32 additions and 3 deletions
|
@ -1800,7 +1800,11 @@ public class Manager implements Closeable {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
account.save();
|
account.save();
|
||||||
if (!isMessageBlocked(envelope, content)) {
|
if (isMessageBlocked(envelope, content)) {
|
||||||
|
logger.info("Ignoring a message from blocked user/group: {}", envelope.getTimestamp());
|
||||||
|
} else if (isNotAGroupMember(envelope, content)) {
|
||||||
|
logger.info("Ignoring a message from a non group member: {}", envelope.getTimestamp());
|
||||||
|
} else {
|
||||||
handler.handleMessage(envelope, content, exception);
|
handler.handleMessage(envelope, content, exception);
|
||||||
}
|
}
|
||||||
if (!(exception instanceof org.whispersystems.libsignal.UntrustedIdentityException)) {
|
if (!(exception instanceof org.whispersystems.libsignal.UntrustedIdentityException)) {
|
||||||
|
@ -1827,18 +1831,43 @@ public class Manager implements Closeable {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (content != null && content.getDataMessage().isPresent()) {
|
||||||
|
SignalServiceDataMessage message = content.getDataMessage().get();
|
||||||
|
if (message.getGroupContext().isPresent()) {
|
||||||
|
GroupId groupId = GroupUtils.getGroupId(message.getGroupContext().get());
|
||||||
|
GroupInfo group = getGroup(groupId);
|
||||||
|
if (group != null && group.isBlocked()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean isNotAGroupMember(
|
||||||
|
SignalServiceEnvelope envelope, SignalServiceContent content
|
||||||
|
) {
|
||||||
|
SignalServiceAddress source;
|
||||||
|
if (!envelope.isUnidentifiedSender() && envelope.hasSource()) {
|
||||||
|
source = envelope.getSourceAddress();
|
||||||
|
} else if (content != null) {
|
||||||
|
source = content.getSender();
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (content != null && content.getDataMessage().isPresent()) {
|
if (content != null && content.getDataMessage().isPresent()) {
|
||||||
SignalServiceDataMessage message = content.getDataMessage().get();
|
SignalServiceDataMessage message = content.getDataMessage().get();
|
||||||
if (message.getGroupContext().isPresent()) {
|
if (message.getGroupContext().isPresent()) {
|
||||||
if (message.getGroupContext().get().getGroupV1().isPresent()) {
|
if (message.getGroupContext().get().getGroupV1().isPresent()) {
|
||||||
SignalServiceGroup groupInfo = message.getGroupContext().get().getGroupV1().get();
|
SignalServiceGroup groupInfo = message.getGroupContext().get().getGroupV1().get();
|
||||||
if (groupInfo.getType() != SignalServiceGroup.Type.DELIVER) {
|
if (groupInfo.getType() == SignalServiceGroup.Type.QUIT) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
GroupId groupId = GroupUtils.getGroupId(message.getGroupContext().get());
|
GroupId groupId = GroupUtils.getGroupId(message.getGroupContext().get());
|
||||||
GroupInfo group = getGroup(groupId);
|
GroupInfo group = getGroup(groupId);
|
||||||
if (group != null && group.isBlocked()) {
|
if (group != null && !group.isMember(source)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue