mirror of
https://github.com/AsamK/signal-cli
synced 2025-08-29 10:30:38 +00:00
Add RecipientIdCreator for creating recipientIds from the database
This commit is contained in:
parent
7da2e1b262
commit
46adc1af98
3 changed files with 21 additions and 1 deletions
|
@ -32,6 +32,7 @@ import org.asamk.signal.manager.storage.recipients.LegacyRecipientStore2;
|
|||
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.RecipientIdCreator;
|
||||
import org.asamk.signal.manager.storage.recipients.RecipientResolver;
|
||||
import org.asamk.signal.manager.storage.recipients.RecipientStore;
|
||||
import org.asamk.signal.manager.storage.recipients.RecipientTrustedResolver;
|
||||
|
@ -1117,6 +1118,10 @@ public class SignalAccount implements Closeable {
|
|||
return getRecipientStore();
|
||||
}
|
||||
|
||||
private RecipientIdCreator getRecipientIdCreator() {
|
||||
return recipientId -> getRecipientStore().create(recipientId);
|
||||
}
|
||||
|
||||
public RecipientResolver getRecipientResolver() {
|
||||
return new RecipientResolver() {
|
||||
@Override
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
package org.asamk.signal.manager.storage.recipients;
|
||||
|
||||
public interface RecipientIdCreator {
|
||||
|
||||
RecipientId create(long recipientId);
|
||||
}
|
|
@ -31,7 +31,7 @@ import java.util.UUID;
|
|||
import java.util.function.Supplier;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class RecipientStore implements RecipientResolver, RecipientTrustedResolver, ContactsStore, ProfileStore {
|
||||
public class RecipientStore implements RecipientIdCreator, RecipientResolver, RecipientTrustedResolver, ContactsStore, ProfileStore {
|
||||
|
||||
private final static Logger logger = LoggerFactory.getLogger(RecipientStore.class);
|
||||
private static final String TABLE_RECIPIENT = "recipient";
|
||||
|
@ -144,6 +144,15 @@ public class RecipientStore implements RecipientResolver, RecipientTrustedResolv
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Should only be used for recipientIds from the database.
|
||||
* Where the foreign key relations ensure a valid recipientId.
|
||||
*/
|
||||
@Override
|
||||
public RecipientId create(final long recipientId) {
|
||||
return new RecipientId(recipientId, this);
|
||||
}
|
||||
|
||||
public RecipientId resolveRecipient(
|
||||
final String number, Supplier<ACI> aciSupplier
|
||||
) throws UnregisteredRecipientException {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue