]> nmode's Git Repositories - signal-cli/blobdiff - src/main/java/org/asamk/signal/dbus/DbusSignalImpl.java
Update gradle
[signal-cli] / src / main / java / org / asamk / signal / dbus / DbusSignalImpl.java
index f4a9cda832d322f6fb3c1437c4cd77a453e45387..a65c183b030b792a04546c020755c2ade46185c1 100644 (file)
@@ -9,7 +9,7 @@ import org.asamk.signal.manager.api.InvalidDeviceLinkException;
 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.NotMasterDeviceException;
+import org.asamk.signal.manager.api.NotPrimaryDeviceException;
 import org.asamk.signal.manager.api.RecipientIdentifier;
 import org.asamk.signal.manager.api.SendMessageResult;
 import org.asamk.signal.manager.api.SendMessageResults;
@@ -17,6 +17,7 @@ import org.asamk.signal.manager.api.StickerPackInvalidException;
 import org.asamk.signal.manager.api.TypingAction;
 import org.asamk.signal.manager.api.UnregisteredRecipientException;
 import org.asamk.signal.manager.api.UpdateGroup;
+import org.asamk.signal.manager.api.UpdateProfile;
 import org.asamk.signal.manager.api.UserStatus;
 import org.asamk.signal.manager.groups.GroupId;
 import org.asamk.signal.manager.groups.GroupInviteLinkUrl;
@@ -215,7 +216,8 @@ public class DbusSignalImpl implements Signal {
                             attachments,
                             List.of(),
                             Optional.empty(),
-                            Optional.empty()),
+                            Optional.empty(),
+                            List.of()),
                     getSingleRecipientIdentifiers(recipients, m.getSelfNumber()).stream()
                             .map(RecipientIdentifier.class::cast)
                             .collect(Collectors.toSet()));
@@ -296,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
@@ -366,7 +383,8 @@ public class DbusSignalImpl implements Signal {
                     attachments,
                     List.of(),
                     Optional.empty(),
-                    Optional.empty()), Set.of(RecipientIdentifier.NoteToSelf.INSTANCE));
+                    Optional.empty(),
+                    List.of()), Set.of(RecipientIdentifier.NoteToSelf.INSTANCE));
             checkSendMessageResults(results);
             return results.timestamp();
         } catch (AttachmentInvalidException e) {
@@ -407,7 +425,8 @@ public class DbusSignalImpl implements Signal {
                     attachments,
                     List.of(),
                     Optional.empty(),
-                    Optional.empty()), Set.of(getGroupRecipientIdentifier(groupId)));
+                    Optional.empty(),
+                    List.of()), Set.of(getGroupRecipientIdentifier(groupId)));
             checkSendMessageResults(results);
             return results.timestamp();
         } catch (IOException | InvalidStickerException e) {
@@ -488,8 +507,8 @@ public class DbusSignalImpl implements Signal {
     @Override
     public void setContactName(final String number, final String name) {
         try {
-            m.setContactName(getSingleRecipientIdentifier(number, m.getSelfNumber()), name);
-        } catch (NotMasterDeviceException e) {
+            m.setContactName(getSingleRecipientIdentifier(number, m.getSelfNumber()), name, "");
+        } catch (NotPrimaryDeviceException e) {
             throw new Error.Failure("This command doesn't work on linked devices.");
         } catch (IOException e) {
             throw new Error.Failure("Contact is not registered.");
@@ -513,7 +532,7 @@ public class DbusSignalImpl implements Signal {
     public void setContactBlocked(final String number, final boolean blocked) {
         try {
             m.setContactsBlocked(List.of(getSingleRecipientIdentifier(number, m.getSelfNumber())), blocked);
-        } catch (NotMasterDeviceException e) {
+        } catch (NotPrimaryDeviceException e) {
             throw new Error.Failure("This command doesn't work on linked devices.");
         } catch (IOException e) {
             throw new Error.Failure(e.getMessage());
@@ -526,7 +545,7 @@ public class DbusSignalImpl implements Signal {
     public void setGroupBlocked(final byte[] groupId, final boolean blocked) {
         try {
             m.setGroupsBlocked(List.of(getGroupId(groupId)), blocked);
-        } catch (NotMasterDeviceException e) {
+        } catch (NotPrimaryDeviceException e) {
             throw new Error.Failure("This command doesn't work on linked devices.");
         } catch (GroupNotFoundException e) {
             throw new Error.GroupNotFound(e.getMessage());
@@ -662,10 +681,15 @@ public class DbusSignalImpl implements Signal {
             about = nullIfEmpty(about);
             aboutEmoji = nullIfEmpty(aboutEmoji);
             avatarPath = nullIfEmpty(avatarPath);
-            Optional<File> avatarFile = removeAvatar
-                    ? Optional.empty()
-                    : avatarPath == null ? null : Optional.of(new File(avatarPath));
-            m.setProfile(givenName, familyName, about, aboutEmoji, avatarFile);
+            File avatarFile = removeAvatar || avatarPath == null ? null : new File(avatarPath);
+            m.updateProfile(UpdateProfile.newBuilder()
+                    .withGivenName(givenName)
+                    .withFamilyName(familyName)
+                    .withAbout(about)
+                    .withAboutEmoji(aboutEmoji)
+                    .withAvatar(avatarFile)
+                    .withDeleteAvatar(removeAvatar)
+                    .build());
         } catch (IOException e) {
             throw new Error.Failure(e.getMessage());
         }
@@ -688,7 +712,7 @@ public class DbusSignalImpl implements Signal {
             m.setRegistrationLockPin(Optional.empty());
         } catch (IOException e) {
             throw new Error.Failure("Remove pin error: " + e.getMessage());
-        } catch (NotMasterDeviceException e) {
+        } catch (NotPrimaryDeviceException e) {
             throw new Error.Failure("This command doesn't work on linked devices.");
         }
     }
@@ -699,7 +723,7 @@ public class DbusSignalImpl implements Signal {
             m.setRegistrationLockPin(Optional.of(registrationLockPin));
         } catch (IOException e) {
             throw new Error.Failure("Set pin error: " + e.getMessage());
-        } catch (NotMasterDeviceException e) {
+        } catch (NotPrimaryDeviceException e) {
             throw new Error.Failure("This command doesn't work on linked devices.");
         }
     }
@@ -1086,7 +1110,7 @@ public class DbusSignalImpl implements Signal {
                         Optional.ofNullable(linkPreviews)));
             } catch (IOException e) {
                 throw new Error.Failure("UpdateAccount error: " + e.getMessage());
-            } catch (NotMasterDeviceException e) {
+            } catch (NotPrimaryDeviceException e) {
                 throw new Error.Failure("This command doesn't work on linked devices.");
             }
         }
@@ -1264,7 +1288,7 @@ public class DbusSignalImpl implements Signal {
         private void setIsBlocked(final boolean isBlocked) {
             try {
                 m.setGroupsBlocked(List.of(groupId), isBlocked);
-            } catch (NotMasterDeviceException e) {
+            } catch (NotPrimaryDeviceException e) {
                 throw new Error.Failure("This command doesn't work on linked devices.");
             } catch (GroupNotFoundException e) {
                 throw new Error.GroupNotFound(e.getMessage());