import net.sourceforge.argparse4j.inf.Namespace;
import net.sourceforge.argparse4j.inf.Subparser;
-import org.asamk.signal.OutputWriter;
import org.asamk.signal.commands.exceptions.CommandException;
import org.asamk.signal.commands.exceptions.UserErrorException;
import org.asamk.signal.manager.Manager;
-import org.asamk.signal.manager.UntrustedIdentityException;
+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 {
@Override
final var type = ns.getString("type");
try {
+ final SendMessageResults results;
if (type == null || "read".equals(type)) {
- m.sendReadReceipt(recipient, targetTimestamps);
+ results = m.sendReadReceipt(recipient, targetTimestamps);
} else if ("viewed".equals(type)) {
- m.sendViewedReceipt(recipient, targetTimestamps);
+ results = m.sendViewedReceipt(recipient, targetTimestamps);
} else {
throw new UserErrorException("Unknown receipt type: " + type);
}
- } catch (IOException | UntrustedIdentityException e) {
+ outputResult(outputWriter, results);
+ } catch (IOException e) {
throw new UserErrorException("Failed to send message: " + e.getMessage() + " (" + e.getClass()
.getSimpleName() + ")");
}