Fix inspections

This commit is contained in:
AsamK 2023-10-17 20:00:47 +02:00
parent d51dd7ae57
commit fc2e9bbfae
27 changed files with 158 additions and 158 deletions

View file

@ -1363,6 +1363,10 @@
"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":[] }]
@ -1371,6 +1375,10 @@
"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":[] }]
@ -1379,6 +1387,10 @@
"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":[] }]
@ -1391,10 +1403,22 @@
"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":[] }]
@ -1419,6 +1443,10 @@
"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":[] }]

View file

@ -92,7 +92,7 @@ public interface Manager extends Closeable {
Configuration getConfiguration();
void updateConfiguration(Configuration configuration) throws IOException, NotPrimaryDeviceException;
void updateConfiguration(Configuration configuration) throws NotPrimaryDeviceException;
/**
* Update the user's profile.
@ -160,11 +160,11 @@ public interface Manager extends Closeable {
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
@ -199,7 +199,7 @@ public interface Manager extends Closeable {
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
@ -299,7 +299,7 @@ public interface Manager extends Closeable {
InputStream retrieveAttachment(final String id) throws IOException;
@Override
void close() throws IOException;
void close();
interface ReceiveMessageHandler {

View file

@ -4,5 +4,5 @@ import org.asamk.signal.manager.api.TrustNewIdentity;
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);
}

View file

@ -50,7 +50,9 @@ public class SendRetryMessageRequestAction implements HandleAction {
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,

View file

@ -34,6 +34,7 @@ import org.whispersystems.signalservice.api.messages.multidevice.ViewOnceOpenMes
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;
@ -234,7 +235,7 @@ public record MessageEnvelope(
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()
@ -291,9 +292,9 @@ public record MessageEnvelope(
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),
@ -310,8 +311,9 @@ public record MessageEnvelope(
a.isGif(),
a.isBorderless());
} else {
final var a = attachment.asStream();
return new Attachment(Optional.empty(),
Attachment attachment = null;
try (final var a = signalAttachment.asStream()) {
attachment = new Attachment(Optional.empty(),
Optional.empty(),
a.getFileName(),
a.getContentType(),
@ -325,6 +327,10 @@ public record MessageEnvelope(
a.getVoiceNote(),
a.isGif(),
a.isBorderless());
return attachment;
} catch (IOException e) {
return attachment;
}
}
}

View file

@ -822,8 +822,8 @@ public class GroupHelper {
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());
}
}
}

View file

@ -14,7 +14,6 @@ import org.slf4j.LoggerFactory;
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;
@ -112,12 +111,8 @@ public class IdentityHelper {
}
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());
}
return true;
}

View file

@ -212,10 +212,11 @@ public final class ProfileHelper {
if (avatar != null) {
if (avatar.isPresent()) {
final var streamDetails = Utils.createStreamDetails(avatar.get()).first();
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());
}

View file

@ -13,6 +13,7 @@ import org.asamk.signal.manager.util.MimeUtils;
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;
@ -73,8 +74,8 @@ public class SyncHelper {
requestSyncData(SyncMessage.Request.Type.PNI_IDENTITY);
}
public void sendSyncFetchProfileMessage() {
context.getSendHelper()
public SendMessageResult sendSyncFetchProfileMessage() {
return context.getSendHelper()
.sendSyncMessage(SignalServiceSyncMessage.forFetchLatest(SignalServiceSyncMessage.FetchType.LOCAL_PROFILE));
}
@ -193,7 +194,7 @@ public class SyncHelper {
}
}
public void sendBlockedList() {
public SendMessageResult sendBlockedList() {
var addresses = new ArrayList<SignalServiceAddress>();
for (var record : account.getContactStore().getContacts()) {
if (record.second().isBlocked()) {
@ -206,30 +207,33 @@ public class SyncHelper {
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(
@ -240,13 +244,13 @@ public class SyncHelper {
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) {
@ -344,10 +348,10 @@ public class SyncHelper {
}
}
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 {

View file

@ -125,11 +125,7 @@ public class MultiAccountManagerImpl implements MultiAccountManager {
public void close() {
synchronized (managers) {
for (var m : new ArrayList<>(managers)) {
try {
m.close();
} catch (IOException e) {
logger.warn("Cleanup failed", e);
}
}
managers.clear();
}

View file

@ -47,7 +47,7 @@ public abstract class Database implements AutoCloseable {
}
@Override
public void close() throws SQLException {
public void close() {
dataSource.close();
}

View file

@ -1610,11 +1610,7 @@ public class SignalAccount implements Closeable {
public void close() {
synchronized (fileChannel) {
if (accountDatabase != null) {
try {
accountDatabase.close();
} catch (SQLException e) {
logger.warn("Failed to close account database: {}", e.getMessage(), e);
}
}
if (messageSendLogStore != null) {
messageSendLogStore.close();

View file

@ -252,7 +252,6 @@ public class AccountsStore {
}
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);
@ -262,9 +261,6 @@ public class AccountsStore {
fileChannel.truncate(fileChannel.position());
fileChannel.force(false);
}
} catch (Exception e) {
logger.error("Error saving accounts file: {}", e.getMessage(), e);
}
}
private static Pair<FileChannel, FileLock> openFileChannel(File fileName) throws IOException {

View file

@ -9,9 +9,9 @@ import java.util.Date;
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;

View file

@ -4,11 +4,11 @@ import org.asamk.signal.manager.storage.recipients.RecipientAddress;
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;

View file

@ -1,3 +1,3 @@
package org.asamk.signal.manager.storage.recipients;
record RecipientWithAddress(RecipientId id, RecipientAddress address) {}
public record RecipientWithAddress(RecipientId id, RecipientAddress address) {}

View file

@ -328,7 +328,7 @@ public class SessionStore implements SignalServiceSessionStore {
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);

View file

@ -25,7 +25,7 @@ public class LegacyJsonThreadStore {
@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());

View file

@ -69,7 +69,7 @@ public class MessageCacheUtils {
if (version >= 2) {
serverReceivedTimestamp = in.readLong();
uuid = in.readUTF();
if ("".equals(uuid)) {
if (uuid.isEmpty()) {
uuid = null;
}
}

View file

@ -27,14 +27,14 @@ class MergeRecipientHelperTest {
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))),
@ -74,7 +74,7 @@ class MergeRecipientHelperTest {
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))),
@ -100,7 +100,7 @@ class MergeRecipientHelperTest {
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))),

View file

@ -68,9 +68,10 @@ This can be piped to a QR encoder to create a display that can be captured by a
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

View file

@ -138,9 +138,9 @@ public interface Signal extends DBusInterface {
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;
@ -497,13 +497,13 @@ public interface Signal extends DBusInterface {
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;
@ -542,13 +542,13 @@ public interface Signal extends DBusInterface {
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;
@ -610,13 +610,13 @@ public interface Signal extends DBusInterface {
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;

View file

@ -165,20 +165,7 @@ public class App {
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.");
}
@ -196,6 +183,21 @@ public class App {
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()
@ -274,8 +276,6 @@ public class App {
) throws CommandException {
try (var m = loadManager(account, signalAccountFiles)) {
commandHandler.handleLocalCommand(command, m);
} catch (IOException e) {
logger.warn("Cleanup failed", e);
}
}

View file

@ -10,8 +10,6 @@ import org.asamk.signal.manager.api.SendMessageResults;
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 {
@ -45,7 +43,6 @@ 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);
@ -55,9 +52,5 @@ public class SendReceiptCommand implements JsonRpcLocalCommand {
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() + ")");
}
}
}

View file

@ -4,14 +4,12 @@ import net.sourceforge.argparse4j.inf.Namespace;
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 {
@ -51,8 +49,6 @@ 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.");
}

View file

@ -136,7 +136,7 @@ public class DbusManagerImpl implements Manager {
}
@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()

View file

@ -351,26 +351,16 @@ public class DbusSignalImpl implements Signal {
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);
final var results = m.sendReadReceipt(getSingleRecipientIdentifier(recipient, m.getSelfNumber()), messageIds);
checkSendMessageResults(results);
} catch (IOException e) {
throw new Error.Failure(e.getMessage());
}
}
@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);
final var results = m.sendViewedReceipt(getSingleRecipientIdentifier(recipient, m.getSelfNumber()), messageIds);
checkSendMessageResults(results);
} catch (IOException e) {
throw new Error.Failure(e.getMessage());
}
}
@Override
@ -532,8 +522,6 @@ public class DbusSignalImpl implements Signal {
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.");
}
@ -1238,8 +1226,6 @@ public class DbusSignalImpl implements Signal {
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.");
}