mirror of
https://github.com/AsamK/signal-cli
synced 2025-09-02 20:40:38 +00:00
Minor changes and corrections
This commit is contained in:
parent
20f9f2b26d
commit
98aedcb3f3
4 changed files with 33 additions and 9 deletions
|
@ -688,7 +688,8 @@ public class Manager implements Signal {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void setContactBlocked(String number, boolean blocked) {
|
||||
public void setContactBlocked(String number, boolean blocked) throws InvalidNumberException {
|
||||
number = Utils.canonicalizeNumber(number, username);
|
||||
ContactInfo contact = account.getContactStore().getContact(number);
|
||||
if (contact == null) {
|
||||
contact = new ContactInfo();
|
||||
|
@ -1207,7 +1208,14 @@ public class Manager implements Signal {
|
|||
}
|
||||
|
||||
private boolean isMessageBlocked(SignalServiceEnvelope envelope, SignalServiceContent content) {
|
||||
SignalServiceAddress source = envelope.getSourceAddress();
|
||||
SignalServiceAddress source;
|
||||
if (!envelope.isUnidentifiedSender() && envelope.hasSource()) {
|
||||
source = envelope.getSourceAddress();
|
||||
} else if (content != null) {
|
||||
source = content.getSender();
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
ContactInfo sourceContact = getContact(source.getNumber().get());
|
||||
if (sourceContact != null && sourceContact.blocked) {
|
||||
return true;
|
||||
|
@ -1313,8 +1321,13 @@ public class Manager implements Signal {
|
|||
if (syncMessage.getBlockedList().isPresent()) {
|
||||
final BlockedListMessage blockedListMessage = syncMessage.getBlockedList().get();
|
||||
for (SignalServiceAddress address : blockedListMessage.getAddresses()) {
|
||||
if (address.getNumber().isPresent())
|
||||
setContactBlocked(address.getNumber().get(), true);
|
||||
if (address.getNumber().isPresent()) {
|
||||
try {
|
||||
setContactBlocked(address.getNumber().get(), true);
|
||||
} catch (InvalidNumberException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
for (byte[] groupId : blockedListMessage.getGroupIds()) {
|
||||
try {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue