mirror of
https://github.com/AsamK/signal-cli
synced 2025-08-29 02:20:39 +00:00
Adapt log levels
This commit is contained in:
parent
592491ab4e
commit
a738fb725b
2 changed files with 55 additions and 49 deletions
|
@ -44,16 +44,68 @@ public class UnidentifiedAccessHelper {
|
|||
this.profileProvider = profileProvider;
|
||||
}
|
||||
|
||||
public List<Optional<UnidentifiedAccessPair>> getAccessFor(List<RecipientId> recipients) {
|
||||
return recipients.stream().map(this::getAccessFor).toList();
|
||||
}
|
||||
|
||||
public Optional<UnidentifiedAccessPair> getAccessFor(RecipientId recipient) {
|
||||
return getAccessFor(recipient, false);
|
||||
}
|
||||
|
||||
public Optional<UnidentifiedAccessPair> getAccessFor(RecipientId recipientId, boolean noRefresh) {
|
||||
var recipientUnidentifiedAccessKey = getTargetUnidentifiedAccessKey(recipientId, noRefresh);
|
||||
if (recipientUnidentifiedAccessKey == null) {
|
||||
logger.trace("Unidentified access not available for {}", recipientId);
|
||||
return Optional.absent();
|
||||
}
|
||||
|
||||
var selfUnidentifiedAccessKey = getSelfUnidentifiedAccessKey(noRefresh);
|
||||
if (selfUnidentifiedAccessKey == null) {
|
||||
logger.trace("Unidentified access not available for self");
|
||||
return Optional.absent();
|
||||
}
|
||||
|
||||
var senderCertificate = getSenderCertificateFor(recipientId);
|
||||
if (senderCertificate == null) {
|
||||
logger.trace("Unidentified access not available due to missing sender certificate");
|
||||
return Optional.absent();
|
||||
}
|
||||
|
||||
try {
|
||||
return Optional.of(new UnidentifiedAccessPair(new UnidentifiedAccess(recipientUnidentifiedAccessKey,
|
||||
senderCertificate), new UnidentifiedAccess(selfUnidentifiedAccessKey, senderCertificate)));
|
||||
} catch (InvalidCertificateException e) {
|
||||
return Optional.absent();
|
||||
}
|
||||
}
|
||||
|
||||
public Optional<UnidentifiedAccessPair> getAccessForSync() {
|
||||
var selfUnidentifiedAccessKey = getSelfUnidentifiedAccessKey(false);
|
||||
var selfUnidentifiedAccessCertificate = getSenderCertificate();
|
||||
|
||||
if (selfUnidentifiedAccessKey == null || selfUnidentifiedAccessCertificate == null) {
|
||||
return Optional.absent();
|
||||
}
|
||||
|
||||
try {
|
||||
return Optional.of(new UnidentifiedAccessPair(new UnidentifiedAccess(selfUnidentifiedAccessKey,
|
||||
selfUnidentifiedAccessCertificate),
|
||||
new UnidentifiedAccess(selfUnidentifiedAccessKey, selfUnidentifiedAccessCertificate)));
|
||||
} catch (InvalidCertificateException e) {
|
||||
return Optional.absent();
|
||||
}
|
||||
}
|
||||
|
||||
private byte[] getSenderCertificateFor(final RecipientId recipientId) {
|
||||
final var sharingMode = account.getConfigurationStore().getPhoneNumberSharingMode();
|
||||
if (sharingMode == PhoneNumberSharingMode.EVERYBODY || (
|
||||
sharingMode == PhoneNumberSharingMode.CONTACTS
|
||||
&& account.getContactStore().getContact(recipientId) != null
|
||||
)) {
|
||||
logger.debug("Using normal sender certificate for message to {}", recipientId);
|
||||
logger.trace("Using normal sender certificate for message to {}", recipientId);
|
||||
return getSenderCertificate();
|
||||
} else {
|
||||
logger.debug("Using phone number privacy sender certificate for message to {}", recipientId);
|
||||
logger.trace("Using phone number privacy sender certificate for message to {}", recipientId);
|
||||
return getSenderCertificateForPhoneNumberPrivacy();
|
||||
}
|
||||
}
|
||||
|
@ -130,52 +182,6 @@ public class UnidentifiedAccessHelper {
|
|||
}
|
||||
}
|
||||
|
||||
public Optional<UnidentifiedAccessPair> getAccessForSync() {
|
||||
var selfUnidentifiedAccessKey = getSelfUnidentifiedAccessKey(false);
|
||||
var selfUnidentifiedAccessCertificate = getSenderCertificate();
|
||||
|
||||
if (selfUnidentifiedAccessKey == null || selfUnidentifiedAccessCertificate == null) {
|
||||
return Optional.absent();
|
||||
}
|
||||
|
||||
try {
|
||||
return Optional.of(new UnidentifiedAccessPair(new UnidentifiedAccess(selfUnidentifiedAccessKey,
|
||||
selfUnidentifiedAccessCertificate),
|
||||
new UnidentifiedAccess(selfUnidentifiedAccessKey, selfUnidentifiedAccessCertificate)));
|
||||
} catch (InvalidCertificateException e) {
|
||||
return Optional.absent();
|
||||
}
|
||||
}
|
||||
|
||||
public List<Optional<UnidentifiedAccessPair>> getAccessFor(List<RecipientId> recipients) {
|
||||
return recipients.stream().map(this::getAccessFor).toList();
|
||||
}
|
||||
|
||||
public Optional<UnidentifiedAccessPair> getAccessFor(RecipientId recipient) {
|
||||
return getAccessFor(recipient, false);
|
||||
}
|
||||
|
||||
public Optional<UnidentifiedAccessPair> getAccessFor(RecipientId recipient, boolean noRefresh) {
|
||||
var recipientUnidentifiedAccessKey = getTargetUnidentifiedAccessKey(recipient, noRefresh);
|
||||
if (recipientUnidentifiedAccessKey == null) {
|
||||
return Optional.absent();
|
||||
}
|
||||
|
||||
var selfUnidentifiedAccessKey = getSelfUnidentifiedAccessKey(noRefresh);
|
||||
var selfUnidentifiedAccessCertificate = getSenderCertificateFor(recipient);
|
||||
if (selfUnidentifiedAccessKey == null || selfUnidentifiedAccessCertificate == null) {
|
||||
return Optional.absent();
|
||||
}
|
||||
|
||||
try {
|
||||
return Optional.of(new UnidentifiedAccessPair(new UnidentifiedAccess(recipientUnidentifiedAccessKey,
|
||||
selfUnidentifiedAccessCertificate),
|
||||
new UnidentifiedAccess(selfUnidentifiedAccessKey, selfUnidentifiedAccessCertificate)));
|
||||
} catch (InvalidCertificateException e) {
|
||||
return Optional.absent();
|
||||
}
|
||||
}
|
||||
|
||||
private static byte[] createUnrestrictedUnidentifiedAccess() {
|
||||
return UNRESTRICTED_KEY;
|
||||
}
|
||||
|
|
|
@ -114,7 +114,7 @@ public class IdentityKeyStore implements org.whispersystems.libsignal.state.Iden
|
|||
return false;
|
||||
}
|
||||
if (identityInfo.getTrustLevel() == trustLevel) {
|
||||
logger.debug("Not updating trust level for recipient {}, trust level already matches", recipientId);
|
||||
logger.trace("Not updating trust level for recipient {}, trust level already matches", recipientId);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue