]> nmode's Git Repositories - signal-cli/blobdiff - src/main/java/org/asamk/signal/dbus/DbusSignalImpl.java
Implement replying to stories
[signal-cli] / src / main / java / org / asamk / signal / dbus / DbusSignalImpl.java
index d2ac27a987254b699703028489e0ee70af1412cc..1a9118be1f2065ce82134dca21908d81efa4fda1 100644 (file)
@@ -10,6 +10,8 @@ import org.asamk.signal.manager.api.InvalidNumberException;
 import org.asamk.signal.manager.api.InvalidStickerException;
 import org.asamk.signal.manager.api.Message;
 import org.asamk.signal.manager.api.NotPrimaryDeviceException;
+import org.asamk.signal.manager.api.PendingAdminApprovalException;
+import org.asamk.signal.manager.api.RecipientAddress;
 import org.asamk.signal.manager.api.RecipientIdentifier;
 import org.asamk.signal.manager.api.SendMessageResult;
 import org.asamk.signal.manager.api.SendMessageResults;
@@ -27,7 +29,6 @@ import org.asamk.signal.manager.groups.GroupPermission;
 import org.asamk.signal.manager.groups.GroupSendingNotAllowedException;
 import org.asamk.signal.manager.groups.LastGroupAdminException;
 import org.asamk.signal.manager.groups.NotAGroupMemberException;
-import org.asamk.signal.manager.storage.recipients.RecipientAddress;
 import org.asamk.signal.util.SendMessageResultUtils;
 import org.freedesktop.dbus.DBusPath;
 import org.freedesktop.dbus.connections.impl.DBusConnection;
@@ -217,7 +218,8 @@ public class DbusSignalImpl implements Signal {
                             List.of(),
                             Optional.empty(),
                             Optional.empty(),
-                            List.of()),
+                            List.of(),
+                            Optional.empty()),
                     getSingleRecipientIdentifiers(recipients, m.getSelfNumber()).stream()
                             .map(RecipientIdentifier.class::cast)
                             .collect(Collectors.toSet()));
@@ -286,7 +288,8 @@ public class DbusSignalImpl implements Signal {
                     targetSentTimestamp,
                     getSingleRecipientIdentifiers(recipients, m.getSelfNumber()).stream()
                             .map(RecipientIdentifier.class::cast)
-                            .collect(Collectors.toSet()));
+                            .collect(Collectors.toSet()),
+                    false);
             checkSendMessageResults(results);
             return results.timestamp();
         } catch (IOException e) {
@@ -298,6 +301,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
@@ -369,7 +387,8 @@ public class DbusSignalImpl implements Signal {
                     List.of(),
                     Optional.empty(),
                     Optional.empty(),
-                    List.of()), Set.of(RecipientIdentifier.NoteToSelf.INSTANCE));
+                    List.of(),
+                    Optional.empty()), Set.of(RecipientIdentifier.NoteToSelf.INSTANCE));
             checkSendMessageResults(results);
             return results.timestamp();
         } catch (AttachmentInvalidException e) {
@@ -411,7 +430,8 @@ public class DbusSignalImpl implements Signal {
                     List.of(),
                     Optional.empty(),
                     Optional.empty(),
-                    List.of()), Set.of(getGroupRecipientIdentifier(groupId)));
+                    List.of(),
+                    Optional.empty()), Set.of(getGroupRecipientIdentifier(groupId)));
             checkSendMessageResults(results);
             return results.timestamp();
         } catch (IOException | InvalidStickerException e) {
@@ -469,7 +489,8 @@ public class DbusSignalImpl implements Signal {
                     remove,
                     getSingleRecipientIdentifier(targetAuthor, m.getSelfNumber()),
                     targetSentTimestamp,
-                    Set.of(getGroupRecipientIdentifier(groupId)));
+                    Set.of(getGroupRecipientIdentifier(groupId)),
+                    false);
             checkSendMessageResults(results);
             return results.timestamp();
         } catch (IOException e) {
@@ -763,6 +784,8 @@ public class DbusSignalImpl implements Signal {
             }
             final var result = m.joinGroup(linkUrl);
             return result.first().serialize();
+        } catch (PendingAdminApprovalException e) {
+            throw new Error.Failure("Pending admin approval: " + e.getMessage());
         } catch (GroupInviteLinkUrl.InvalidGroupLinkException | InactiveGroupLinkException e) {
             throw new Error.Failure("Group link is invalid: " + e.getMessage());
         } catch (GroupInviteLinkUrl.UnknownGroupLinkVersionException e) {