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

@ -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,19 +43,14 @@ 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);
}
}

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.");
}