mirror of
https://github.com/AsamK/signal-cli
synced 2025-09-02 04:20:38 +00:00
Prevent blocked messages from being printed
This commit is contained in:
parent
ff478a5b0a
commit
67e94bc856
1 changed files with 23 additions and 1 deletions
|
@ -1182,7 +1182,9 @@ public class Manager implements Signal {
|
|||
handleMessage(envelope, content, ignoreAttachments);
|
||||
}
|
||||
account.save();
|
||||
handler.handleMessage(envelope, content, exception);
|
||||
if (!isMessageBlocked(envelope, content)) {
|
||||
handler.handleMessage(envelope, content, exception);
|
||||
}
|
||||
if (!(exception instanceof ProtocolUntrustedIdentityException)) {
|
||||
File cacheFile = null;
|
||||
try {
|
||||
|
@ -1203,6 +1205,26 @@ public class Manager implements Signal {
|
|||
}
|
||||
}
|
||||
|
||||
private boolean isMessageBlocked(SignalServiceEnvelope envelope, SignalServiceContent content) {
|
||||
SignalServiceAddress source = envelope.getSourceAddress();
|
||||
ContactInfo sourceContact = getContact(source.getNumber().get());
|
||||
if (sourceContact != null && sourceContact.blocked) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (content != null && content.getDataMessage().isPresent()) {
|
||||
SignalServiceDataMessage message = content.getDataMessage().get();
|
||||
if (message.getGroupInfo().isPresent()) {
|
||||
SignalServiceGroup groupInfo = message.getGroupInfo().get();
|
||||
GroupInfo group = getGroup(groupInfo.getGroupId());
|
||||
if (groupInfo.getType() == SignalServiceGroup.Type.DELIVER && group != null && group.blocked) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void handleMessage(SignalServiceEnvelope envelope, SignalServiceContent content, boolean ignoreAttachments) {
|
||||
if (content != null) {
|
||||
SignalServiceAddress sender;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue