]> nmode's Git Repositories - signal-cli/blobdiff - src/main/java/org/asamk/signal/dbus/DbusSignalImpl.java
dbus implementation of sendReaction command (#581)
[signal-cli] / src / main / java / org / asamk / signal / dbus / DbusSignalImpl.java
index 24a90662ab2eb567d7449c44a2574e81a547dfac..9bc4b67f9a9ba68133c005fff47b457cd5014d89 100644 (file)
@@ -103,6 +103,30 @@ public class DbusSignalImpl implements Signal {
         }
     }
 
+    @Override
+    public long sendMessageReaction(
+            final String emoji, final boolean remove, final String targetAuthor, final long targetSentTimestamp, final String recipient
+    ) {
+        var recipients = new ArrayList<String>(1);
+        recipients.add(recipient);
+        return sendMessageReaction(emoji, remove, targetAuthor, targetSentTimestamp, recipients);
+    }
+
+    @Override
+    public long sendMessageReaction(
+            final String emoji, final boolean remove, final String targetAuthor, final long targetSentTimestamp, final List<String> recipients
+    ) {
+        try {
+            final var results = m.sendMessageReaction(emoji, remove, targetAuthor, targetSentTimestamp, recipients);
+            checkSendMessageResults(results.first(), results.second());
+            return results.first();
+        } catch (InvalidNumberException e) {
+            throw new Error.InvalidNumber(e.getMessage());
+        } catch (IOException e) {
+            throw new Error.Failure(e.getMessage());
+        }
+    }
+
     @Override
     public long sendNoteToSelfMessage(
             final String message, final List<String> attachments
@@ -145,6 +169,23 @@ public class DbusSignalImpl implements Signal {
         }
     }
 
+    @Override
+    public long sendGroupMessageReaction(
+            final String emoji, final boolean remove, final String targetAuthor, final long targetSentTimestamp, final byte[] groupId
+    ) {
+        try {
+            final var results = m.sendGroupMessageReaction(emoji, remove, targetAuthor, targetSentTimestamp, GroupId.unknownVersion(groupId));
+            checkSendMessageResults(results.first(), results.second());
+            return results.first();
+        } catch (IOException e) {
+            throw new Error.Failure(e.getMessage());
+        } catch (InvalidNumberException e) {
+            throw new Error.InvalidNumber(e.getMessage());
+        } catch (GroupNotFoundException | NotAGroupMemberException e) {
+            throw new Error.GroupNotFound(e.getMessage());
+        }
+    }
+
     // Since contact names might be empty if not defined, also potentially return
     // the profile name
     @Override