logger.trace("Archiving old sessions for {}", recipientId);
account.getSessionStore().archiveSessions(recipientId);
account.getSenderKeyStore().deleteSharedWith(recipientId);
- final var profile = account.getRecipientStore().getProfile(recipientId);
+ final var profile = account.getProfileStore().getProfile(recipientId);
if (profile != null) {
- account.getRecipientStore()
+ account.getProfileStore()
.storeProfile(recipientId,
Profile.newBuilder(profile)
.withUnidentifiedAccessMode(Profile.UnidentifiedAccessMode.UNKNOWN)
final var aci = registeredUsers.get(number);
final var profile = aci == null
? null
- : context.getProfileHelper().getRecipientProfile(account.getRecipientStore().resolveRecipient(aci));
+ : context.getProfileHelper()
+ .getRecipientProfile(account.getRecipientResolver().resolveRecipient(aci));
return new UserStatus(number.isEmpty() ? null : number,
aci == null ? null : aci.uuid(),
profile != null
return null;
}
- return Group.from(groupInfo,
- account.getRecipientStore()::resolveRecipientAddress,
- account.getSelfRecipientId());
+ return Group.from(groupInfo, account.getRecipientAddressResolver(), account.getSelfRecipientId());
}
@Override
}
private SendMessageResult toSendMessageResult(final org.whispersystems.signalservice.api.messages.SendMessageResult result) {
- return SendMessageResult.from(result,
- account.getRecipientStore(),
- account.getRecipientStore()::resolveRecipientAddress);
+ return SendMessageResult.from(result, account.getRecipientResolver(), account.getRecipientAddressResolver());
}
private SendMessageResults sendTypingMessage(
@Override
public void deleteRecipient(final RecipientIdentifier.Single recipient) {
- account.removeRecipient(account.getRecipientStore().resolveRecipient(recipient.toPartialRecipientAddress()));
+ account.removeRecipient(account.getRecipientResolver().resolveRecipient(recipient.toPartialRecipientAddress()));
}
@Override
public void deleteContact(final RecipientIdentifier.Single recipient) {
account.getContactStore()
- .deleteContact(account.getRecipientStore().resolveRecipient(recipient.toPartialRecipientAddress()));
+ .deleteContact(account.getRecipientResolver().resolveRecipient(recipient.toPartialRecipientAddress()));
}
@Override
return null;
}
- final var address = account.getRecipientStore().resolveRecipientAddress(identityInfo.getRecipientId());
+ final var address = account.getRecipientAddressResolver()
+ .resolveRecipientAddress(identityInfo.getRecipientId());
final var scannableFingerprint = context.getIdentityHelper()
.computeSafetyNumberForScanning(identityInfo.getRecipientId(), identityInfo.getIdentityKey());
return new Identity(address,
account.setNumber(number);
account.setAci(aci);
account.setPni(pni);
- account.getRecipientStore().resolveSelfRecipientTrusted(account.getSelfRecipientAddress());
+ account.getRecipientTrustedResolver().resolveSelfRecipientTrusted(account.getSelfRecipientAddress());
// TODO check and update remote storage
context.getUnidentifiedAccessHelper().rotateSenderCertificates();
dependencies.resetAfterAddressChange();
downloadGroupAvatar(groupId, groupSecretParams, avatar);
}
}
- groupInfoV2.setGroup(group, account.getRecipientStore());
+ groupInfoV2.setGroup(group, account.getRecipientResolver());
account.getGroupStore().updateGroup(groupInfoV2);
}
final var gv2 = gv2Pair.first();
final var decryptedGroup = gv2Pair.second();
- gv2.setGroup(decryptedGroup, account.getRecipientStore());
+ gv2.setGroup(decryptedGroup, account.getRecipientResolver());
if (avatarFile != null) {
context.getAvatarStore()
.storeGroupAvatar(gv2.getGroupId(),
downloadGroupAvatar(groupInfoV2.getGroupId(), groupSecretParams, avatar);
}
}
- groupInfoV2.setGroup(decryptedGroup, account.getRecipientStore());
+ groupInfoV2.setGroup(decryptedGroup, account.getRecipientResolver());
account.getGroupStore().updateGroup(group);
}
}
private void storeProfileKeysFromMembers(final DecryptedGroup group) {
for (var member : group.getMembersList()) {
final var serviceId = ServiceId.fromByteString(member.getUuid());
- final var recipientId = account.getRecipientStore().resolveRecipient(serviceId);
+ final var recipientId = account.getRecipientResolver().resolveRecipient(serviceId);
final var profileStore = account.getProfileStore();
if (profileStore.getProfileKey(recipientId) != null) {
// We already have a profile key, not updating it from a non-authoritative source
if (profileKeyFromChange != null) {
final var serviceId = profileKeyFromChange.first();
final var profileKey = profileKeyFromChange.second();
- final var recipientId = account.getRecipientStore().resolveRecipient(serviceId);
+ final var recipientId = account.getRecipientResolver().resolveRecipient(serviceId);
account.getProfileStore().storeProfileKey(recipientId, profileKey);
}
}
.forEach(p -> {
final var serviceId = p.first();
final var profileKey = p.second();
- final var recipientId = account.getRecipientStore().resolveRecipient(serviceId);
+ final var recipientId = account.getRecipientResolver().resolveRecipient(serviceId);
newProfileKeys.put(recipientId, profileKey);
});
if (!page.getPagingData().hasMorePages()) {
throw new LastGroupAdminException(groupInfoV2.getGroupId(), groupInfoV2.getTitle());
}
final var groupGroupChangePair = context.getGroupV2Helper().leaveGroup(groupInfoV2, newAdmins);
- groupInfoV2.setGroup(groupGroupChangePair.first(), account.getRecipientStore());
+ groupInfoV2.setGroup(groupGroupChangePair.first(), account.getRecipientResolver());
account.getGroupStore().updateGroup(groupInfoV2);
var messageBuilder = getGroupUpdateMessageBuilder(groupInfoV2, groupGroupChangePair.second().toByteArray());
) throws IOException {
final var selfRecipientId = account.getSelfRecipientId();
final var members = group.getMembersIncludingPendingWithout(selfRecipientId);
- group.setGroup(newDecryptedGroup, account.getRecipientStore());
+ group.setGroup(newDecryptedGroup, account.getRecipientResolver());
members.addAll(group.getMembersIncludingPendingWithout(selfRecipientId));
account.getGroupStore().updateGroup(group);
return new SendGroupMessageResults(timestamp,
results.stream()
.map(sendMessageResult -> SendMessageResult.from(sendMessageResult,
- account.getRecipientStore(),
- account.getRecipientStore()::resolveRecipientAddress))
+ account.getRecipientResolver(),
+ account.getRecipientAddressResolver()))
.toList());
}
}
try {
content = dependencies.getCipher().decrypt(envelope);
} catch (ProtocolUntrustedIdentityException e) {
- final var recipientId = account.getRecipientStore().resolveRecipient(e.getSender());
- final var exception = new UntrustedIdentityException(account.getRecipientStore()
+ final var recipientId = account.getRecipientResolver().resolveRecipient(e.getSender());
+ final var exception = new UntrustedIdentityException(account.getRecipientAddressResolver()
.resolveRecipientAddress(recipientId), e.getSenderDevice());
return new Pair<>(List.of(), exception);
} catch (Exception e) {
if (envelope.hasSourceUuid()) {
// Store uuid if we don't have it already
// address/uuid in envelope is sent by server
- account.getRecipientStore().resolveRecipientTrusted(envelope.getSourceAddress());
+ account.getRecipientTrustedResolver().resolveRecipientTrusted(envelope.getSourceAddress());
}
SignalServiceContent content = null;
Exception exception = null;
try {
content = dependencies.getCipher().decrypt(envelope);
} catch (ProtocolUntrustedIdentityException e) {
- final var recipientId = account.getRecipientStore().resolveRecipient(e.getSender());
+ final var recipientId = account.getRecipientResolver().resolveRecipient(e.getSender());
actions.add(new RetrieveProfileAction(recipientId));
- exception = new UntrustedIdentityException(account.getRecipientStore()
+ exception = new UntrustedIdentityException(account.getRecipientAddressResolver()
.resolveRecipientAddress(recipientId), e.getSenderDevice());
} catch (ProtocolInvalidKeyIdException | ProtocolInvalidKeyException | ProtocolNoSessionException |
ProtocolInvalidMessageException e) {
logger.debug("Failed to decrypt incoming message", e);
- final var sender = account.getRecipientStore().resolveRecipient(e.getSender());
+ final var sender = account.getRecipientResolver().resolveRecipient(e.getSender());
if (context.getContactHelper().isContactBlocked(sender)) {
logger.debug("Received invalid message from blocked contact, ignoring.");
} else {
if (!envelope.hasSourceUuid() && content != null) {
// Store uuid if we don't have it already
// address/uuid is validated by unidentified sender certificate
- account.getRecipientStore().resolveRecipientTrusted(content.getSender());
+ account.getRecipientTrustedResolver().resolveRecipientTrusted(content.getSender());
}
if (envelope.isReceipt()) {
final var senderPair = getSender(envelope, content);
}
handler.handleMessage(MessageEnvelope.from(envelope,
content,
- account.getRecipientStore(),
- account.getRecipientStore()::resolveRecipientAddress,
+ account.getRecipientResolver(),
+ account.getRecipientAddressResolver(),
context.getAttachmentHelper()::getAttachmentFile,
exception), exception);
return actions;
if (syncMessage.getVerified().isPresent()) {
final var verifiedMessage = syncMessage.getVerified().get();
account.getIdentityKeyStore()
- .setIdentityTrustLevel(account.getRecipientStore()
+ .setIdentityTrustLevel(account.getRecipientTrustedResolver()
.resolveRecipientTrusted(verifiedMessage.getDestination()),
verifiedMessage.getIdentityKey(),
TrustLevel.fromVerifiedState(verifiedMessage.getVerified()));
var profile = account.getProfileStore().getProfile(recipientId);
if (profile == null || !Objects.equals(avatarPath, profile.getAvatarUrlPath())) {
logger.trace("Downloading profile avatar for {}", recipientId);
- downloadProfileAvatar(account.getRecipientStore().resolveRecipientAddress(recipientId),
+ downloadProfileAvatar(account.getRecipientAddressResolver().resolveRecipientAddress(recipientId),
avatarPath,
profileKey);
var builder = profile == null ? Profile.newBuilder() : Profile.newBuilder(profile);
isWaitingForMessage = true;
var result = signalWebSocket.readOrEmpty(timeout.toMillis(), envelope1 -> {
isWaitingForMessage = false;
- final var recipientId = envelope1.hasSourceUuid() ? account.getRecipientStore()
+ final var recipientId = envelope1.hasSourceUuid() ? account.getRecipientResolver()
.resolveRecipient(envelope1.getSourceAddress()) : null;
logger.trace("Storing new message from {}", recipientId);
// store message on disk, before acknowledging receipt to the server
if (exception instanceof UntrustedIdentityException) {
logger.debug("Keeping message with untrusted identity in message cache");
final var address = ((UntrustedIdentityException) exception).getSender();
- final var recipientId = account.getRecipientStore().resolveRecipient(address);
+ final var recipientId = account.getRecipientResolver().resolveRecipient(address);
if (!envelope.hasSourceUuid()) {
try {
cachedMessage[0] = account.getMessageCache().replaceSender(cachedMessage[0], recipientId);
}
if (!envelope.hasSourceUuid()) {
final var identifier = ((UntrustedIdentityException) exception).getSender();
- final var recipientId = account.getRecipientStore().resolveRecipient(identifier);
+ final var recipientId = account.getRecipientResolver().resolveRecipient(identifier);
try {
account.getMessageCache().replaceSender(cachedMessage, recipientId);
} catch (IOException ioException) {
}
public SignalServiceAddress resolveSignalServiceAddress(RecipientId recipientId) {
- final var address = account.getRecipientStore().resolveRecipientAddress(recipientId);
+ final var address = account.getRecipientAddressResolver().resolveRecipientAddress(recipientId);
if (address.number().isEmpty() || address.uuid().isPresent()) {
return address.toSignalServiceAddress();
}
// Return SignalServiceAddress with unknown UUID
return address.toSignalServiceAddress();
}
- return account.getRecipientStore()
- .resolveRecipientAddress(account.getRecipientStore().resolveRecipient(aci))
+ return account.getRecipientAddressResolver()
+ .resolveRecipientAddress(account.getRecipientResolver().resolveRecipient(aci))
.toSignalServiceAddress();
}
public RecipientId resolveRecipient(final SignalServiceAddress address) {
- return account.getRecipientStore().resolveRecipient(address);
+ return account.getRecipientResolver().resolveRecipient(address);
}
public Set<RecipientId> resolveRecipients(Collection<RecipientIdentifier.Single> recipients) throws UnregisteredRecipientException {
public RecipientId resolveRecipient(final RecipientIdentifier.Single recipient) throws UnregisteredRecipientException {
if (recipient instanceof RecipientIdentifier.Uuid uuidRecipient) {
- return account.getRecipientStore().resolveRecipient(ServiceId.from(uuidRecipient.uuid()));
+ return account.getRecipientResolver().resolveRecipient(ServiceId.from(uuidRecipient.uuid()));
} else {
final var number = ((RecipientIdentifier.Number) recipient).number();
return account.getRecipientStore().resolveRecipient(number, () -> {
}
final var number = address.getNumber().get();
final var uuid = getRegisteredUser(number);
- return account.getRecipientStore().resolveRecipientTrusted(new SignalServiceAddress(uuid, number));
+ return account.getRecipientTrustedResolver().resolveRecipientTrusted(new SignalServiceAddress(uuid, number));
}
public Map<String, ACI> getRegisteredUsers(final Set<String> numbers) throws IOException {
}
// Store numbers as recipients, so we have the number/uuid association
- registeredUsers.forEach((number, aci) -> account.getRecipientStore()
+ registeredUsers.forEach((number, aci) -> account.getRecipientTrustedResolver()
.resolveRecipientTrusted(new SignalServiceAddress(aci, number)));
return registeredUsers;
private void handleSendMessageResult(final SendMessageResult r) {
if (r.isSuccess() && !r.getSuccess().isUnidentified()) {
final var recipientId = context.getRecipientHelper().resolveRecipient(r.getAddress());
- final var profile = account.getRecipientStore().getProfile(recipientId);
+ final var profile = account.getProfileStore().getProfile(recipientId);
if (profile != null && (
profile.getUnidentifiedAccessMode() == Profile.UnidentifiedAccessMode.ENABLED
|| profile.getUnidentifiedAccessMode() == Profile.UnidentifiedAccessMode.UNRESTRICTED
)) {
- account.getRecipientStore()
+ account.getProfileStore()
.storeProfile(recipientId,
Profile.newBuilder(profile)
.withUnidentifiedAccessMode(Profile.UnidentifiedAccessMode.UNKNOWN)
}
if (r.isUnregisteredFailure()) {
final var recipientId = context.getRecipientHelper().resolveRecipient(r.getAddress());
- final var profile = account.getRecipientStore().getProfile(recipientId);
+ final var profile = account.getProfileStore().getProfile(recipientId);
if (profile != null && (
profile.getUnidentifiedAccessMode() == Profile.UnidentifiedAccessMode.ENABLED
|| profile.getUnidentifiedAccessMode() == Profile.UnidentifiedAccessMode.UNRESTRICTED
)) {
- account.getRecipientStore()
+ account.getProfileStore()
.storeProfile(recipientId,
Profile.newBuilder(profile)
.withUnidentifiedAccessMode(Profile.UnidentifiedAccessMode.UNKNOWN)
final var contactRecord = record.getContact().get();
final var address = contactRecord.getAddress();
- final var recipientId = account.getRecipientStore().resolveRecipient(address);
+ final var recipientId = account.getRecipientResolver().resolveRecipient(address);
final var contact = account.getContactStore().getContact(recipientId);
final var blocked = contact != null && contact.isBlocked();
final var profileShared = contact != null && contact.isProfileSharingEnabled();
if (c.getAddress().matches(account.getSelfAddress()) && c.getProfileKey().isPresent()) {
account.setProfileKey(c.getProfileKey().get());
}
- final var recipientId = account.getRecipientStore().resolveRecipientTrusted(c.getAddress());
+ final var recipientId = account.getRecipientTrustedResolver().resolveRecipientTrusted(c.getAddress());
var contact = account.getContactStore().getContact(recipientId);
final var builder = contact == null ? Contact.newBuilder() : Contact.newBuilder(contact);
if (c.getName().isPresent()) {
if (c.getVerified().isPresent()) {
final var verifiedMessage = c.getVerified().get();
account.getIdentityKeyStore()
- .setIdentityTrustLevel(account.getRecipientStore()
+ .setIdentityTrustLevel(account.getRecipientTrustedResolver()
.resolveRecipientTrusted(verifiedMessage.getDestination()),
verifiedMessage.getIdentityKey(),
TrustLevel.fromVerifiedState(verifiedMessage.getVerified()));
import org.asamk.signal.manager.api.TrustLevel;
import org.asamk.signal.manager.config.ServiceEnvironment;
import org.asamk.signal.manager.groups.GroupId;
+import org.asamk.signal.manager.helper.RecipientAddressResolver;
import org.asamk.signal.manager.storage.configuration.ConfigurationStore;
import org.asamk.signal.manager.storage.contacts.ContactsStore;
import org.asamk.signal.manager.storage.contacts.LegacyJsonContactsStore;
import org.asamk.signal.manager.storage.recipients.Profile;
import org.asamk.signal.manager.storage.recipients.RecipientAddress;
import org.asamk.signal.manager.storage.recipients.RecipientId;
+import org.asamk.signal.manager.storage.recipients.RecipientResolver;
import org.asamk.signal.manager.storage.recipients.RecipientStore;
+import org.asamk.signal.manager.storage.recipients.RecipientTrustedResolver;
import org.asamk.signal.manager.storage.sendLog.MessageSendLogStore;
import org.asamk.signal.manager.storage.senderKeys.SenderKeyStore;
import org.asamk.signal.manager.storage.sessions.SessionStore;
signalAccount.localRegistrationId = registrationId;
signalAccount.trustNewIdentity = trustNewIdentity;
signalAccount.groupStore = new GroupStore(getGroupCachePath(dataPath, accountPath),
- signalAccount.getRecipientStore(),
+ signalAccount.getRecipientResolver(),
signalAccount::saveGroupStore);
signalAccount.stickerStore = new StickerStore(signalAccount::saveStickerStore);
signalAccount.configurationStore = new ConfigurationStore(signalAccount::saveConfigurationStore);
aciIdentityKey,
pniIdentityKey,
profileKey);
- signalAccount.getRecipientStore().resolveSelfRecipientTrusted(signalAccount.getSelfRecipientAddress());
+ signalAccount.getRecipientTrustedResolver()
+ .resolveSelfRecipientTrusted(signalAccount.getSelfRecipientAddress());
signalAccount.getSessionStore().archiveAllSessions();
signalAccount.getSenderKeyStore().deleteAll();
signalAccount.clearAllPreKeys();
signalAccount.localRegistrationId = registrationId;
signalAccount.trustNewIdentity = trustNewIdentity;
signalAccount.groupStore = new GroupStore(getGroupCachePath(dataPath, accountPath),
- signalAccount.getRecipientStore(),
+ signalAccount.getRecipientResolver(),
signalAccount::saveGroupStore);
signalAccount.stickerStore = new StickerStore(signalAccount::saveStickerStore);
signalAccount.configurationStore = new ConfigurationStore(signalAccount::saveConfigurationStore);
- signalAccount.getRecipientStore().resolveSelfRecipientTrusted(signalAccount.getSelfRecipientAddress());
+ signalAccount.getRecipientTrustedResolver()
+ .resolveSelfRecipientTrusted(signalAccount.getSelfRecipientAddress());
signalAccount.previousStorageVersion = CURRENT_STORAGE_VERSION;
signalAccount.migrateLegacyConfigs();
signalAccount.clearAllPreKeys();
groupStoreStorage = jsonProcessor.convertValue(rootNode.get("groupStore"), GroupStore.Storage.class);
groupStore = GroupStore.fromStorage(groupStoreStorage,
getGroupCachePath(dataPath, accountPath),
- getRecipientStore(),
+ getRecipientResolver(),
this::saveGroupStore);
} else {
groupStore = new GroupStore(getGroupCachePath(dataPath, accountPath),
- getRecipientStore(),
+ getRecipientResolver(),
this::saveGroupStore);
}
if (legacyRecipientStore != null) {
getRecipientStore().resolveRecipientsTrusted(legacyRecipientStore.getAddresses());
}
- getRecipientStore().resolveSelfRecipientTrusted(getSelfRecipientAddress());
+ getRecipientTrustedResolver().resolveSelfRecipientTrusted(getSelfRecipientAddress());
migrated = true;
}
final var contactStore = jsonProcessor.convertValue(contactStoreNode, LegacyJsonContactsStore.class);
for (var contact : contactStore.getContacts()) {
final var recipientId = getRecipientStore().resolveRecipientTrusted(contact.getAddress());
- getRecipientStore().storeContact(recipientId,
+ getContactStore().storeContact(recipientId,
new Contact(contact.name,
contact.color,
contact.messageExpirationTime,
var profileStoreNode = rootNode.get("profileStore");
final var legacyProfileStore = jsonProcessor.convertValue(profileStoreNode, LegacyProfileStore.class);
for (var profileEntry : legacyProfileStore.getProfileEntries()) {
- var recipientId = getRecipientStore().resolveRecipient(profileEntry.getAddress());
- getRecipientStore().storeProfileKeyCredential(recipientId, profileEntry.getProfileKeyCredential());
- getRecipientStore().storeProfileKey(recipientId, profileEntry.getProfileKey());
+ var recipientId = getRecipientResolver().resolveRecipient(profileEntry.getAddress());
+ getProfileStore().storeProfileKeyCredential(recipientId, profileEntry.getProfileKeyCredential());
+ getProfileStore().storeProfileKey(recipientId, profileEntry.getProfileKey());
final var profile = profileEntry.getProfile();
if (profile != null) {
final var capabilities = new HashSet<Profile.Capability>();
? Profile.UnidentifiedAccessMode.ENABLED
: Profile.UnidentifiedAccessMode.DISABLED,
capabilities);
- getRecipientStore().storeProfile(recipientId, newProfile);
+ getProfileStore().storeProfile(recipientId, newProfile);
}
}
}
}
try {
if (UuidUtil.isUuid(thread.id) || thread.id.startsWith("+")) {
- final var recipientId = getRecipientStore().resolveRecipient(thread.id);
- var contact = getRecipientStore().getContact(recipientId);
+ final var recipientId = getRecipientResolver().resolveRecipient(thread.id);
+ var contact = getContactStore().getContact(recipientId);
if (contact != null) {
- getRecipientStore().storeContact(recipientId,
+ getContactStore().storeContact(recipientId,
Contact.newBuilder(contact)
.withMessageExpirationTime(thread.messageExpirationTime)
.build());
public SessionStore getSessionStore() {
return getOrCreate(() -> sessionStore,
- () -> sessionStore = new SessionStore(getSessionsPath(dataPath, accountPath), getRecipientStore()));
+ () -> sessionStore = new SessionStore(getSessionsPath(dataPath, accountPath), getRecipientResolver()));
}
public IdentityKeyStore getIdentityKeyStore() {
return getOrCreate(() -> identityKeyStore,
() -> identityKeyStore = new IdentityKeyStore(getIdentitiesPath(dataPath, accountPath),
- getRecipientStore(),
+ getRecipientResolver(),
aciIdentityKeyPair,
localRegistrationId,
trustNewIdentity));
return getRecipientStore();
}
+ public RecipientResolver getRecipientResolver() {
+ return getRecipientStore();
+ }
+
+ public RecipientTrustedResolver getRecipientTrustedResolver() {
+ return getRecipientStore();
+ }
+
+ public RecipientAddressResolver getRecipientAddressResolver() {
+ return getRecipientStore()::resolveRecipientAddress;
+ }
+
public RecipientStore getRecipientStore() {
return getOrCreate(() -> recipientStore,
() -> recipientStore = RecipientStore.load(getRecipientsStoreFile(dataPath, accountPath),
return getOrCreate(() -> senderKeyStore,
() -> senderKeyStore = new SenderKeyStore(getSharedSenderKeysFile(dataPath, accountPath),
getSenderKeysPath(dataPath, accountPath),
- getRecipientStore()::resolveRecipientAddress,
- getRecipientStore()));
+ getRecipientAddressResolver(),
+ getRecipientResolver()));
}
public ConfigurationStore getConfigurationStore() {
public MessageSendLogStore getMessageSendLogStore() {
return getOrCreate(() -> messageSendLogStore,
- () -> messageSendLogStore = new MessageSendLogStore(getRecipientStore(), getAccountDatabase()));
+ () -> messageSendLogStore = new MessageSendLogStore(getRecipientResolver(), getAccountDatabase()));
}
public CredentialsProvider getCredentialsProvider() {
}
public RecipientId getSelfRecipientId() {
- return getRecipientStore().resolveRecipient(getSelfRecipientAddress());
+ return getRecipientResolver().resolveRecipient(getSelfRecipientAddress());
}
public byte[] getEncryptedDeviceName() {
clearAllPreKeys();
getSessionStore().archiveAllSessions();
getSenderKeyStore().deleteAll();
- final var recipientId = getRecipientStore().resolveSelfRecipientTrusted(getSelfRecipientAddress());
+ final var recipientId = getRecipientTrustedResolver().resolveSelfRecipientTrusted(getSelfRecipientAddress());
final var publicKey = getAciIdentityKeyPair().getPublicKey();
getIdentityKeyStore().saveIdentity(recipientId, publicKey, new Date());
getIdentityKeyStore().setIdentityTrustLevel(recipientId, publicKey, TrustLevel.TRUSTED_VERIFIED);
import java.util.function.Supplier;
import java.util.stream.Collectors;
-public class RecipientStore implements RecipientResolver, ContactsStore, ProfileStore {
+public class RecipientStore implements RecipientResolver, RecipientTrustedResolver, ContactsStore, ProfileStore {
private final static Logger logger = LoggerFactory.getLogger(RecipientStore.class);
return resolveRecipient(new RecipientAddress(address), false, false);
}
+ @Override
public RecipientId resolveSelfRecipientTrusted(RecipientAddress address) {
return resolveRecipient(address, true, true);
}
return resolveRecipient(address, true, false);
}
+ @Override
public RecipientId resolveRecipientTrusted(SignalServiceAddress address) {
return resolveRecipient(new RecipientAddress(address), true, false);
}
--- /dev/null
+package org.asamk.signal.manager.storage.recipients;
+
+import org.whispersystems.signalservice.api.push.SignalServiceAddress;
+
+public interface RecipientTrustedResolver {
+
+ RecipientId resolveSelfRecipientTrusted(RecipientAddress address);
+
+ RecipientId resolveRecipientTrusted(SignalServiceAddress address);
+}