]> nmode's Git Repositories - signal-cli/commitdiff
Add sendPaymentNotification dbus method
authorAsamK <asamk@gmx.de>
Sun, 18 Sep 2022 14:56:30 +0000 (16:56 +0200)
committerAsamK <asamk@gmx.de>
Sun, 18 Sep 2022 14:56:30 +0000 (16:56 +0200)
Closes #1010

man/signal-cli-dbus.5.adoc
src/main/java/org/asamk/Signal.java
src/main/java/org/asamk/signal/dbus/DbusManagerImpl.java
src/main/java/org/asamk/signal/dbus/DbusSignalImpl.java

index 2a83e50ce7594dfc26780e07136e54ee0a4f7324..bc3ad40de1ee1b6435d72242877bb6c716a79ead 100644 (file)
@@ -202,6 +202,15 @@ Depending on the type of the recipient(s) field this sends a reaction to one or
 
 Exceptions: Failure, InvalidNumber
 
+sendPaymentNotification(receipt<ay>, note<s>, recipient<s>) -> timestamp<x>::
+* receipt : Byte array with the payment receipt blob
+* note : String with a note for the payment
+* recipient : String with the phone number of a single recipient
+
+* timestamp : Long, can be used to identify the corresponding Signal reply
+
+Exceptions: Failure
+
 sendNoteToSelfMessage(message<s>, attachments<as>) -> timestamp<x>::
 * message : Text to send (can be UTF8)
 * attachments : String array of filenames to send as attachments (passed as filename, so need to be readable by the user signal-cli is running under)
index caf55555a4184cf4919aa26a70ca9d41b8505c90..c65d75c0b5aa1795069c52c70a32f75dbb75cdcd 100644 (file)
@@ -62,6 +62,8 @@ public interface Signal extends DBusInterface {
             String emoji, boolean remove, String targetAuthor, long targetSentTimestamp, List<String> recipients
     ) throws Error.InvalidNumber, Error.Failure;
 
+    long sendPaymentNotification(byte[] receipt, String note, String recipient) throws Error.Failure;
+
     void sendContacts() throws Error.Failure;
 
     void sendSyncRequest() throws Error.Failure;
index e13aee4dd652e36810195d68726edc91a78ca0de..b78f8022b8feced5761313c512b11a726f604184 100644 (file)
@@ -388,7 +388,8 @@ public class DbusManagerImpl implements Manager {
     public SendMessageResults sendPaymentNotificationMessage(
             final byte[] receipt, final String note, final RecipientIdentifier.Single recipient
     ) throws IOException {
-        throw new UnsupportedOperationException();
+        final var timestamp = signal.sendPaymentNotification(receipt, note, recipient.getIdentifier());
+        return new SendMessageResults(timestamp, Map.of());
     }
 
     @Override
index d2ac27a987254b699703028489e0ee70af1412cc..a65c183b030b792a04546c020755c2ade46185c1 100644 (file)
@@ -298,6 +298,21 @@ public class DbusSignalImpl implements Signal {
         }
     }
 
+    @Override
+    public long sendPaymentNotification(
+            final byte[] receipt, final String note, final String recipient
+    ) throws Error.Failure {
+        try {
+            final var results = m.sendPaymentNotificationMessage(receipt,
+                    note,
+                    getSingleRecipientIdentifier(recipient, m.getSelfNumber()));
+            checkSendMessageResults(results);
+            return results.timestamp();
+        } catch (IOException e) {
+            throw new Error.Failure(e.getMessage());
+        }
+    }
+
     @Override
     public void sendTyping(
             final String recipient, final boolean stop