mirror of
https://github.com/AsamK/signal-cli
synced 2025-08-29 02:20:39 +00:00
Add UnregisteredRecipientException
This commit is contained in:
parent
a7ecb9e10f
commit
c88c92086e
20 changed files with 244 additions and 117 deletions
|
@ -13,6 +13,7 @@ import org.asamk.signal.manager.api.RecipientIdentifier;
|
||||||
import org.asamk.signal.manager.api.SendGroupMessageResults;
|
import org.asamk.signal.manager.api.SendGroupMessageResults;
|
||||||
import org.asamk.signal.manager.api.SendMessageResults;
|
import org.asamk.signal.manager.api.SendMessageResults;
|
||||||
import org.asamk.signal.manager.api.TypingAction;
|
import org.asamk.signal.manager.api.TypingAction;
|
||||||
|
import org.asamk.signal.manager.api.UnregisteredRecipientException;
|
||||||
import org.asamk.signal.manager.api.UpdateGroup;
|
import org.asamk.signal.manager.api.UpdateGroup;
|
||||||
import org.asamk.signal.manager.config.ServiceConfig;
|
import org.asamk.signal.manager.config.ServiceConfig;
|
||||||
import org.asamk.signal.manager.config.ServiceEnvironment;
|
import org.asamk.signal.manager.config.ServiceEnvironment;
|
||||||
|
@ -40,7 +41,6 @@ import java.util.Map;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.concurrent.TimeUnit;
|
|
||||||
|
|
||||||
public interface Manager extends Closeable {
|
public interface Manager extends Closeable {
|
||||||
|
|
||||||
|
@ -123,23 +123,23 @@ public interface Manager extends Closeable {
|
||||||
|
|
||||||
void setRegistrationLockPin(Optional<String> pin) throws IOException;
|
void setRegistrationLockPin(Optional<String> pin) throws IOException;
|
||||||
|
|
||||||
Profile getRecipientProfile(RecipientIdentifier.Single recipient) throws IOException;
|
Profile getRecipientProfile(RecipientIdentifier.Single recipient) throws IOException, UnregisteredRecipientException;
|
||||||
|
|
||||||
List<Group> getGroups();
|
List<Group> getGroups();
|
||||||
|
|
||||||
SendGroupMessageResults quitGroup(
|
SendGroupMessageResults quitGroup(
|
||||||
GroupId groupId, Set<RecipientIdentifier.Single> groupAdmins
|
GroupId groupId, Set<RecipientIdentifier.Single> groupAdmins
|
||||||
) throws GroupNotFoundException, IOException, NotAGroupMemberException, LastGroupAdminException;
|
) throws GroupNotFoundException, IOException, NotAGroupMemberException, LastGroupAdminException, UnregisteredRecipientException;
|
||||||
|
|
||||||
void deleteGroup(GroupId groupId) throws IOException;
|
void deleteGroup(GroupId groupId) throws IOException;
|
||||||
|
|
||||||
Pair<GroupId, SendGroupMessageResults> createGroup(
|
Pair<GroupId, SendGroupMessageResults> createGroup(
|
||||||
String name, Set<RecipientIdentifier.Single> members, File avatarFile
|
String name, Set<RecipientIdentifier.Single> members, File avatarFile
|
||||||
) throws IOException, AttachmentInvalidException;
|
) throws IOException, AttachmentInvalidException, UnregisteredRecipientException;
|
||||||
|
|
||||||
SendGroupMessageResults updateGroup(
|
SendGroupMessageResults updateGroup(
|
||||||
final GroupId groupId, final UpdateGroup updateGroup
|
final GroupId groupId, final UpdateGroup updateGroup
|
||||||
) throws IOException, GroupNotFoundException, AttachmentInvalidException, NotAGroupMemberException, GroupSendingNotAllowedException;
|
) throws IOException, GroupNotFoundException, AttachmentInvalidException, NotAGroupMemberException, GroupSendingNotAllowedException, UnregisteredRecipientException;
|
||||||
|
|
||||||
Pair<GroupId, SendGroupMessageResults> joinGroup(
|
Pair<GroupId, SendGroupMessageResults> joinGroup(
|
||||||
GroupInviteLinkUrl inviteLinkUrl
|
GroupInviteLinkUrl inviteLinkUrl
|
||||||
|
@ -159,7 +159,7 @@ public interface Manager extends Closeable {
|
||||||
|
|
||||||
SendMessageResults sendMessage(
|
SendMessageResults sendMessage(
|
||||||
Message message, Set<RecipientIdentifier> recipients
|
Message message, Set<RecipientIdentifier> recipients
|
||||||
) throws IOException, AttachmentInvalidException, NotAGroupMemberException, GroupNotFoundException, GroupSendingNotAllowedException;
|
) throws IOException, AttachmentInvalidException, NotAGroupMemberException, GroupNotFoundException, GroupSendingNotAllowedException, UnregisteredRecipientException;
|
||||||
|
|
||||||
SendMessageResults sendRemoteDeleteMessage(
|
SendMessageResults sendRemoteDeleteMessage(
|
||||||
long targetSentTimestamp, Set<RecipientIdentifier> recipients
|
long targetSentTimestamp, Set<RecipientIdentifier> recipients
|
||||||
|
@ -171,21 +171,21 @@ public interface Manager extends Closeable {
|
||||||
RecipientIdentifier.Single targetAuthor,
|
RecipientIdentifier.Single targetAuthor,
|
||||||
long targetSentTimestamp,
|
long targetSentTimestamp,
|
||||||
Set<RecipientIdentifier> recipients
|
Set<RecipientIdentifier> recipients
|
||||||
) throws IOException, NotAGroupMemberException, GroupNotFoundException, GroupSendingNotAllowedException;
|
) throws IOException, NotAGroupMemberException, GroupNotFoundException, GroupSendingNotAllowedException, UnregisteredRecipientException;
|
||||||
|
|
||||||
SendMessageResults sendEndSessionMessage(Set<RecipientIdentifier.Single> recipients) throws IOException;
|
SendMessageResults sendEndSessionMessage(Set<RecipientIdentifier.Single> recipients) throws IOException;
|
||||||
|
|
||||||
void deleteRecipient(RecipientIdentifier.Single recipient) throws IOException;
|
void deleteRecipient(RecipientIdentifier.Single recipient);
|
||||||
|
|
||||||
void deleteContact(RecipientIdentifier.Single recipient) throws IOException;
|
void deleteContact(RecipientIdentifier.Single recipient);
|
||||||
|
|
||||||
void setContactName(
|
void setContactName(
|
||||||
RecipientIdentifier.Single recipient, String name
|
RecipientIdentifier.Single recipient, String name
|
||||||
) throws NotMasterDeviceException, IOException;
|
) throws NotMasterDeviceException, IOException, UnregisteredRecipientException;
|
||||||
|
|
||||||
void setContactBlocked(
|
void setContactBlocked(
|
||||||
RecipientIdentifier.Single recipient, boolean blocked
|
RecipientIdentifier.Single recipient, boolean blocked
|
||||||
) throws NotMasterDeviceException, IOException;
|
) throws NotMasterDeviceException, IOException, UnregisteredRecipientException;
|
||||||
|
|
||||||
void setGroupBlocked(
|
void setGroupBlocked(
|
||||||
GroupId groupId, boolean blocked
|
GroupId groupId, boolean blocked
|
||||||
|
@ -193,7 +193,7 @@ public interface Manager extends Closeable {
|
||||||
|
|
||||||
void setExpirationTimer(
|
void setExpirationTimer(
|
||||||
RecipientIdentifier.Single recipient, int messageExpirationTimer
|
RecipientIdentifier.Single recipient, int messageExpirationTimer
|
||||||
) throws IOException;
|
) throws IOException, UnregisteredRecipientException;
|
||||||
|
|
||||||
URI uploadStickerPack(File path) throws IOException, StickerPackInvalidException;
|
URI uploadStickerPack(File path) throws IOException, StickerPackInvalidException;
|
||||||
|
|
||||||
|
@ -245,13 +245,19 @@ public interface Manager extends Closeable {
|
||||||
|
|
||||||
List<Identity> getIdentities(RecipientIdentifier.Single recipient);
|
List<Identity> getIdentities(RecipientIdentifier.Single recipient);
|
||||||
|
|
||||||
boolean trustIdentityVerified(RecipientIdentifier.Single recipient, byte[] fingerprint);
|
boolean trustIdentityVerified(
|
||||||
|
RecipientIdentifier.Single recipient, byte[] fingerprint
|
||||||
|
) throws UnregisteredRecipientException;
|
||||||
|
|
||||||
boolean trustIdentityVerifiedSafetyNumber(RecipientIdentifier.Single recipient, String safetyNumber);
|
boolean trustIdentityVerifiedSafetyNumber(
|
||||||
|
RecipientIdentifier.Single recipient, String safetyNumber
|
||||||
|
) throws UnregisteredRecipientException;
|
||||||
|
|
||||||
boolean trustIdentityVerifiedSafetyNumber(RecipientIdentifier.Single recipient, byte[] safetyNumber);
|
boolean trustIdentityVerifiedSafetyNumber(
|
||||||
|
RecipientIdentifier.Single recipient, byte[] safetyNumber
|
||||||
|
) throws UnregisteredRecipientException;
|
||||||
|
|
||||||
boolean trustIdentityAllKeys(RecipientIdentifier.Single recipient);
|
boolean trustIdentityAllKeys(RecipientIdentifier.Single recipient) throws UnregisteredRecipientException;
|
||||||
|
|
||||||
void addClosedListener(Runnable listener);
|
void addClosedListener(Runnable listener);
|
||||||
|
|
||||||
|
|
|
@ -30,6 +30,7 @@ import org.asamk.signal.manager.api.SendGroupMessageResults;
|
||||||
import org.asamk.signal.manager.api.SendMessageResult;
|
import org.asamk.signal.manager.api.SendMessageResult;
|
||||||
import org.asamk.signal.manager.api.SendMessageResults;
|
import org.asamk.signal.manager.api.SendMessageResults;
|
||||||
import org.asamk.signal.manager.api.TypingAction;
|
import org.asamk.signal.manager.api.TypingAction;
|
||||||
|
import org.asamk.signal.manager.api.UnregisteredRecipientException;
|
||||||
import org.asamk.signal.manager.api.UpdateGroup;
|
import org.asamk.signal.manager.api.UpdateGroup;
|
||||||
import org.asamk.signal.manager.config.ServiceEnvironmentConfig;
|
import org.asamk.signal.manager.config.ServiceEnvironmentConfig;
|
||||||
import org.asamk.signal.manager.groups.GroupId;
|
import org.asamk.signal.manager.groups.GroupId;
|
||||||
|
@ -76,7 +77,6 @@ import org.whispersystems.signalservice.api.messages.SignalServiceEnvelope;
|
||||||
import org.whispersystems.signalservice.api.messages.SignalServiceReceiptMessage;
|
import org.whispersystems.signalservice.api.messages.SignalServiceReceiptMessage;
|
||||||
import org.whispersystems.signalservice.api.messages.SignalServiceTypingMessage;
|
import org.whispersystems.signalservice.api.messages.SignalServiceTypingMessage;
|
||||||
import org.whispersystems.signalservice.api.push.ACI;
|
import org.whispersystems.signalservice.api.push.ACI;
|
||||||
import org.whispersystems.signalservice.api.push.SignalServiceAddress;
|
|
||||||
import org.whispersystems.signalservice.api.push.exceptions.AuthorizationFailedException;
|
import org.whispersystems.signalservice.api.push.exceptions.AuthorizationFailedException;
|
||||||
import org.whispersystems.signalservice.api.util.DeviceNameUtil;
|
import org.whispersystems.signalservice.api.util.DeviceNameUtil;
|
||||||
import org.whispersystems.signalservice.api.util.InvalidNumberException;
|
import org.whispersystems.signalservice.api.util.InvalidNumberException;
|
||||||
|
@ -506,7 +506,7 @@ public class ManagerImpl implements Manager {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Profile getRecipientProfile(RecipientIdentifier.Single recipient) throws IOException {
|
public Profile getRecipientProfile(RecipientIdentifier.Single recipient) throws IOException, UnregisteredRecipientException {
|
||||||
return profileHelper.getRecipientProfile(recipientHelper.resolveRecipient(recipient));
|
return profileHelper.getRecipientProfile(recipientHelper.resolveRecipient(recipient));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -556,7 +556,7 @@ public class ManagerImpl implements Manager {
|
||||||
@Override
|
@Override
|
||||||
public SendGroupMessageResults quitGroup(
|
public SendGroupMessageResults quitGroup(
|
||||||
GroupId groupId, Set<RecipientIdentifier.Single> groupAdmins
|
GroupId groupId, Set<RecipientIdentifier.Single> groupAdmins
|
||||||
) throws GroupNotFoundException, IOException, NotAGroupMemberException, LastGroupAdminException {
|
) throws GroupNotFoundException, IOException, NotAGroupMemberException, LastGroupAdminException, UnregisteredRecipientException {
|
||||||
final var newAdmins = recipientHelper.resolveRecipients(groupAdmins);
|
final var newAdmins = recipientHelper.resolveRecipients(groupAdmins);
|
||||||
return groupHelper.quitGroup(groupId, newAdmins);
|
return groupHelper.quitGroup(groupId, newAdmins);
|
||||||
}
|
}
|
||||||
|
@ -569,7 +569,7 @@ public class ManagerImpl implements Manager {
|
||||||
@Override
|
@Override
|
||||||
public Pair<GroupId, SendGroupMessageResults> createGroup(
|
public Pair<GroupId, SendGroupMessageResults> createGroup(
|
||||||
String name, Set<RecipientIdentifier.Single> members, File avatarFile
|
String name, Set<RecipientIdentifier.Single> members, File avatarFile
|
||||||
) throws IOException, AttachmentInvalidException {
|
) throws IOException, AttachmentInvalidException, UnregisteredRecipientException {
|
||||||
return groupHelper.createGroup(name,
|
return groupHelper.createGroup(name,
|
||||||
members == null ? null : recipientHelper.resolveRecipients(members),
|
members == null ? null : recipientHelper.resolveRecipients(members),
|
||||||
avatarFile);
|
avatarFile);
|
||||||
|
@ -578,7 +578,7 @@ public class ManagerImpl implements Manager {
|
||||||
@Override
|
@Override
|
||||||
public SendGroupMessageResults updateGroup(
|
public SendGroupMessageResults updateGroup(
|
||||||
final GroupId groupId, final UpdateGroup updateGroup
|
final GroupId groupId, final UpdateGroup updateGroup
|
||||||
) throws IOException, GroupNotFoundException, AttachmentInvalidException, NotAGroupMemberException, GroupSendingNotAllowedException {
|
) throws IOException, GroupNotFoundException, AttachmentInvalidException, NotAGroupMemberException, GroupSendingNotAllowedException, UnregisteredRecipientException {
|
||||||
return groupHelper.updateGroup(groupId,
|
return groupHelper.updateGroup(groupId,
|
||||||
updateGroup.getName(),
|
updateGroup.getName(),
|
||||||
updateGroup.getDescription(),
|
updateGroup.getDescription(),
|
||||||
|
@ -614,12 +614,17 @@ public class ManagerImpl implements Manager {
|
||||||
messageBuilder.withTimestamp(timestamp);
|
messageBuilder.withTimestamp(timestamp);
|
||||||
for (final var recipient : recipients) {
|
for (final var recipient : recipients) {
|
||||||
if (recipient instanceof RecipientIdentifier.Single single) {
|
if (recipient instanceof RecipientIdentifier.Single single) {
|
||||||
final var recipientId = recipientHelper.resolveRecipient(single);
|
try {
|
||||||
final var result = sendHelper.sendMessage(messageBuilder, recipientId);
|
final var recipientId = recipientHelper.resolveRecipient(single);
|
||||||
results.put(recipient,
|
final var result = sendHelper.sendMessage(messageBuilder, recipientId);
|
||||||
List.of(SendMessageResult.from(result,
|
results.put(recipient,
|
||||||
account.getRecipientStore(),
|
List.of(SendMessageResult.from(result,
|
||||||
account.getRecipientStore()::resolveRecipientAddress)));
|
account.getRecipientStore(),
|
||||||
|
account.getRecipientStore()::resolveRecipientAddress)));
|
||||||
|
} catch (UnregisteredRecipientException e) {
|
||||||
|
results.put(recipient,
|
||||||
|
List.of(SendMessageResult.unregisteredFailure(single.toPartialRecipientAddress())));
|
||||||
|
}
|
||||||
} else if (recipient instanceof RecipientIdentifier.NoteToSelf) {
|
} else if (recipient instanceof RecipientIdentifier.NoteToSelf) {
|
||||||
final var result = sendHelper.sendSelfMessage(messageBuilder);
|
final var result = sendHelper.sendSelfMessage(messageBuilder);
|
||||||
results.put(recipient,
|
results.put(recipient,
|
||||||
|
@ -645,14 +650,19 @@ public class ManagerImpl implements Manager {
|
||||||
var results = new HashMap<RecipientIdentifier, List<SendMessageResult>>();
|
var results = new HashMap<RecipientIdentifier, List<SendMessageResult>>();
|
||||||
final var timestamp = System.currentTimeMillis();
|
final var timestamp = System.currentTimeMillis();
|
||||||
for (var recipient : recipients) {
|
for (var recipient : recipients) {
|
||||||
if (recipient instanceof RecipientIdentifier.Single) {
|
if (recipient instanceof RecipientIdentifier.Single single) {
|
||||||
final var message = new SignalServiceTypingMessage(action, timestamp, Optional.absent());
|
final var message = new SignalServiceTypingMessage(action, timestamp, Optional.absent());
|
||||||
final var recipientId = recipientHelper.resolveRecipient((RecipientIdentifier.Single) recipient);
|
try {
|
||||||
final var result = sendHelper.sendTypingMessage(message, recipientId);
|
final var recipientId = recipientHelper.resolveRecipient(single);
|
||||||
results.put(recipient,
|
final var result = sendHelper.sendTypingMessage(message, recipientId);
|
||||||
List.of(SendMessageResult.from(result,
|
results.put(recipient,
|
||||||
account.getRecipientStore(),
|
List.of(SendMessageResult.from(result,
|
||||||
account.getRecipientStore()::resolveRecipientAddress)));
|
account.getRecipientStore(),
|
||||||
|
account.getRecipientStore()::resolveRecipientAddress)));
|
||||||
|
} catch (UnregisteredRecipientException e) {
|
||||||
|
results.put(recipient,
|
||||||
|
List.of(SendMessageResult.unregisteredFailure(single.toPartialRecipientAddress())));
|
||||||
|
}
|
||||||
} else if (recipient instanceof RecipientIdentifier.Group) {
|
} else if (recipient instanceof RecipientIdentifier.Group) {
|
||||||
final var groupId = ((RecipientIdentifier.Group) recipient).groupId();
|
final var groupId = ((RecipientIdentifier.Group) recipient).groupId();
|
||||||
final var message = new SignalServiceTypingMessage(action, timestamp, Optional.of(groupId.serialize()));
|
final var message = new SignalServiceTypingMessage(action, timestamp, Optional.of(groupId.serialize()));
|
||||||
|
@ -684,12 +694,7 @@ public class ManagerImpl implements Manager {
|
||||||
messageIds,
|
messageIds,
|
||||||
timestamp);
|
timestamp);
|
||||||
|
|
||||||
final var result = sendHelper.sendReceiptMessage(receiptMessage, recipientHelper.resolveRecipient(sender));
|
return sendReceiptMessage(sender, timestamp, receiptMessage);
|
||||||
return new SendMessageResults(timestamp,
|
|
||||||
Map.of(sender,
|
|
||||||
List.of(SendMessageResult.from(result,
|
|
||||||
account.getRecipientStore(),
|
|
||||||
account.getRecipientStore()::resolveRecipientAddress))));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -701,18 +706,31 @@ public class ManagerImpl implements Manager {
|
||||||
messageIds,
|
messageIds,
|
||||||
timestamp);
|
timestamp);
|
||||||
|
|
||||||
final var result = sendHelper.sendReceiptMessage(receiptMessage, recipientHelper.resolveRecipient(sender));
|
return sendReceiptMessage(sender, timestamp, receiptMessage);
|
||||||
return new SendMessageResults(timestamp,
|
}
|
||||||
Map.of(sender,
|
|
||||||
List.of(SendMessageResult.from(result,
|
private SendMessageResults sendReceiptMessage(
|
||||||
account.getRecipientStore(),
|
final RecipientIdentifier.Single sender,
|
||||||
account.getRecipientStore()::resolveRecipientAddress))));
|
final long timestamp,
|
||||||
|
final SignalServiceReceiptMessage receiptMessage
|
||||||
|
) throws IOException {
|
||||||
|
try {
|
||||||
|
final var result = sendHelper.sendReceiptMessage(receiptMessage, recipientHelper.resolveRecipient(sender));
|
||||||
|
return new SendMessageResults(timestamp,
|
||||||
|
Map.of(sender,
|
||||||
|
List.of(SendMessageResult.from(result,
|
||||||
|
account.getRecipientStore(),
|
||||||
|
account.getRecipientStore()::resolveRecipientAddress))));
|
||||||
|
} catch (UnregisteredRecipientException e) {
|
||||||
|
return new SendMessageResults(timestamp,
|
||||||
|
Map.of(sender, List.of(SendMessageResult.unregisteredFailure(sender.toPartialRecipientAddress()))));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SendMessageResults sendMessage(
|
public SendMessageResults sendMessage(
|
||||||
Message message, Set<RecipientIdentifier> recipients
|
Message message, Set<RecipientIdentifier> recipients
|
||||||
) throws IOException, AttachmentInvalidException, NotAGroupMemberException, GroupNotFoundException, GroupSendingNotAllowedException {
|
) throws IOException, AttachmentInvalidException, NotAGroupMemberException, GroupNotFoundException, GroupSendingNotAllowedException, UnregisteredRecipientException {
|
||||||
final var messageBuilder = SignalServiceDataMessage.newBuilder();
|
final var messageBuilder = SignalServiceDataMessage.newBuilder();
|
||||||
applyMessage(messageBuilder, message);
|
applyMessage(messageBuilder, message);
|
||||||
return sendMessage(messageBuilder, recipients);
|
return sendMessage(messageBuilder, recipients);
|
||||||
|
@ -720,7 +738,7 @@ public class ManagerImpl implements Manager {
|
||||||
|
|
||||||
private void applyMessage(
|
private void applyMessage(
|
||||||
final SignalServiceDataMessage.Builder messageBuilder, final Message message
|
final SignalServiceDataMessage.Builder messageBuilder, final Message message
|
||||||
) throws AttachmentInvalidException, IOException {
|
) throws AttachmentInvalidException, IOException, UnregisteredRecipientException {
|
||||||
messageBuilder.withBody(message.messageText());
|
messageBuilder.withBody(message.messageText());
|
||||||
final var attachments = message.attachments();
|
final var attachments = message.attachments();
|
||||||
if (attachments != null) {
|
if (attachments != null) {
|
||||||
|
@ -739,7 +757,7 @@ public class ManagerImpl implements Manager {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private ArrayList<SignalServiceDataMessage.Mention> resolveMentions(final List<Message.Mention> mentionList) throws IOException {
|
private ArrayList<SignalServiceDataMessage.Mention> resolveMentions(final List<Message.Mention> mentionList) throws IOException, UnregisteredRecipientException {
|
||||||
final var mentions = new ArrayList<SignalServiceDataMessage.Mention>();
|
final var mentions = new ArrayList<SignalServiceDataMessage.Mention>();
|
||||||
for (final var m : mentionList) {
|
for (final var m : mentionList) {
|
||||||
final var recipientId = recipientHelper.resolveRecipient(m.recipient());
|
final var recipientId = recipientHelper.resolveRecipient(m.recipient());
|
||||||
|
@ -765,7 +783,7 @@ public class ManagerImpl implements Manager {
|
||||||
RecipientIdentifier.Single targetAuthor,
|
RecipientIdentifier.Single targetAuthor,
|
||||||
long targetSentTimestamp,
|
long targetSentTimestamp,
|
||||||
Set<RecipientIdentifier> recipients
|
Set<RecipientIdentifier> recipients
|
||||||
) throws IOException, NotAGroupMemberException, GroupNotFoundException, GroupSendingNotAllowedException {
|
) throws IOException, NotAGroupMemberException, GroupNotFoundException, GroupSendingNotAllowedException, UnregisteredRecipientException {
|
||||||
var targetAuthorRecipientId = recipientHelper.resolveRecipient(targetAuthor);
|
var targetAuthorRecipientId = recipientHelper.resolveRecipient(targetAuthor);
|
||||||
var reaction = new SignalServiceDataMessage.Reaction(emoji,
|
var reaction = new SignalServiceDataMessage.Reaction(emoji,
|
||||||
remove,
|
remove,
|
||||||
|
@ -786,26 +804,32 @@ public class ManagerImpl implements Manager {
|
||||||
throw new AssertionError(e);
|
throw new AssertionError(e);
|
||||||
} finally {
|
} finally {
|
||||||
for (var recipient : recipients) {
|
for (var recipient : recipients) {
|
||||||
final var recipientId = recipientHelper.resolveRecipient(recipient);
|
final RecipientId recipientId;
|
||||||
|
try {
|
||||||
|
recipientId = recipientHelper.resolveRecipient(recipient);
|
||||||
|
} catch (UnregisteredRecipientException e) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
account.getSessionStore().deleteAllSessions(recipientId);
|
account.getSessionStore().deleteAllSessions(recipientId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void deleteRecipient(final RecipientIdentifier.Single recipient) throws IOException {
|
public void deleteRecipient(final RecipientIdentifier.Single recipient) {
|
||||||
account.removeRecipient(recipientHelper.resolveRecipient(recipient));
|
account.removeRecipient(account.getRecipientStore().resolveRecipient(recipient.toPartialRecipientAddress()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void deleteContact(final RecipientIdentifier.Single recipient) throws IOException {
|
public void deleteContact(final RecipientIdentifier.Single recipient) {
|
||||||
account.getContactStore().deleteContact(recipientHelper.resolveRecipient(recipient));
|
account.getContactStore()
|
||||||
|
.deleteContact(account.getRecipientStore().resolveRecipient(recipient.toPartialRecipientAddress()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setContactName(
|
public void setContactName(
|
||||||
RecipientIdentifier.Single recipient, String name
|
RecipientIdentifier.Single recipient, String name
|
||||||
) throws NotMasterDeviceException, IOException {
|
) throws NotMasterDeviceException, IOException, UnregisteredRecipientException {
|
||||||
if (!account.isMasterDevice()) {
|
if (!account.isMasterDevice()) {
|
||||||
throw new NotMasterDeviceException();
|
throw new NotMasterDeviceException();
|
||||||
}
|
}
|
||||||
|
@ -815,12 +839,12 @@ public class ManagerImpl implements Manager {
|
||||||
@Override
|
@Override
|
||||||
public void setContactBlocked(
|
public void setContactBlocked(
|
||||||
RecipientIdentifier.Single recipient, boolean blocked
|
RecipientIdentifier.Single recipient, boolean blocked
|
||||||
) throws NotMasterDeviceException, IOException {
|
) throws NotMasterDeviceException, IOException, UnregisteredRecipientException {
|
||||||
if (!account.isMasterDevice()) {
|
if (!account.isMasterDevice()) {
|
||||||
throw new NotMasterDeviceException();
|
throw new NotMasterDeviceException();
|
||||||
}
|
}
|
||||||
contactHelper.setContactBlocked(recipientHelper.resolveRecipient(recipient), blocked);
|
contactHelper.setContactBlocked(recipientHelper.resolveRecipient(recipient), blocked);
|
||||||
// TODO cycle our profile key
|
// TODO cycle our profile key, if we're not together in a group with recipient
|
||||||
syncHelper.sendBlockedList();
|
syncHelper.sendBlockedList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -842,7 +866,7 @@ public class ManagerImpl implements Manager {
|
||||||
@Override
|
@Override
|
||||||
public void setExpirationTimer(
|
public void setExpirationTimer(
|
||||||
RecipientIdentifier.Single recipient, int messageExpirationTimer
|
RecipientIdentifier.Single recipient, int messageExpirationTimer
|
||||||
) throws IOException {
|
) throws IOException, UnregisteredRecipientException {
|
||||||
var recipientId = recipientHelper.resolveRecipient(recipient);
|
var recipientId = recipientHelper.resolveRecipient(recipient);
|
||||||
contactHelper.setExpirationTimer(recipientId, messageExpirationTimer);
|
contactHelper.setExpirationTimer(recipientId, messageExpirationTimer);
|
||||||
final var messageBuilder = SignalServiceDataMessage.newBuilder().asExpirationUpdate();
|
final var messageBuilder = SignalServiceDataMessage.newBuilder().asExpirationUpdate();
|
||||||
|
@ -1095,9 +1119,8 @@ public class ManagerImpl implements Manager {
|
||||||
logger.debug("Checking for new message from server");
|
logger.debug("Checking for new message from server");
|
||||||
try {
|
try {
|
||||||
var result = signalWebSocket.readOrEmpty(timeout.toMillis(), envelope1 -> {
|
var result = signalWebSocket.readOrEmpty(timeout.toMillis(), envelope1 -> {
|
||||||
final var recipientId = envelope1.hasSourceUuid()
|
final var recipientId = envelope1.hasSourceUuid() ? account.getRecipientStore()
|
||||||
? resolveRecipient(envelope1.getSourceAddress())
|
.resolveRecipient(envelope1.getSourceAddress()) : null;
|
||||||
: null;
|
|
||||||
// store message on disk, before acknowledging receipt to the server
|
// store message on disk, before acknowledging receipt to the server
|
||||||
cachedMessage[0] = account.getMessageCache().cacheMessage(envelope1, recipientId);
|
cachedMessage[0] = account.getMessageCache().cacheMessage(envelope1, recipientId);
|
||||||
});
|
});
|
||||||
|
@ -1234,7 +1257,7 @@ public class ManagerImpl implements Manager {
|
||||||
final RecipientId recipientId;
|
final RecipientId recipientId;
|
||||||
try {
|
try {
|
||||||
recipientId = recipientHelper.resolveRecipient(recipient);
|
recipientId = recipientHelper.resolveRecipient(recipient);
|
||||||
} catch (IOException e) {
|
} catch (IOException | UnregisteredRecipientException e) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return contactHelper.isContactBlocked(recipientId);
|
return contactHelper.isContactBlocked(recipientId);
|
||||||
|
@ -1259,7 +1282,7 @@ public class ManagerImpl implements Manager {
|
||||||
final RecipientId recipientId;
|
final RecipientId recipientId;
|
||||||
try {
|
try {
|
||||||
recipientId = recipientHelper.resolveRecipient(recipient);
|
recipientId = recipientHelper.resolveRecipient(recipient);
|
||||||
} catch (IOException e) {
|
} catch (IOException | UnregisteredRecipientException e) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1268,7 +1291,7 @@ public class ManagerImpl implements Manager {
|
||||||
return contact.getName();
|
return contact.getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
final var profile = getRecipientProfile(recipientId);
|
final var profile = profileHelper.getRecipientProfile(recipientId);
|
||||||
if (profile != null) {
|
if (profile != null) {
|
||||||
return profile.getDisplayName();
|
return profile.getDisplayName();
|
||||||
}
|
}
|
||||||
|
@ -1311,7 +1334,7 @@ public class ManagerImpl implements Manager {
|
||||||
IdentityInfo identity;
|
IdentityInfo identity;
|
||||||
try {
|
try {
|
||||||
identity = account.getIdentityKeyStore().getIdentity(recipientHelper.resolveRecipient(recipient));
|
identity = account.getIdentityKeyStore().getIdentity(recipientHelper.resolveRecipient(recipient));
|
||||||
} catch (IOException e) {
|
} catch (IOException | UnregisteredRecipientException e) {
|
||||||
identity = null;
|
identity = null;
|
||||||
}
|
}
|
||||||
return identity == null ? List.of() : List.of(toIdentity(identity));
|
return identity == null ? List.of() : List.of(toIdentity(identity));
|
||||||
|
@ -1324,7 +1347,9 @@ public class ManagerImpl implements Manager {
|
||||||
* @param fingerprint Fingerprint
|
* @param fingerprint Fingerprint
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean trustIdentityVerified(RecipientIdentifier.Single recipient, byte[] fingerprint) {
|
public boolean trustIdentityVerified(
|
||||||
|
RecipientIdentifier.Single recipient, byte[] fingerprint
|
||||||
|
) throws UnregisteredRecipientException {
|
||||||
RecipientId recipientId;
|
RecipientId recipientId;
|
||||||
try {
|
try {
|
||||||
recipientId = recipientHelper.resolveRecipient(recipient);
|
recipientId = recipientHelper.resolveRecipient(recipient);
|
||||||
|
@ -1345,7 +1370,9 @@ public class ManagerImpl implements Manager {
|
||||||
* @param safetyNumber Safety number
|
* @param safetyNumber Safety number
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean trustIdentityVerifiedSafetyNumber(RecipientIdentifier.Single recipient, String safetyNumber) {
|
public boolean trustIdentityVerifiedSafetyNumber(
|
||||||
|
RecipientIdentifier.Single recipient, String safetyNumber
|
||||||
|
) throws UnregisteredRecipientException {
|
||||||
RecipientId recipientId;
|
RecipientId recipientId;
|
||||||
try {
|
try {
|
||||||
recipientId = recipientHelper.resolveRecipient(recipient);
|
recipientId = recipientHelper.resolveRecipient(recipient);
|
||||||
|
@ -1366,7 +1393,9 @@ public class ManagerImpl implements Manager {
|
||||||
* @param safetyNumber Scannable safety number
|
* @param safetyNumber Scannable safety number
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean trustIdentityVerifiedSafetyNumber(RecipientIdentifier.Single recipient, byte[] safetyNumber) {
|
public boolean trustIdentityVerifiedSafetyNumber(
|
||||||
|
RecipientIdentifier.Single recipient, byte[] safetyNumber
|
||||||
|
) throws UnregisteredRecipientException {
|
||||||
RecipientId recipientId;
|
RecipientId recipientId;
|
||||||
try {
|
try {
|
||||||
recipientId = recipientHelper.resolveRecipient(recipient);
|
recipientId = recipientHelper.resolveRecipient(recipient);
|
||||||
|
@ -1386,7 +1415,7 @@ public class ManagerImpl implements Manager {
|
||||||
* @param recipient account of the identity
|
* @param recipient account of the identity
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean trustIdentityAllKeys(RecipientIdentifier.Single recipient) {
|
public boolean trustIdentityAllKeys(RecipientIdentifier.Single recipient) throws UnregisteredRecipientException {
|
||||||
RecipientId recipientId;
|
RecipientId recipientId;
|
||||||
try {
|
try {
|
||||||
recipientId = recipientHelper.resolveRecipient(recipient);
|
recipientId = recipientHelper.resolveRecipient(recipient);
|
||||||
|
@ -1414,10 +1443,6 @@ public class ManagerImpl implements Manager {
|
||||||
this.identityHelper.handleIdentityFailure(recipientId, identityFailure);
|
this.identityHelper.handleIdentityFailure(recipientId, identityFailure);
|
||||||
}
|
}
|
||||||
|
|
||||||
private RecipientId resolveRecipient(SignalServiceAddress address) {
|
|
||||||
return account.getRecipientStore().resolveRecipient(address);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void close() throws IOException {
|
public void close() throws IOException {
|
||||||
Thread thread;
|
Thread thread;
|
||||||
|
|
|
@ -50,6 +50,8 @@ public sealed interface RecipientIdentifier {
|
||||||
}
|
}
|
||||||
throw new AssertionError("RecipientAddress without identifier");
|
throw new AssertionError("RecipientAddress without identifier");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
RecipientAddress toPartialRecipientAddress();
|
||||||
}
|
}
|
||||||
|
|
||||||
record Uuid(UUID uuid) implements Single {
|
record Uuid(UUID uuid) implements Single {
|
||||||
|
@ -58,6 +60,11 @@ public sealed interface RecipientIdentifier {
|
||||||
public String getIdentifier() {
|
public String getIdentifier() {
|
||||||
return uuid.toString();
|
return uuid.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public RecipientAddress toPartialRecipientAddress() {
|
||||||
|
return new RecipientAddress(uuid);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
record Number(String number) implements Single {
|
record Number(String number) implements Single {
|
||||||
|
@ -66,6 +73,11 @@ public sealed interface RecipientIdentifier {
|
||||||
public String getIdentifier() {
|
public String getIdentifier() {
|
||||||
return number;
|
return number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public RecipientAddress toPartialRecipientAddress() {
|
||||||
|
return new RecipientAddress(null, number);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
record Group(GroupId groupId) implements RecipientIdentifier {
|
record Group(GroupId groupId) implements RecipientIdentifier {
|
||||||
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
package org.asamk.signal.manager.api;
|
||||||
|
|
||||||
|
import org.asamk.signal.manager.storage.recipients.RecipientAddress;
|
||||||
|
|
||||||
|
public class UnregisteredRecipientException extends Exception {
|
||||||
|
|
||||||
|
private final RecipientAddress sender;
|
||||||
|
|
||||||
|
public UnregisteredRecipientException(final RecipientAddress sender) {
|
||||||
|
super("Unregistered user: " + sender.getIdentifier());
|
||||||
|
this.sender = sender;
|
||||||
|
}
|
||||||
|
|
||||||
|
public RecipientAddress getSender() {
|
||||||
|
return sender;
|
||||||
|
}
|
||||||
|
}
|
|
@ -2,16 +2,17 @@ package org.asamk.signal.manager.helper;
|
||||||
|
|
||||||
import org.asamk.signal.manager.SignalDependencies;
|
import org.asamk.signal.manager.SignalDependencies;
|
||||||
import org.asamk.signal.manager.api.RecipientIdentifier;
|
import org.asamk.signal.manager.api.RecipientIdentifier;
|
||||||
|
import org.asamk.signal.manager.api.UnregisteredRecipientException;
|
||||||
import org.asamk.signal.manager.config.ServiceConfig;
|
import org.asamk.signal.manager.config.ServiceConfig;
|
||||||
import org.asamk.signal.manager.config.ServiceEnvironmentConfig;
|
import org.asamk.signal.manager.config.ServiceEnvironmentConfig;
|
||||||
import org.asamk.signal.manager.storage.SignalAccount;
|
import org.asamk.signal.manager.storage.SignalAccount;
|
||||||
|
import org.asamk.signal.manager.storage.recipients.RecipientAddress;
|
||||||
import org.asamk.signal.manager.storage.recipients.RecipientId;
|
import org.asamk.signal.manager.storage.recipients.RecipientId;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.whispersystems.libsignal.InvalidKeyException;
|
import org.whispersystems.libsignal.InvalidKeyException;
|
||||||
import org.whispersystems.signalservice.api.push.ACI;
|
import org.whispersystems.signalservice.api.push.ACI;
|
||||||
import org.whispersystems.signalservice.api.push.SignalServiceAddress;
|
import org.whispersystems.signalservice.api.push.SignalServiceAddress;
|
||||||
import org.whispersystems.signalservice.api.push.exceptions.UnregisteredUserException;
|
|
||||||
import org.whispersystems.signalservice.internal.contacts.crypto.Quote;
|
import org.whispersystems.signalservice.internal.contacts.crypto.Quote;
|
||||||
import org.whispersystems.signalservice.internal.contacts.crypto.UnauthenticatedQuoteException;
|
import org.whispersystems.signalservice.internal.contacts.crypto.UnauthenticatedQuoteException;
|
||||||
import org.whispersystems.signalservice.internal.contacts.crypto.UnauthenticatedResponseException;
|
import org.whispersystems.signalservice.internal.contacts.crypto.UnauthenticatedResponseException;
|
||||||
|
@ -53,7 +54,7 @@ public class RecipientHelper {
|
||||||
final ACI aci;
|
final ACI aci;
|
||||||
try {
|
try {
|
||||||
aci = getRegisteredUser(number);
|
aci = getRegisteredUser(number);
|
||||||
} catch (IOException e) {
|
} catch (UnregisteredRecipientException | IOException e) {
|
||||||
logger.warn("Failed to get uuid for e164 number: {}", number, e);
|
logger.warn("Failed to get uuid for e164 number: {}", number, e);
|
||||||
// Return SignalServiceAddress with unknown UUID
|
// Return SignalServiceAddress with unknown UUID
|
||||||
return address.toSignalServiceAddress();
|
return address.toSignalServiceAddress();
|
||||||
|
@ -63,7 +64,7 @@ public class RecipientHelper {
|
||||||
.toSignalServiceAddress();
|
.toSignalServiceAddress();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Set<RecipientId> resolveRecipients(Collection<RecipientIdentifier.Single> recipients) throws IOException {
|
public Set<RecipientId> resolveRecipients(Collection<RecipientIdentifier.Single> recipients) throws IOException, UnregisteredRecipientException {
|
||||||
final var recipientIds = new HashSet<RecipientId>(recipients.size());
|
final var recipientIds = new HashSet<RecipientId>(recipients.size());
|
||||||
for (var number : recipients) {
|
for (var number : recipients) {
|
||||||
final var recipientId = resolveRecipient(number);
|
final var recipientId = resolveRecipient(number);
|
||||||
|
@ -72,7 +73,7 @@ public class RecipientHelper {
|
||||||
return recipientIds;
|
return recipientIds;
|
||||||
}
|
}
|
||||||
|
|
||||||
public RecipientId resolveRecipient(final RecipientIdentifier.Single recipient) throws IOException {
|
public RecipientId resolveRecipient(final RecipientIdentifier.Single recipient) throws IOException, UnregisteredRecipientException {
|
||||||
if (recipient instanceof RecipientIdentifier.Uuid uuidRecipient) {
|
if (recipient instanceof RecipientIdentifier.Uuid uuidRecipient) {
|
||||||
return account.getRecipientStore().resolveRecipient(ACI.from(uuidRecipient.uuid()));
|
return account.getRecipientStore().resolveRecipient(ACI.from(uuidRecipient.uuid()));
|
||||||
} else {
|
} else {
|
||||||
|
@ -80,14 +81,14 @@ public class RecipientHelper {
|
||||||
return account.getRecipientStore().resolveRecipient(number, () -> {
|
return account.getRecipientStore().resolveRecipient(number, () -> {
|
||||||
try {
|
try {
|
||||||
return getRegisteredUser(number);
|
return getRegisteredUser(number);
|
||||||
} catch (IOException e) {
|
} catch (Exception e) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public RecipientId refreshRegisteredUser(RecipientId recipientId) throws IOException {
|
public RecipientId refreshRegisteredUser(RecipientId recipientId) throws IOException, UnregisteredRecipientException {
|
||||||
final var address = resolveSignalServiceAddress(recipientId);
|
final var address = resolveSignalServiceAddress(recipientId);
|
||||||
if (!address.getNumber().isPresent()) {
|
if (!address.getNumber().isPresent()) {
|
||||||
return recipientId;
|
return recipientId;
|
||||||
|
@ -115,16 +116,16 @@ public class RecipientHelper {
|
||||||
return registeredUsers;
|
return registeredUsers;
|
||||||
}
|
}
|
||||||
|
|
||||||
private ACI getRegisteredUser(final String number) throws IOException {
|
private ACI getRegisteredUser(final String number) throws IOException, UnregisteredRecipientException {
|
||||||
final Map<String, ACI> aciMap;
|
final Map<String, ACI> aciMap;
|
||||||
try {
|
try {
|
||||||
aciMap = getRegisteredUsers(Set.of(number));
|
aciMap = getRegisteredUsers(Set.of(number));
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
throw new UnregisteredUserException(number, e);
|
throw new UnregisteredRecipientException(new RecipientAddress(null, number));
|
||||||
}
|
}
|
||||||
final var uuid = aciMap.get(number);
|
final var uuid = aciMap.get(number);
|
||||||
if (uuid == null) {
|
if (uuid == null) {
|
||||||
throw new UnregisteredUserException(number, null);
|
throw new UnregisteredRecipientException(new RecipientAddress(null, number));
|
||||||
}
|
}
|
||||||
return uuid;
|
return uuid;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,11 @@
|
||||||
package org.asamk.signal.manager.helper;
|
package org.asamk.signal.manager.helper;
|
||||||
|
|
||||||
|
import org.asamk.signal.manager.api.UnregisteredRecipientException;
|
||||||
import org.asamk.signal.manager.storage.recipients.RecipientId;
|
import org.asamk.signal.manager.storage.recipients.RecipientId;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
public interface RecipientRegistrationRefresher {
|
public interface RecipientRegistrationRefresher {
|
||||||
|
|
||||||
RecipientId refreshRecipientRegistration(RecipientId recipientId) throws IOException;
|
RecipientId refreshRecipientRegistration(RecipientId recipientId) throws IOException, UnregisteredRecipientException;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package org.asamk.signal.manager.helper;
|
package org.asamk.signal.manager.helper;
|
||||||
|
|
||||||
import org.asamk.signal.manager.SignalDependencies;
|
import org.asamk.signal.manager.SignalDependencies;
|
||||||
|
import org.asamk.signal.manager.api.UnregisteredRecipientException;
|
||||||
import org.asamk.signal.manager.groups.GroupId;
|
import org.asamk.signal.manager.groups.GroupId;
|
||||||
import org.asamk.signal.manager.groups.GroupNotFoundException;
|
import org.asamk.signal.manager.groups.GroupNotFoundException;
|
||||||
import org.asamk.signal.manager.groups.GroupSendingNotAllowedException;
|
import org.asamk.signal.manager.groups.GroupSendingNotAllowedException;
|
||||||
|
@ -494,7 +495,12 @@ public class SendHelper {
|
||||||
try {
|
try {
|
||||||
return s.send(messageSender, address, unidentifiedAccessHelper.getAccessFor(recipientId));
|
return s.send(messageSender, address, unidentifiedAccessHelper.getAccessFor(recipientId));
|
||||||
} catch (UnregisteredUserException e) {
|
} catch (UnregisteredUserException e) {
|
||||||
final var newRecipientId = recipientRegistrationRefresher.refreshRecipientRegistration(recipientId);
|
final RecipientId newRecipientId;
|
||||||
|
try {
|
||||||
|
newRecipientId = recipientRegistrationRefresher.refreshRecipientRegistration(recipientId);
|
||||||
|
} catch (UnregisteredRecipientException ex) {
|
||||||
|
return SendMessageResult.unregisteredFailure(address);
|
||||||
|
}
|
||||||
address = addressResolver.resolveSignalServiceAddress(newRecipientId);
|
address = addressResolver.resolveSignalServiceAddress(newRecipientId);
|
||||||
return s.send(messageSender, address, unidentifiedAccessHelper.getAccessFor(newRecipientId));
|
return s.send(messageSender, address, unidentifiedAccessHelper.getAccessFor(newRecipientId));
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@ package org.asamk.signal.manager.storage.recipients;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
|
||||||
import org.asamk.signal.manager.api.Pair;
|
import org.asamk.signal.manager.api.Pair;
|
||||||
|
import org.asamk.signal.manager.api.UnregisteredRecipientException;
|
||||||
import org.asamk.signal.manager.storage.Utils;
|
import org.asamk.signal.manager.storage.Utils;
|
||||||
import org.asamk.signal.manager.storage.contacts.ContactsStore;
|
import org.asamk.signal.manager.storage.contacts.ContactsStore;
|
||||||
import org.asamk.signal.manager.storage.profiles.ProfileStore;
|
import org.asamk.signal.manager.storage.profiles.ProfileStore;
|
||||||
|
@ -13,7 +14,6 @@ import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.whispersystems.signalservice.api.push.ACI;
|
import org.whispersystems.signalservice.api.push.ACI;
|
||||||
import org.whispersystems.signalservice.api.push.SignalServiceAddress;
|
import org.whispersystems.signalservice.api.push.SignalServiceAddress;
|
||||||
import org.whispersystems.signalservice.api.push.exceptions.UnregisteredUserException;
|
|
||||||
import org.whispersystems.signalservice.api.util.UuidUtil;
|
import org.whispersystems.signalservice.api.util.UuidUtil;
|
||||||
|
|
||||||
import java.io.ByteArrayInputStream;
|
import java.io.ByteArrayInputStream;
|
||||||
|
@ -144,7 +144,7 @@ public class RecipientStore implements RecipientResolver, ContactsStore, Profile
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public RecipientId resolveRecipient(ACI aci) {
|
public RecipientId resolveRecipient(ACI aci) {
|
||||||
return resolveRecipient(new RecipientAddress(aci == null ? null : aci.uuid()), false);
|
return resolveRecipient(new RecipientAddress(aci.uuid()), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -160,7 +160,7 @@ public class RecipientStore implements RecipientResolver, ContactsStore, Profile
|
||||||
|
|
||||||
public RecipientId resolveRecipient(
|
public RecipientId resolveRecipient(
|
||||||
final String number, Supplier<ACI> aciSupplier
|
final String number, Supplier<ACI> aciSupplier
|
||||||
) throws UnregisteredUserException {
|
) throws UnregisteredRecipientException {
|
||||||
final Optional<Recipient> byNumber;
|
final Optional<Recipient> byNumber;
|
||||||
synchronized (recipients) {
|
synchronized (recipients) {
|
||||||
byNumber = findByNumberLocked(number);
|
byNumber = findByNumberLocked(number);
|
||||||
|
@ -168,7 +168,7 @@ public class RecipientStore implements RecipientResolver, ContactsStore, Profile
|
||||||
if (byNumber.isEmpty() || byNumber.get().getAddress().uuid().isEmpty()) {
|
if (byNumber.isEmpty() || byNumber.get().getAddress().uuid().isEmpty()) {
|
||||||
final var aci = aciSupplier.get();
|
final var aci = aciSupplier.get();
|
||||||
if (aci == null) {
|
if (aci == null) {
|
||||||
throw new UnregisteredUserException(number, null);
|
throw new UnregisteredRecipientException(new RecipientAddress(null, number));
|
||||||
}
|
}
|
||||||
|
|
||||||
return resolveRecipient(new RecipientAddress(aci.uuid(), number), false);
|
return resolveRecipient(new RecipientAddress(aci.uuid(), number), false);
|
||||||
|
|
|
@ -615,5 +615,12 @@ public interface Signal extends DBusInterface {
|
||||||
super("Untrusted identity: " + message);
|
super("Untrusted identity: " + message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class UnregisteredRecipient extends DBusExecutionException {
|
||||||
|
|
||||||
|
public UnregisteredRecipient(final String message) {
|
||||||
|
super("Unregistered recipient: " + message);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,6 +8,7 @@ import org.asamk.signal.commands.exceptions.UnexpectedErrorException;
|
||||||
import org.asamk.signal.commands.exceptions.UserErrorException;
|
import org.asamk.signal.commands.exceptions.UserErrorException;
|
||||||
import org.asamk.signal.manager.Manager;
|
import org.asamk.signal.manager.Manager;
|
||||||
import org.asamk.signal.manager.NotMasterDeviceException;
|
import org.asamk.signal.manager.NotMasterDeviceException;
|
||||||
|
import org.asamk.signal.manager.api.UnregisteredRecipientException;
|
||||||
import org.asamk.signal.manager.groups.GroupNotFoundException;
|
import org.asamk.signal.manager.groups.GroupNotFoundException;
|
||||||
import org.asamk.signal.output.OutputWriter;
|
import org.asamk.signal.output.OutputWriter;
|
||||||
import org.asamk.signal.util.CommandUtil;
|
import org.asamk.signal.util.CommandUtil;
|
||||||
|
@ -44,6 +45,8 @@ public class BlockCommand implements JsonRpcLocalCommand {
|
||||||
throw new UserErrorException("This command doesn't work on linked devices.");
|
throw new UserErrorException("This command doesn't work on linked devices.");
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new UnexpectedErrorException("Failed to sync block to linked devices: " + e.getMessage(), e);
|
throw new UnexpectedErrorException("Failed to sync block to linked devices: " + e.getMessage(), e);
|
||||||
|
} catch (UnregisteredRecipientException e) {
|
||||||
|
throw new UserErrorException("The user " + e.getSender().getIdentifier() + " is not registered.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,7 @@ import org.asamk.signal.commands.exceptions.CommandException;
|
||||||
import org.asamk.signal.commands.exceptions.IOErrorException;
|
import org.asamk.signal.commands.exceptions.IOErrorException;
|
||||||
import org.asamk.signal.commands.exceptions.UserErrorException;
|
import org.asamk.signal.commands.exceptions.UserErrorException;
|
||||||
import org.asamk.signal.manager.Manager;
|
import org.asamk.signal.manager.Manager;
|
||||||
|
import org.asamk.signal.manager.api.UnregisteredRecipientException;
|
||||||
import org.asamk.signal.manager.groups.GroupNotFoundException;
|
import org.asamk.signal.manager.groups.GroupNotFoundException;
|
||||||
import org.asamk.signal.manager.groups.LastGroupAdminException;
|
import org.asamk.signal.manager.groups.LastGroupAdminException;
|
||||||
import org.asamk.signal.manager.groups.NotAGroupMemberException;
|
import org.asamk.signal.manager.groups.NotAGroupMemberException;
|
||||||
|
@ -70,6 +71,8 @@ public class QuitGroupCommand implements JsonRpcLocalCommand {
|
||||||
throw new UserErrorException("Failed to send to group: " + e.getMessage());
|
throw new UserErrorException("Failed to send to group: " + e.getMessage());
|
||||||
} catch (LastGroupAdminException e) {
|
} catch (LastGroupAdminException e) {
|
||||||
throw new UserErrorException("You need to specify a new admin with --admin: " + e.getMessage());
|
throw new UserErrorException("You need to specify a new admin with --admin: " + e.getMessage());
|
||||||
|
} catch (UnregisteredRecipientException e) {
|
||||||
|
throw new UserErrorException("The user " + e.getSender().getIdentifier() + " is not registered.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,13 +5,10 @@ import net.sourceforge.argparse4j.inf.Namespace;
|
||||||
import net.sourceforge.argparse4j.inf.Subparser;
|
import net.sourceforge.argparse4j.inf.Subparser;
|
||||||
|
|
||||||
import org.asamk.signal.commands.exceptions.CommandException;
|
import org.asamk.signal.commands.exceptions.CommandException;
|
||||||
import org.asamk.signal.commands.exceptions.IOErrorException;
|
|
||||||
import org.asamk.signal.manager.Manager;
|
import org.asamk.signal.manager.Manager;
|
||||||
import org.asamk.signal.output.OutputWriter;
|
import org.asamk.signal.output.OutputWriter;
|
||||||
import org.asamk.signal.util.CommandUtil;
|
import org.asamk.signal.util.CommandUtil;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
public class RemoveContactCommand implements JsonRpcLocalCommand {
|
public class RemoveContactCommand implements JsonRpcLocalCommand {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -36,14 +33,10 @@ public class RemoveContactCommand implements JsonRpcLocalCommand {
|
||||||
var recipient = CommandUtil.getSingleRecipientIdentifier(recipientString, m.getSelfNumber());
|
var recipient = CommandUtil.getSingleRecipientIdentifier(recipientString, m.getSelfNumber());
|
||||||
|
|
||||||
var forget = Boolean.TRUE == ns.getBoolean("forget");
|
var forget = Boolean.TRUE == ns.getBoolean("forget");
|
||||||
try {
|
if (forget) {
|
||||||
if (forget) {
|
m.deleteRecipient(recipient);
|
||||||
m.deleteRecipient(recipient);
|
} else {
|
||||||
} else {
|
m.deleteContact(recipient);
|
||||||
m.deleteContact(recipient);
|
|
||||||
}
|
|
||||||
} catch (IOException e) {
|
|
||||||
throw new IOErrorException("Remove contact error: " + e.getMessage(), e);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,6 +11,7 @@ import org.asamk.signal.manager.AttachmentInvalidException;
|
||||||
import org.asamk.signal.manager.Manager;
|
import org.asamk.signal.manager.Manager;
|
||||||
import org.asamk.signal.manager.api.Message;
|
import org.asamk.signal.manager.api.Message;
|
||||||
import org.asamk.signal.manager.api.RecipientIdentifier;
|
import org.asamk.signal.manager.api.RecipientIdentifier;
|
||||||
|
import org.asamk.signal.manager.api.UnregisteredRecipientException;
|
||||||
import org.asamk.signal.manager.groups.GroupNotFoundException;
|
import org.asamk.signal.manager.groups.GroupNotFoundException;
|
||||||
import org.asamk.signal.manager.groups.GroupSendingNotAllowedException;
|
import org.asamk.signal.manager.groups.GroupSendingNotAllowedException;
|
||||||
import org.asamk.signal.manager.groups.NotAGroupMemberException;
|
import org.asamk.signal.manager.groups.NotAGroupMemberException;
|
||||||
|
@ -143,6 +144,8 @@ public class SendCommand implements JsonRpcLocalCommand {
|
||||||
.getSimpleName() + ")", e);
|
.getSimpleName() + ")", e);
|
||||||
} catch (GroupNotFoundException | NotAGroupMemberException | GroupSendingNotAllowedException e) {
|
} catch (GroupNotFoundException | NotAGroupMemberException | GroupSendingNotAllowedException e) {
|
||||||
throw new UserErrorException(e.getMessage());
|
throw new UserErrorException(e.getMessage());
|
||||||
|
} catch (UnregisteredRecipientException e) {
|
||||||
|
throw new UserErrorException("The user " + e.getSender().getIdentifier() + " is not registered.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,7 @@ import org.asamk.signal.commands.exceptions.CommandException;
|
||||||
import org.asamk.signal.commands.exceptions.UnexpectedErrorException;
|
import org.asamk.signal.commands.exceptions.UnexpectedErrorException;
|
||||||
import org.asamk.signal.commands.exceptions.UserErrorException;
|
import org.asamk.signal.commands.exceptions.UserErrorException;
|
||||||
import org.asamk.signal.manager.Manager;
|
import org.asamk.signal.manager.Manager;
|
||||||
|
import org.asamk.signal.manager.api.UnregisteredRecipientException;
|
||||||
import org.asamk.signal.manager.groups.GroupNotFoundException;
|
import org.asamk.signal.manager.groups.GroupNotFoundException;
|
||||||
import org.asamk.signal.manager.groups.GroupSendingNotAllowedException;
|
import org.asamk.signal.manager.groups.GroupSendingNotAllowedException;
|
||||||
import org.asamk.signal.manager.groups.NotAGroupMemberException;
|
import org.asamk.signal.manager.groups.NotAGroupMemberException;
|
||||||
|
@ -76,6 +77,8 @@ public class SendReactionCommand implements JsonRpcLocalCommand {
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new UnexpectedErrorException("Failed to send message: " + e.getMessage() + " (" + e.getClass()
|
throw new UnexpectedErrorException("Failed to send message: " + e.getMessage() + " (" + e.getClass()
|
||||||
.getSimpleName() + ")", e);
|
.getSimpleName() + ")", e);
|
||||||
|
} catch (UnregisteredRecipientException e) {
|
||||||
|
throw new UserErrorException("The user " + e.getSender().getIdentifier() + " is not registered.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,7 @@ import net.sourceforge.argparse4j.inf.Subparser;
|
||||||
import org.asamk.signal.commands.exceptions.CommandException;
|
import org.asamk.signal.commands.exceptions.CommandException;
|
||||||
import org.asamk.signal.commands.exceptions.UserErrorException;
|
import org.asamk.signal.commands.exceptions.UserErrorException;
|
||||||
import org.asamk.signal.manager.Manager;
|
import org.asamk.signal.manager.Manager;
|
||||||
|
import org.asamk.signal.manager.api.UnregisteredRecipientException;
|
||||||
import org.asamk.signal.output.OutputWriter;
|
import org.asamk.signal.output.OutputWriter;
|
||||||
import org.asamk.signal.util.CommandUtil;
|
import org.asamk.signal.util.CommandUtil;
|
||||||
import org.asamk.signal.util.Hex;
|
import org.asamk.signal.util.Hex;
|
||||||
|
@ -40,7 +41,12 @@ public class TrustCommand implements JsonRpcLocalCommand {
|
||||||
var recipentString = ns.getString("recipient");
|
var recipentString = ns.getString("recipient");
|
||||||
var recipient = CommandUtil.getSingleRecipientIdentifier(recipentString, m.getSelfNumber());
|
var recipient = CommandUtil.getSingleRecipientIdentifier(recipentString, m.getSelfNumber());
|
||||||
if (Boolean.TRUE.equals(ns.getBoolean("trust-all-known-keys"))) {
|
if (Boolean.TRUE.equals(ns.getBoolean("trust-all-known-keys"))) {
|
||||||
boolean res = m.trustIdentityAllKeys(recipient);
|
boolean res;
|
||||||
|
try {
|
||||||
|
res = m.trustIdentityAllKeys(recipient);
|
||||||
|
} catch (UnregisteredRecipientException e) {
|
||||||
|
throw new UserErrorException("The user " + e.getSender().getIdentifier() + " is not registered.");
|
||||||
|
}
|
||||||
if (!res) {
|
if (!res) {
|
||||||
throw new UserErrorException("Failed to set the trust for this number, make sure the number is correct.");
|
throw new UserErrorException("Failed to set the trust for this number, make sure the number is correct.");
|
||||||
}
|
}
|
||||||
|
@ -60,13 +66,23 @@ public class TrustCommand implements JsonRpcLocalCommand {
|
||||||
throw new UserErrorException(
|
throw new UserErrorException(
|
||||||
"Failed to parse the fingerprint, make sure the fingerprint is a correctly encoded hex string without additional characters.");
|
"Failed to parse the fingerprint, make sure the fingerprint is a correctly encoded hex string without additional characters.");
|
||||||
}
|
}
|
||||||
boolean res = m.trustIdentityVerified(recipient, fingerprintBytes);
|
boolean res;
|
||||||
|
try {
|
||||||
|
res = m.trustIdentityVerified(recipient, fingerprintBytes);
|
||||||
|
} catch (UnregisteredRecipientException e) {
|
||||||
|
throw new UserErrorException("The user " + e.getSender().getIdentifier() + " is not registered.");
|
||||||
|
}
|
||||||
if (!res) {
|
if (!res) {
|
||||||
throw new UserErrorException(
|
throw new UserErrorException(
|
||||||
"Failed to set the trust for the fingerprint of this number, make sure the number and the fingerprint are correct.");
|
"Failed to set the trust for the fingerprint of this number, make sure the number and the fingerprint are correct.");
|
||||||
}
|
}
|
||||||
} else if (safetyNumber.length() == 60) {
|
} else if (safetyNumber.length() == 60) {
|
||||||
boolean res = m.trustIdentityVerifiedSafetyNumber(recipient, safetyNumber);
|
boolean res;
|
||||||
|
try {
|
||||||
|
res = m.trustIdentityVerifiedSafetyNumber(recipient, safetyNumber);
|
||||||
|
} catch (UnregisteredRecipientException e) {
|
||||||
|
throw new UserErrorException("The user " + e.getSender().getIdentifier() + " is not registered.");
|
||||||
|
}
|
||||||
if (!res) {
|
if (!res) {
|
||||||
throw new UserErrorException(
|
throw new UserErrorException(
|
||||||
"Failed to set the trust for the safety number of this phone number, make sure the phone number and the safety number are correct.");
|
"Failed to set the trust for the safety number of this phone number, make sure the phone number and the safety number are correct.");
|
||||||
|
@ -79,7 +95,12 @@ public class TrustCommand implements JsonRpcLocalCommand {
|
||||||
throw new UserErrorException(
|
throw new UserErrorException(
|
||||||
"Safety number has invalid format, either specify the old hex fingerprint or the new safety number");
|
"Safety number has invalid format, either specify the old hex fingerprint or the new safety number");
|
||||||
}
|
}
|
||||||
boolean res = m.trustIdentityVerifiedSafetyNumber(recipient, scannableSafetyNumber);
|
boolean res;
|
||||||
|
try {
|
||||||
|
res = m.trustIdentityVerifiedSafetyNumber(recipient, scannableSafetyNumber);
|
||||||
|
} catch (UnregisteredRecipientException e) {
|
||||||
|
throw new UserErrorException("The user " + e.getSender().getIdentifier() + " is not registered.");
|
||||||
|
}
|
||||||
if (!res) {
|
if (!res) {
|
||||||
throw new UserErrorException(
|
throw new UserErrorException(
|
||||||
"Failed to set the trust for the safety number of this phone number, make sure the phone number and the safety number are correct.");
|
"Failed to set the trust for the safety number of this phone number, make sure the phone number and the safety number are correct.");
|
||||||
|
|
|
@ -8,6 +8,7 @@ import org.asamk.signal.commands.exceptions.UnexpectedErrorException;
|
||||||
import org.asamk.signal.commands.exceptions.UserErrorException;
|
import org.asamk.signal.commands.exceptions.UserErrorException;
|
||||||
import org.asamk.signal.manager.Manager;
|
import org.asamk.signal.manager.Manager;
|
||||||
import org.asamk.signal.manager.NotMasterDeviceException;
|
import org.asamk.signal.manager.NotMasterDeviceException;
|
||||||
|
import org.asamk.signal.manager.api.UnregisteredRecipientException;
|
||||||
import org.asamk.signal.manager.groups.GroupNotFoundException;
|
import org.asamk.signal.manager.groups.GroupNotFoundException;
|
||||||
import org.asamk.signal.output.OutputWriter;
|
import org.asamk.signal.output.OutputWriter;
|
||||||
import org.asamk.signal.util.CommandUtil;
|
import org.asamk.signal.util.CommandUtil;
|
||||||
|
@ -44,6 +45,8 @@ public class UnblockCommand implements JsonRpcLocalCommand {
|
||||||
throw new UserErrorException("This command doesn't work on linked devices.");
|
throw new UserErrorException("This command doesn't work on linked devices.");
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new UnexpectedErrorException("Failed to sync unblock to linked devices: " + e.getMessage(), e);
|
throw new UnexpectedErrorException("Failed to sync unblock to linked devices: " + e.getMessage(), e);
|
||||||
|
} catch (UnregisteredRecipientException e) {
|
||||||
|
throw new UserErrorException("The user " + e.getSender().getIdentifier() + " is not registered.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,7 @@ import org.asamk.signal.commands.exceptions.IOErrorException;
|
||||||
import org.asamk.signal.commands.exceptions.UserErrorException;
|
import org.asamk.signal.commands.exceptions.UserErrorException;
|
||||||
import org.asamk.signal.manager.Manager;
|
import org.asamk.signal.manager.Manager;
|
||||||
import org.asamk.signal.manager.NotMasterDeviceException;
|
import org.asamk.signal.manager.NotMasterDeviceException;
|
||||||
|
import org.asamk.signal.manager.api.UnregisteredRecipientException;
|
||||||
import org.asamk.signal.output.OutputWriter;
|
import org.asamk.signal.output.OutputWriter;
|
||||||
import org.asamk.signal.util.CommandUtil;
|
import org.asamk.signal.util.CommandUtil;
|
||||||
|
|
||||||
|
@ -49,6 +50,8 @@ public class UpdateContactCommand implements JsonRpcLocalCommand {
|
||||||
throw new IOErrorException("Update contact error: " + e.getMessage(), e);
|
throw new IOErrorException("Update contact error: " + e.getMessage(), e);
|
||||||
} catch (NotMasterDeviceException e) {
|
} catch (NotMasterDeviceException e) {
|
||||||
throw new UserErrorException("This command doesn't work on linked devices.");
|
throw new UserErrorException("This command doesn't work on linked devices.");
|
||||||
|
} catch (UnregisteredRecipientException e) {
|
||||||
|
throw new UserErrorException("The user " + e.getSender().getIdentifier() + " is not registered.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,6 +10,7 @@ import org.asamk.signal.commands.exceptions.UserErrorException;
|
||||||
import org.asamk.signal.manager.AttachmentInvalidException;
|
import org.asamk.signal.manager.AttachmentInvalidException;
|
||||||
import org.asamk.signal.manager.Manager;
|
import org.asamk.signal.manager.Manager;
|
||||||
import org.asamk.signal.manager.api.SendGroupMessageResults;
|
import org.asamk.signal.manager.api.SendGroupMessageResults;
|
||||||
|
import org.asamk.signal.manager.api.UnregisteredRecipientException;
|
||||||
import org.asamk.signal.manager.api.UpdateGroup;
|
import org.asamk.signal.manager.api.UpdateGroup;
|
||||||
import org.asamk.signal.manager.groups.GroupId;
|
import org.asamk.signal.manager.groups.GroupId;
|
||||||
import org.asamk.signal.manager.groups.GroupLinkState;
|
import org.asamk.signal.manager.groups.GroupLinkState;
|
||||||
|
@ -167,6 +168,8 @@ public class UpdateGroupCommand implements JsonRpcLocalCommand {
|
||||||
throw new UserErrorException("Failed to add avatar attachment for group\": " + e.getMessage());
|
throw new UserErrorException("Failed to add avatar attachment for group\": " + e.getMessage());
|
||||||
} catch (GroupNotFoundException | NotAGroupMemberException | GroupSendingNotAllowedException e) {
|
} catch (GroupNotFoundException | NotAGroupMemberException | GroupSendingNotAllowedException e) {
|
||||||
throw new UserErrorException(e.getMessage());
|
throw new UserErrorException(e.getMessage());
|
||||||
|
} catch (UnregisteredRecipientException e) {
|
||||||
|
throw new UserErrorException("The user " + e.getSender().getIdentifier() + " is not registered.");
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new UnexpectedErrorException("Failed to send message: " + e.getMessage() + " (" + e.getClass()
|
throw new UnexpectedErrorException("Failed to send message: " + e.getMessage() + " (" + e.getClass()
|
||||||
.getSimpleName() + ")", e);
|
.getSimpleName() + ")", e);
|
||||||
|
|
|
@ -392,12 +392,12 @@ public class DbusManagerImpl implements Manager {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void deleteRecipient(final RecipientIdentifier.Single recipient) throws IOException {
|
public void deleteRecipient(final RecipientIdentifier.Single recipient) {
|
||||||
signal.deleteRecipient(recipient.getIdentifier());
|
signal.deleteRecipient(recipient.getIdentifier());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void deleteContact(final RecipientIdentifier.Single recipient) throws IOException {
|
public void deleteContact(final RecipientIdentifier.Single recipient) {
|
||||||
signal.deleteContact(recipient.getIdentifier());
|
signal.deleteContact(recipient.getIdentifier());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,6 +16,7 @@ import org.asamk.signal.manager.api.RecipientIdentifier;
|
||||||
import org.asamk.signal.manager.api.SendMessageResult;
|
import org.asamk.signal.manager.api.SendMessageResult;
|
||||||
import org.asamk.signal.manager.api.SendMessageResults;
|
import org.asamk.signal.manager.api.SendMessageResults;
|
||||||
import org.asamk.signal.manager.api.TypingAction;
|
import org.asamk.signal.manager.api.TypingAction;
|
||||||
|
import org.asamk.signal.manager.api.UnregisteredRecipientException;
|
||||||
import org.asamk.signal.manager.api.UpdateGroup;
|
import org.asamk.signal.manager.api.UpdateGroup;
|
||||||
import org.asamk.signal.manager.groups.GroupId;
|
import org.asamk.signal.manager.groups.GroupId;
|
||||||
import org.asamk.signal.manager.groups.GroupInviteLinkUrl;
|
import org.asamk.signal.manager.groups.GroupInviteLinkUrl;
|
||||||
|
@ -211,6 +212,8 @@ public class DbusSignalImpl implements Signal {
|
||||||
throw new Error.Failure(e);
|
throw new Error.Failure(e);
|
||||||
} catch (GroupNotFoundException | NotAGroupMemberException | GroupSendingNotAllowedException e) {
|
} catch (GroupNotFoundException | NotAGroupMemberException | GroupSendingNotAllowedException e) {
|
||||||
throw new Error.GroupNotFound(e.getMessage());
|
throw new Error.GroupNotFound(e.getMessage());
|
||||||
|
} catch (UnregisteredRecipientException e) {
|
||||||
|
throw new Error.UntrustedIdentity(e.getSender().getIdentifier() + " is not registered.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -272,6 +275,8 @@ public class DbusSignalImpl implements Signal {
|
||||||
throw new Error.Failure(e.getMessage());
|
throw new Error.Failure(e.getMessage());
|
||||||
} catch (GroupNotFoundException | NotAGroupMemberException | GroupSendingNotAllowedException e) {
|
} catch (GroupNotFoundException | NotAGroupMemberException | GroupSendingNotAllowedException e) {
|
||||||
throw new Error.GroupNotFound(e.getMessage());
|
throw new Error.GroupNotFound(e.getMessage());
|
||||||
|
} catch (UnregisteredRecipientException e) {
|
||||||
|
throw new Error.UntrustedIdentity(e.getSender().getIdentifier() + " is not registered.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -351,6 +356,8 @@ public class DbusSignalImpl implements Signal {
|
||||||
throw new Error.Failure(e.getMessage());
|
throw new Error.Failure(e.getMessage());
|
||||||
} catch (GroupNotFoundException | NotAGroupMemberException | GroupSendingNotAllowedException e) {
|
} catch (GroupNotFoundException | NotAGroupMemberException | GroupSendingNotAllowedException e) {
|
||||||
throw new Error.GroupNotFound(e.getMessage());
|
throw new Error.GroupNotFound(e.getMessage());
|
||||||
|
} catch (UnregisteredRecipientException e) {
|
||||||
|
throw new Error.UntrustedIdentity(e.getSender().getIdentifier() + " is not registered.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -366,20 +373,12 @@ public class DbusSignalImpl implements Signal {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void deleteRecipient(final String recipient) throws Error.Failure {
|
public void deleteRecipient(final String recipient) throws Error.Failure {
|
||||||
try {
|
m.deleteRecipient(getSingleRecipientIdentifier(recipient, m.getSelfNumber()));
|
||||||
m.deleteRecipient(getSingleRecipientIdentifier(recipient, m.getSelfNumber()));
|
|
||||||
} catch (IOException e) {
|
|
||||||
throw new Error.Failure("Recipient not found");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void deleteContact(final String recipient) throws Error.Failure {
|
public void deleteContact(final String recipient) throws Error.Failure {
|
||||||
try {
|
m.deleteContact(getSingleRecipientIdentifier(recipient, m.getSelfNumber()));
|
||||||
m.deleteContact(getSingleRecipientIdentifier(recipient, m.getSelfNumber()));
|
|
||||||
} catch (IOException e) {
|
|
||||||
throw new Error.Failure("Contact not found");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -395,6 +394,8 @@ public class DbusSignalImpl implements Signal {
|
||||||
throw new Error.GroupNotFound(e.getMessage());
|
throw new Error.GroupNotFound(e.getMessage());
|
||||||
} catch (AttachmentInvalidException e) {
|
} catch (AttachmentInvalidException e) {
|
||||||
throw new Error.AttachmentInvalid(e.getMessage());
|
throw new Error.AttachmentInvalid(e.getMessage());
|
||||||
|
} catch (UnregisteredRecipientException e) {
|
||||||
|
throw new Error.UntrustedIdentity(e.getSender().getIdentifier() + " is not registered.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -449,6 +450,8 @@ public class DbusSignalImpl implements Signal {
|
||||||
throw new Error.Failure(e.getMessage());
|
throw new Error.Failure(e.getMessage());
|
||||||
} catch (GroupNotFoundException | NotAGroupMemberException | GroupSendingNotAllowedException e) {
|
} catch (GroupNotFoundException | NotAGroupMemberException | GroupSendingNotAllowedException e) {
|
||||||
throw new Error.GroupNotFound(e.getMessage());
|
throw new Error.GroupNotFound(e.getMessage());
|
||||||
|
} catch (UnregisteredRecipientException e) {
|
||||||
|
throw new Error.UntrustedIdentity(e.getSender().getIdentifier() + " is not registered.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -468,6 +471,8 @@ public class DbusSignalImpl implements Signal {
|
||||||
throw new Error.Failure("This command doesn't work on linked devices.");
|
throw new Error.Failure("This command doesn't work on linked devices.");
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new Error.Failure("Contact is not registered.");
|
throw new Error.Failure("Contact is not registered.");
|
||||||
|
} catch (UnregisteredRecipientException e) {
|
||||||
|
throw new Error.UntrustedIdentity(e.getSender().getIdentifier() + " is not registered.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -477,6 +482,8 @@ public class DbusSignalImpl implements Signal {
|
||||||
m.setExpirationTimer(getSingleRecipientIdentifier(number, m.getSelfNumber()), expiration);
|
m.setExpirationTimer(getSingleRecipientIdentifier(number, m.getSelfNumber()), expiration);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new Error.Failure(e.getMessage());
|
throw new Error.Failure(e.getMessage());
|
||||||
|
} catch (UnregisteredRecipientException e) {
|
||||||
|
throw new Error.UntrustedIdentity(e.getSender().getIdentifier() + " is not registered.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -488,6 +495,8 @@ public class DbusSignalImpl implements Signal {
|
||||||
throw new Error.Failure("This command doesn't work on linked devices.");
|
throw new Error.Failure("This command doesn't work on linked devices.");
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new Error.Failure(e.getMessage());
|
throw new Error.Failure(e.getMessage());
|
||||||
|
} catch (UnregisteredRecipientException e) {
|
||||||
|
throw new Error.UntrustedIdentity(e.getSender().getIdentifier() + " is not registered.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -584,6 +593,8 @@ public class DbusSignalImpl implements Signal {
|
||||||
throw new Error.GroupNotFound(e.getMessage());
|
throw new Error.GroupNotFound(e.getMessage());
|
||||||
} catch (AttachmentInvalidException e) {
|
} catch (AttachmentInvalidException e) {
|
||||||
throw new Error.AttachmentInvalid(e.getMessage());
|
throw new Error.AttachmentInvalid(e.getMessage());
|
||||||
|
} catch (UnregisteredRecipientException e) {
|
||||||
|
throw new Error.UntrustedIdentity(e.getSender().getIdentifier() + " is not registered.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -707,7 +718,7 @@ public class DbusSignalImpl implements Signal {
|
||||||
Profile profile = null;
|
Profile profile = null;
|
||||||
try {
|
try {
|
||||||
profile = m.getRecipientProfile(RecipientIdentifier.Single.fromAddress(address));
|
profile = m.getRecipientProfile(RecipientIdentifier.Single.fromAddress(address));
|
||||||
} catch (IOException ignored) {
|
} catch (IOException | UnregisteredRecipientException ignored) {
|
||||||
}
|
}
|
||||||
if (profile != null && profile.getDisplayName().equals(name)) {
|
if (profile != null && profile.getDisplayName().equals(name)) {
|
||||||
numbers.add(number);
|
numbers.add(number);
|
||||||
|
@ -726,6 +737,8 @@ public class DbusSignalImpl implements Signal {
|
||||||
throw new Error.GroupNotFound(e.getMessage());
|
throw new Error.GroupNotFound(e.getMessage());
|
||||||
} catch (IOException | LastGroupAdminException e) {
|
} catch (IOException | LastGroupAdminException e) {
|
||||||
throw new Error.Failure(e.getMessage());
|
throw new Error.Failure(e.getMessage());
|
||||||
|
} catch (UnregisteredRecipientException e) {
|
||||||
|
throw new Error.UntrustedIdentity(e.getSender().getIdentifier() + " is not registered.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1149,6 +1162,8 @@ public class DbusSignalImpl implements Signal {
|
||||||
throw new Error.Failure(e.getMessage());
|
throw new Error.Failure(e.getMessage());
|
||||||
} catch (LastGroupAdminException e) {
|
} catch (LastGroupAdminException e) {
|
||||||
throw new Error.LastGroupAdmin(e.getMessage());
|
throw new Error.LastGroupAdmin(e.getMessage());
|
||||||
|
} catch (UnregisteredRecipientException e) {
|
||||||
|
throw new Error.UntrustedIdentity(e.getSender().getIdentifier() + " is not registered.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1262,6 +1277,8 @@ public class DbusSignalImpl implements Signal {
|
||||||
throw new Error.GroupNotFound(e.getMessage());
|
throw new Error.GroupNotFound(e.getMessage());
|
||||||
} catch (AttachmentInvalidException e) {
|
} catch (AttachmentInvalidException e) {
|
||||||
throw new Error.AttachmentInvalid(e.getMessage());
|
throw new Error.AttachmentInvalid(e.getMessage());
|
||||||
|
} catch (UnregisteredRecipientException e) {
|
||||||
|
throw new Error.UntrustedIdentity(e.getSender().getIdentifier() + " is not registered.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue