]> nmode's Git Repositories - signal-cli/blobdiff - src/main/java/org/asamk/signal/commands/SendReceiptCommand.java
Implement more methods for DbusManagerImpl
[signal-cli] / src / main / java / org / asamk / signal / commands / SendReceiptCommand.java
index 5dd296827972f8ea9d694a04c342b45401670191..6ba8a40cf451cb2b0b4034ddc0e205e8ee33e1ea 100644 (file)
@@ -3,15 +3,17 @@ package org.asamk.signal.commands;
 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
@@ -43,14 +45,16 @@ public class SendReceiptCommand implements JsonRpcLocalCommand {
         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() + ")");
         }