"name":"org.bouncycastle.jcajce.provider.asymmetric.DSTU4145$Mappings",
"methods":[{"name":"<init>","parameterTypes":[] }]
},
+{
+ "name":"org.bouncycastle.jcajce.provider.asymmetric.Dilithium$Mappings",
+ "methods":[{"name":"<init>","parameterTypes":[] }]
+},
{
"name":"org.bouncycastle.jcajce.provider.asymmetric.EC$Mappings",
"methods":[{"name":"<init>","parameterTypes":[] }]
"name":"org.bouncycastle.jcajce.provider.asymmetric.ECGOST$Mappings",
"methods":[{"name":"<init>","parameterTypes":[] }]
},
+{
+ "name":"org.bouncycastle.jcajce.provider.asymmetric.EXTERNAL$Mappings",
+ "methods":[{"name":"<init>","parameterTypes":[] }]
+},
{
"name":"org.bouncycastle.jcajce.provider.asymmetric.EdEC$Mappings",
"methods":[{"name":"<init>","parameterTypes":[] }]
"name":"org.bouncycastle.jcajce.provider.asymmetric.ElGamal$Mappings",
"methods":[{"name":"<init>","parameterTypes":[] }]
},
+{
+ "name":"org.bouncycastle.jcajce.provider.asymmetric.Falcon$Mappings",
+ "methods":[{"name":"<init>","parameterTypes":[] }]
+},
{
"name":"org.bouncycastle.jcajce.provider.asymmetric.GM$Mappings",
"methods":[{"name":"<init>","parameterTypes":[] }]
"name":"org.bouncycastle.jcajce.provider.asymmetric.IES$Mappings",
"methods":[{"name":"<init>","parameterTypes":[] }]
},
+{
+ "name":"org.bouncycastle.jcajce.provider.asymmetric.LMS$Mappings",
+ "methods":[{"name":"<init>","parameterTypes":[] }]
+},
+{
+ "name":"org.bouncycastle.jcajce.provider.asymmetric.NTRU$Mappings",
+ "methods":[{"name":"<init>","parameterTypes":[] }]
+},
{
"name":"org.bouncycastle.jcajce.provider.asymmetric.RSA$Mappings",
"methods":[{"name":"<init>","parameterTypes":[] }]
},
+{
+ "name":"org.bouncycastle.jcajce.provider.asymmetric.SPHINCSPlus$Mappings",
+ "methods":[{"name":"<init>","parameterTypes":[] }]
+},
{
"name":"org.bouncycastle.jcajce.provider.asymmetric.X509$Mappings",
"methods":[{"name":"<init>","parameterTypes":[] }]
"name":"org.bouncycastle.jcajce.provider.digest.Blake2s$Mappings",
"methods":[{"name":"<init>","parameterTypes":[] }]
},
+{
+ "name":"org.bouncycastle.jcajce.provider.digest.Blake3$Mappings",
+ "methods":[{"name":"<init>","parameterTypes":[] }]
+},
{
"name":"org.bouncycastle.jcajce.provider.digest.DSTU7564$Mappings",
"methods":[{"name":"<init>","parameterTypes":[] }]
Configuration getConfiguration();
- void updateConfiguration(Configuration configuration) throws IOException, NotPrimaryDeviceException;
+ void updateConfiguration(Configuration configuration) throws NotPrimaryDeviceException;
/**
* Update the user's profile.
SendMessageResults sendReadReceipt(
RecipientIdentifier.Single sender, List<Long> messageIds
- ) throws IOException;
+ );
SendMessageResults sendViewedReceipt(
RecipientIdentifier.Single sender, List<Long> messageIds
- ) throws IOException;
+ );
SendMessageResults sendMessage(
Message message, Set<RecipientIdentifier> recipients
void setContactName(
RecipientIdentifier.Single recipient, String givenName, final String familyName
- ) throws NotPrimaryDeviceException, IOException, UnregisteredRecipientException;
+ ) throws NotPrimaryDeviceException, UnregisteredRecipientException;
void setContactsBlocked(
Collection<RecipientIdentifier.Single> recipient, boolean blocked
InputStream retrieveAttachment(final String id) throws IOException;
@Override
- void close() throws IOException;
+ void close();
interface ReceiveMessageHandler {
public record Settings(TrustNewIdentity trustNewIdentity, boolean disableMessageSendLog) {
- public static Settings DEFAULT = new Settings(TrustNewIdentity.ON_FIRST_USE, false);
+ public static final Settings DEFAULT = new Settings(TrustNewIdentity.ON_FIRST_USE, false);
}
envelopeType = messageContent.getType();
} else {
originalContent = envelope.getContent();
- envelopeType = envelopeTypeToCiphertextMessageType(envelope.getType());
+ envelopeType = envelope.getType() == null
+ ? CiphertextMessage.WHISPER_TYPE
+ : envelopeTypeToCiphertextMessageType(envelope.getType());
}
DecryptionErrorMessage decryptionErrorMessage = DecryptionErrorMessage.forOriginalMessage(originalContent,
import org.whispersystems.signalservice.api.messages.multidevice.ViewedMessage;
import java.io.File;
+import java.io.IOException;
import java.util.List;
import java.util.Optional;
import java.util.Set;
return new Quote(quote.getId(),
addressResolver.resolveRecipientAddress(recipientResolver.resolveRecipient(quote.getAuthor()))
.toApiRecipientAddress(),
- Optional.ofNullable(quote.getText()),
+ Optional.of(quote.getText()),
quote.getMentions() == null
? List.of()
: quote.getMentions()
boolean isBorderless
) {
- static Attachment from(SignalServiceAttachment attachment, AttachmentFileProvider fileProvider) {
- if (attachment.isPointer()) {
- final var a = attachment.asPointer();
+ static Attachment from(SignalServiceAttachment signalAttachment, AttachmentFileProvider fileProvider) {
+ if (signalAttachment.isPointer()) {
+ final var a = signalAttachment.asPointer();
final var attachmentFile = fileProvider.getFile(a);
return new Attachment(Optional.of(attachmentFile.getName()),
Optional.of(attachmentFile),
a.isGif(),
a.isBorderless());
} else {
- final var a = attachment.asStream();
- return new Attachment(Optional.empty(),
- Optional.empty(),
- a.getFileName(),
- a.getContentType(),
- a.getUploadTimestamp() == 0 ? Optional.empty() : Optional.of(a.getUploadTimestamp()),
- Optional.of(a.getLength()),
- a.getPreview(),
- Optional.empty(),
- a.getCaption(),
- a.getWidth() == 0 ? Optional.empty() : Optional.of(a.getWidth()),
- a.getHeight() == 0 ? Optional.empty() : Optional.of(a.getHeight()),
- a.getVoiceNote(),
- a.isGif(),
- a.isBorderless());
+ Attachment attachment = null;
+ try (final var a = signalAttachment.asStream()) {
+ attachment = new Attachment(Optional.empty(),
+ Optional.empty(),
+ a.getFileName(),
+ a.getContentType(),
+ a.getUploadTimestamp() == 0 ? Optional.empty() : Optional.of(a.getUploadTimestamp()),
+ Optional.of(a.getLength()),
+ a.getPreview(),
+ Optional.empty(),
+ a.getCaption(),
+ a.getWidth() == 0 ? Optional.empty() : Optional.of(a.getWidth()),
+ a.getHeight() == 0 ? Optional.empty() : Optional.of(a.getHeight()),
+ a.getVoiceNote(),
+ a.isGif(),
+ a.isBorderless());
+ return attachment;
+ } catch (IOException e) {
+ return attachment;
+ }
}
}
if (avatarFile == null) {
return null;
}
- try (final var avatar = Utils.createStreamDetails(avatarFile).first().getStream()) {
- return IOUtils.readFully(avatar);
+ try (final var avatar = Utils.createStreamDetails(avatarFile).first()) {
+ return IOUtils.readFully(avatar.getStream());
}
}
}
import org.whispersystems.signalservice.api.messages.SendMessageResult;
import org.whispersystems.signalservice.api.push.ServiceId;
-import java.io.IOException;
import java.util.Arrays;
import java.util.function.BiFunction;
}
account.getIdentityKeyStore().setIdentityTrustLevel(serviceId, identity.getIdentityKey(), trustLevel);
- try {
- context.getSyncHelper()
- .sendVerifiedMessage(address.toSignalServiceAddress(), identity.getIdentityKey(), trustLevel);
- } catch (IOException e) {
- logger.warn("Failed to send verification sync message: {}", e.getMessage());
- }
+ context.getSyncHelper()
+ .sendVerifiedMessage(address.toSignalServiceAddress(), identity.getIdentityKey(), trustLevel);
return true;
}
if (avatar != null) {
if (avatar.isPresent()) {
- final var streamDetails = Utils.createStreamDetails(avatar.get()).first();
- context.getAvatarStore()
- .storeProfileAvatar(account.getSelfRecipientAddress(),
- outputStream -> IOUtils.copyStream(streamDetails.getStream(), outputStream));
+ try (final var streamDetails = Utils.createStreamDetails(avatar.get()).first()) {
+ context.getAvatarStore()
+ .storeProfileAvatar(account.getSelfRecipientAddress(),
+ outputStream -> IOUtils.copyStream(streamDetails.getStream(), outputStream));
+ }
} else {
context.getAvatarStore().deleteProfileAvatar(account.getSelfRecipientAddress());
}
import org.signal.libsignal.protocol.IdentityKey;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import org.whispersystems.signalservice.api.messages.SendMessageResult;
import org.whispersystems.signalservice.api.messages.SignalServiceAttachment;
import org.whispersystems.signalservice.api.messages.SignalServiceAttachmentStream;
import org.whispersystems.signalservice.api.messages.multidevice.BlockedListMessage;
requestSyncData(SyncMessage.Request.Type.PNI_IDENTITY);
}
- public void sendSyncFetchProfileMessage() {
- context.getSendHelper()
+ public SendMessageResult sendSyncFetchProfileMessage() {
+ return context.getSendHelper()
.sendSyncMessage(SignalServiceSyncMessage.forFetchLatest(SignalServiceSyncMessage.FetchType.LOCAL_PROFILE));
}
}
}
- public void sendBlockedList() {
+ public SendMessageResult sendBlockedList() {
var addresses = new ArrayList<SignalServiceAddress>();
for (var record : account.getContactStore().getContacts()) {
if (record.second().isBlocked()) {
groupIds.add(record.getGroupId().serialize());
}
}
- context.getSendHelper()
+ return context.getSendHelper()
.sendSyncMessage(SignalServiceSyncMessage.forBlocked(new BlockedListMessage(addresses, groupIds)));
}
- public void sendVerifiedMessage(
+ public SendMessageResult sendVerifiedMessage(
SignalServiceAddress destination, IdentityKey identityKey, TrustLevel trustLevel
- ) throws IOException {
+ ) {
var verifiedMessage = new VerifiedMessage(destination,
identityKey,
trustLevel.toVerifiedState(),
System.currentTimeMillis());
- context.getSendHelper().sendSyncMessage(SignalServiceSyncMessage.forVerified(verifiedMessage));
+ return context.getSendHelper().sendSyncMessage(SignalServiceSyncMessage.forVerified(verifiedMessage));
}
- public void sendKeysMessage() {
+ public SendMessageResult sendKeysMessage() {
var keysMessage = new KeysMessage(Optional.ofNullable(account.getStorageKey()));
- context.getSendHelper().sendSyncMessage(SignalServiceSyncMessage.forKeys(keysMessage));
+ return context.getSendHelper().sendSyncMessage(SignalServiceSyncMessage.forKeys(keysMessage));
}
- public void sendStickerOperationsMessage(List<StickerPack> installStickers, List<StickerPack> removeStickers) {
+ public SendMessageResult sendStickerOperationsMessage(
+ List<StickerPack> installStickers, List<StickerPack> removeStickers
+ ) {
var installStickerMessages = installStickers.stream().map(s -> getStickerPackOperationMessage(s, true));
var removeStickerMessages = removeStickers.stream().map(s -> getStickerPackOperationMessage(s, false));
var stickerMessages = Stream.concat(installStickerMessages, removeStickerMessages).toList();
- context.getSendHelper().sendSyncMessage(SignalServiceSyncMessage.forStickerPackOperations(stickerMessages));
+ return context.getSendHelper()
+ .sendSyncMessage(SignalServiceSyncMessage.forStickerPackOperations(stickerMessages));
}
private static StickerPackOperationMessage getStickerPackOperationMessage(
installed ? StickerPackOperationMessage.Type.INSTALL : StickerPackOperationMessage.Type.REMOVE);
}
- public void sendConfigurationMessage() {
+ public SendMessageResult sendConfigurationMessage() {
final var config = account.getConfigurationStore();
var configurationMessage = new ConfigurationMessage(Optional.ofNullable(config.getReadReceipts()),
Optional.ofNullable(config.getUnidentifiedDeliveryIndicators()),
Optional.ofNullable(config.getTypingIndicators()),
Optional.ofNullable(config.getLinkPreviews()));
- context.getSendHelper().sendSyncMessage(SignalServiceSyncMessage.forConfiguration(configurationMessage));
+ return context.getSendHelper().sendSyncMessage(SignalServiceSyncMessage.forConfiguration(configurationMessage));
}
public void handleSyncDeviceGroups(final InputStream input) {
}
}
- private void requestSyncData(final SyncMessage.Request.Type type) {
+ private SendMessageResult requestSyncData(final SyncMessage.Request.Type type) {
var r = new SyncMessage.Request.Builder().type(type).build();
var message = SignalServiceSyncMessage.forRequest(new RequestMessage(r));
- context.getSendHelper().sendSyncMessage(message);
+ return context.getSendHelper().sendSyncMessage(message);
}
private Optional<SignalServiceAttachmentStream> createContactAvatarAttachment(RecipientAddress address) throws IOException {
public void close() {
synchronized (managers) {
for (var m : new ArrayList<>(managers)) {
- try {
- m.close();
- } catch (IOException e) {
- logger.warn("Cleanup failed", e);
- }
+ m.close();
}
managers.clear();
}
}
@Override
- public void close() throws SQLException {
+ public void close() {
dataSource.close();
}
public void close() {
synchronized (fileChannel) {
if (accountDatabase != null) {
- try {
- accountDatabase.close();
- } catch (SQLException e) {
- logger.warn("Failed to close account database: {}", e.getMessage(), e);
- }
+ accountDatabase.close();
}
if (messageSendLogStore != null) {
messageSendLogStore.close();
}
private void saveAccountsLocked(FileChannel fileChannel, AccountsStorage accountsStorage) throws IOException {
- try {
- try (var output = new ByteArrayOutputStream()) {
- // Write to memory first to prevent corrupting the file in case of serialization errors
- objectMapper.writeValue(output, accountsStorage);
- var input = new ByteArrayInputStream(output.toByteArray());
- fileChannel.position(0);
- input.transferTo(Channels.newOutputStream(fileChannel));
- fileChannel.truncate(fileChannel.position());
- fileChannel.force(false);
- }
- } catch (Exception e) {
- logger.error("Error saving accounts file: {}", e.getMessage(), e);
+ try (var output = new ByteArrayOutputStream()) {
+ // Write to memory first to prevent corrupting the file in case of serialization errors
+ objectMapper.writeValue(output, accountsStorage);
+ var input = new ByteArrayInputStream(output.toByteArray());
+ fileChannel.position(0);
+ input.transferTo(Channels.newOutputStream(fileChannel));
+ fileChannel.truncate(fileChannel.position());
+ fileChannel.force(false);
}
}
public class LegacyIdentityInfo {
RecipientAddress address;
- IdentityKey identityKey;
- TrustLevel trustLevel;
- Date added;
+ final IdentityKey identityKey;
+ final TrustLevel trustLevel;
+ final Date added;
LegacyIdentityInfo(RecipientAddress address, IdentityKey identityKey, TrustLevel trustLevel, Date added) {
this.address = address;
public class LegacySessionInfo {
- public RecipientAddress address;
+ public final RecipientAddress address;
- public int deviceId;
+ public final int deviceId;
- public byte[] sessionRecord;
+ public final byte[] sessionRecord;
LegacySessionInfo(final RecipientAddress address, final int deviceId, final byte[] sessionRecord) {
this.address = address;
package org.asamk.signal.manager.storage.recipients;
-record RecipientWithAddress(RecipientId id, RecipientAddress address) {}
+public record RecipientWithAddress(RecipientId id, RecipientAddress address) {}
return new Key(address, deviceId);
}
- private SessionRecord getSessionRecordFromResultSet(ResultSet resultSet) throws SQLException {
+ private SessionRecord getSessionRecordFromResultSet(ResultSet resultSet) {
try {
final var record = resultSet.getBytes("record");
return new SessionRecord(record);
@JsonProperty("threads")
@JsonSerialize(using = MapToListSerializer.class)
@JsonDeserialize(using = ThreadsDeserializer.class)
- private Map<String, LegacyThreadInfo> threads = new HashMap<>();
+ private final Map<String, LegacyThreadInfo> threads = new HashMap<>();
public List<LegacyThreadInfo> getThreads() {
return new ArrayList<>(threads.values());
if (version >= 2) {
serverReceivedTimestamp = in.readLong();
uuid = in.readUTF();
- if ("".equals(uuid)) {
+ if (uuid.isEmpty()) {
uuid = null;
}
}
static final PartialAddresses ADDR_A = new PartialAddresses(SERVICE_ID_A, PNI_A, NUMBER_A);
static final PartialAddresses ADDR_B = new PartialAddresses(SERVICE_ID_B, PNI_B, NUMBER_B);
- static T[] testInstancesNone = new T[]{
+ static final T[] testInstancesNone = new T[]{
new T(Set.of(), ADDR_A.FULL, Set.of(rec(1000000, ADDR_A.FULL))),
new T(Set.of(), ADDR_A.ACI_NUM, Set.of(rec(1000000, ADDR_A.ACI_NUM))),
new T(Set.of(), ADDR_A.ACI_PNI, Set.of(rec(1000000, ADDR_A.ACI_PNI))),
new T(Set.of(), ADDR_A.PNI_NUM, Set.of(rec(1000000, ADDR_A.PNI_NUM))),
};
- static T[] testInstancesSingle = new T[]{
+ static final T[] testInstancesSingle = new T[]{
new T(Set.of(rec(1, ADDR_A.FULL)), ADDR_A.FULL, Set.of(rec(1, ADDR_A.FULL))),
new T(Set.of(rec(1, ADDR_A.ACI)), ADDR_A.FULL, Set.of(rec(1, ADDR_A.FULL))),
new T(Set.of(rec(1, ADDR_A.PNI)), ADDR_A.FULL, Set.of(rec(1, ADDR_A.FULL))),
new T(Set.of(rec(1, ADDR_A.FULL)), ADDR_B.FULL, Set.of(rec(1, ADDR_A.FULL), rec(1000000, ADDR_B.FULL))),
};
- static T[] testInstancesTwo = new T[]{
+ static final T[] testInstancesTwo = new T[]{
new T(Set.of(rec(1, ADDR_A.ACI), rec(2, ADDR_A.PNI)), ADDR_A.FULL, Set.of(rec(1, ADDR_A.FULL))),
new T(Set.of(rec(1, ADDR_A.ACI), rec(2, ADDR_A.NUM)), ADDR_A.FULL, Set.of(rec(1, ADDR_A.FULL))),
new T(Set.of(rec(1, ADDR_A.ACI), rec(2, ADDR_A.PNI_NUM)), ADDR_A.FULL, Set.of(rec(1, ADDR_A.FULL))),
new T(Set.of(rec(1, ADDR_A.PNI), rec(2, ADDR_A.ACI_NUM)), ADDR_A.ACI_PNI, Set.of(rec(2, ADDR_A.FULL))),
};
- static T[] testInstancesThree = new T[]{
+ static final T[] testInstancesThree = new T[]{
new T(Set.of(rec(1, ADDR_A.ACI), rec(2, ADDR_A.PNI), rec(3, ADDR_A.NUM)),
ADDR_A.FULL,
Set.of(rec(1, ADDR_A.FULL))),
For example:
-```
+[source]
+----
dbus-send --session --dest=org.asamk.Signal --type=method_call --print-reply /org/asamk/Signal org.asamk.Signal.link string:"My secondary client" | tr '\n' '\0' | sed 's/.*string //g' | sed 's/\"//g' | qrencode -s10 -tANSI256
-```
+----
listAccounts() -> accountList<as>::
* accountList : Array of all attached accounts in DBus object path form
DBusPath getDevice(long deviceId);
- public DBusPath getIdentity(String number);
+ DBusPath getIdentity(String number);
- public List<StructIdentity> listIdentities();
+ List<StructIdentity> listIdentities();
List<StructDevice> listDevices() throws Error.Failure;
class StructDevice extends Struct {
@Position(0)
- DBusPath objectPath;
+ final DBusPath objectPath;
@Position(1)
- Long id;
+ final Long id;
@Position(2)
- String name;
+ final String name;
public StructDevice(final DBusPath objectPath, final Long id, final String name) {
this.objectPath = objectPath;
class StructGroup extends Struct {
@Position(0)
- DBusPath objectPath;
+ final DBusPath objectPath;
@Position(1)
- byte[] id;
+ final byte[] id;
@Position(2)
- String name;
+ final String name;
public StructGroup(final DBusPath objectPath, final byte[] id, final String name) {
this.objectPath = objectPath;
class StructIdentity extends Struct {
@Position(0)
- DBusPath objectPath;
+ final DBusPath objectPath;
@Position(1)
- String uuid;
+ final String uuid;
@Position(2)
- String number;
+ final String number;
public StructIdentity(final DBusPath objectPath, final String uuid, final String number) {
this.objectPath = objectPath;
return;
}
- Set<String> accounts;
- try {
- accounts = signalAccountFiles.getAllLocalAccountNumbers();
- } catch (IOException e) {
- throw new IOErrorException("Failed to load local accounts file", e);
- }
- if (accounts.size() == 0) {
- throw new UserErrorException("No local users found, you first need to register or link an account");
- } else if (accounts.size() > 1) {
- throw new UserErrorException(
- "Multiple users found, you need to specify an account (phone number) with -a");
- }
-
- account = accounts.stream().findFirst().get();
+ account = getAccountIfOnlyOne(signalAccountFiles);
} else if (!Manager.isValidNumber(account, null)) {
throw new UserErrorException("Invalid account (phone number), make sure you include the country code.");
}
throw new UserErrorException("Command only works in multi-account mode");
}
+ private static String getAccountIfOnlyOne(final SignalAccountFiles signalAccountFiles) throws IOErrorException, UserErrorException {
+ Set<String> accounts;
+ try {
+ accounts = signalAccountFiles.getAllLocalAccountNumbers();
+ } catch (IOException e) {
+ throw new IOErrorException("Failed to load local accounts file", e);
+ }
+ if (accounts.isEmpty()) {
+ throw new UserErrorException("No local users found, you first need to register or link an account");
+ } else if (accounts.size() > 1) {
+ throw new UserErrorException("Multiple users found, you need to specify an account (phone number) with -a");
+ }
+ return accounts.stream().findFirst().get();
+ }
+
private OutputWriter getOutputWriter(final Command command) throws UserErrorException {
final var outputTypeInput = ns.<OutputType>get("output");
final var outputType = outputTypeInput == null ? command.getSupportedOutputTypes()
) throws CommandException {
try (var m = loadManager(account, signalAccountFiles)) {
commandHandler.handleLocalCommand(command, m);
- } catch (IOException e) {
- logger.warn("Cleanup failed", e);
}
}
import org.asamk.signal.output.OutputWriter;
import org.asamk.signal.util.CommandUtil;
-import java.io.IOException;
-
import static org.asamk.signal.util.SendMessageResultUtils.outputResult;
public class SendReceiptCommand implements JsonRpcLocalCommand {
final var targetTimestamps = ns.<Long>getList("target-timestamp");
final var type = ns.getString("type");
- try {
- final SendMessageResults results;
- if (type == null || "read".equals(type)) {
- results = m.sendReadReceipt(recipient, targetTimestamps);
- } else if ("viewed".equals(type)) {
- results = m.sendViewedReceipt(recipient, targetTimestamps);
- } else {
- throw new UserErrorException("Unknown receipt type: " + type);
- }
- outputResult(outputWriter, results);
- } catch (IOException e) {
- throw new UserErrorException("Failed to send message: " + e.getMessage() + " (" + e.getClass()
- .getSimpleName() + ")");
+ final SendMessageResults results;
+ if (type == null || "read".equals(type)) {
+ results = m.sendReadReceipt(recipient, targetTimestamps);
+ } else if ("viewed".equals(type)) {
+ results = m.sendViewedReceipt(recipient, targetTimestamps);
+ } else {
+ throw new UserErrorException("Unknown receipt type: " + type);
}
+ outputResult(outputWriter, results);
}
}
import net.sourceforge.argparse4j.inf.Subparser;
import org.asamk.signal.commands.exceptions.CommandException;
-import org.asamk.signal.commands.exceptions.IOErrorException;
import org.asamk.signal.commands.exceptions.UserErrorException;
import org.asamk.signal.manager.Manager;
import org.asamk.signal.manager.api.Configuration;
import org.asamk.signal.manager.api.NotPrimaryDeviceException;
import org.asamk.signal.output.OutputWriter;
-import java.io.IOException;
import java.util.Optional;
public class UpdateConfigurationCommand implements JsonRpcLocalCommand {
Optional.ofNullable(unidentifiedDeliveryIndicators),
Optional.ofNullable(typingIndicators),
Optional.ofNullable(linkPreviews)));
- } catch (IOException e) {
- throw new IOErrorException("UpdateAccount error: " + e.getMessage(), e);
} catch (NotPrimaryDeviceException e) {
throw new UserErrorException("This command doesn't work on linked devices.");
}
}
@Override
- public void updateConfiguration(Configuration newConfiguration) throws IOException {
+ public void updateConfiguration(Configuration newConfiguration) {
final var configuration = getRemoteObject(new DBusPath(signal.getObjectPath() + "/Configuration"),
Signal.Configuration.class);
newConfiguration.readReceipts()
public void sendReadReceipt(
final String recipient, final List<Long> messageIds
) throws Error.Failure, Error.UntrustedIdentity {
- try {
- final var results = m.sendReadReceipt(getSingleRecipientIdentifier(recipient, m.getSelfNumber()),
- messageIds);
- checkSendMessageResults(results);
- } catch (IOException e) {
- throw new Error.Failure(e.getMessage());
- }
+ final var results = m.sendReadReceipt(getSingleRecipientIdentifier(recipient, m.getSelfNumber()), messageIds);
+ checkSendMessageResults(results);
}
@Override
public void sendViewedReceipt(
final String recipient, final List<Long> messageIds
) throws Error.Failure, Error.UntrustedIdentity {
- try {
- final var results = m.sendViewedReceipt(getSingleRecipientIdentifier(recipient, m.getSelfNumber()),
- messageIds);
- checkSendMessageResults(results);
- } catch (IOException e) {
- throw new Error.Failure(e.getMessage());
- }
+ final var results = m.sendViewedReceipt(getSingleRecipientIdentifier(recipient, m.getSelfNumber()), messageIds);
+ checkSendMessageResults(results);
}
@Override
m.setContactName(getSingleRecipientIdentifier(number, m.getSelfNumber()), name, "");
} catch (NotPrimaryDeviceException e) {
throw new Error.Failure("This command doesn't work on linked devices.");
- } catch (IOException e) {
- throw new Error.Failure("Contact is not registered.");
} catch (UnregisteredRecipientException e) {
throw new Error.UntrustedIdentity(e.getSender().getIdentifier() + " is not registered.");
}
Optional.ofNullable(unidentifiedDeliveryIndicators),
Optional.ofNullable(typingIndicators),
Optional.ofNullable(linkPreviews)));
- } catch (IOException e) {
- throw new Error.Failure("UpdateAccount error: " + e.getMessage());
} catch (NotPrimaryDeviceException e) {
throw new Error.Failure("This command doesn't work on linked devices.");
}