1 package org
.asamk
.signal
.dbus
;
3 import org
.asamk
.Signal
;
4 import org
.asamk
.signal
.BaseConfig
;
5 import org
.asamk
.signal
.manager
.Manager
;
6 import org
.asamk
.signal
.manager
.api
.AttachmentInvalidException
;
7 import org
.asamk
.signal
.manager
.api
.DeviceLinkUrl
;
8 import org
.asamk
.signal
.manager
.api
.GroupId
;
9 import org
.asamk
.signal
.manager
.api
.GroupInviteLinkUrl
;
10 import org
.asamk
.signal
.manager
.api
.GroupLinkState
;
11 import org
.asamk
.signal
.manager
.api
.GroupNotFoundException
;
12 import org
.asamk
.signal
.manager
.api
.GroupPermission
;
13 import org
.asamk
.signal
.manager
.api
.GroupSendingNotAllowedException
;
14 import org
.asamk
.signal
.manager
.api
.IdentityVerificationCode
;
15 import org
.asamk
.signal
.manager
.api
.InactiveGroupLinkException
;
16 import org
.asamk
.signal
.manager
.api
.InvalidDeviceLinkException
;
17 import org
.asamk
.signal
.manager
.api
.InvalidNumberException
;
18 import org
.asamk
.signal
.manager
.api
.InvalidStickerException
;
19 import org
.asamk
.signal
.manager
.api
.LastGroupAdminException
;
20 import org
.asamk
.signal
.manager
.api
.Message
;
21 import org
.asamk
.signal
.manager
.api
.NotAGroupMemberException
;
22 import org
.asamk
.signal
.manager
.api
.NotPrimaryDeviceException
;
23 import org
.asamk
.signal
.manager
.api
.PendingAdminApprovalException
;
24 import org
.asamk
.signal
.manager
.api
.RecipientAddress
;
25 import org
.asamk
.signal
.manager
.api
.RecipientIdentifier
;
26 import org
.asamk
.signal
.manager
.api
.SendMessageResult
;
27 import org
.asamk
.signal
.manager
.api
.SendMessageResults
;
28 import org
.asamk
.signal
.manager
.api
.StickerPackInvalidException
;
29 import org
.asamk
.signal
.manager
.api
.TypingAction
;
30 import org
.asamk
.signal
.manager
.api
.UnregisteredRecipientException
;
31 import org
.asamk
.signal
.manager
.api
.UpdateGroup
;
32 import org
.asamk
.signal
.manager
.api
.UpdateProfile
;
33 import org
.asamk
.signal
.manager
.api
.UserStatus
;
34 import org
.asamk
.signal
.util
.SendMessageResultUtils
;
35 import org
.freedesktop
.dbus
.DBusPath
;
36 import org
.freedesktop
.dbus
.connections
.impl
.DBusConnection
;
37 import org
.freedesktop
.dbus
.exceptions
.DBusException
;
38 import org
.freedesktop
.dbus
.exceptions
.DBusExecutionException
;
39 import org
.freedesktop
.dbus
.interfaces
.DBusInterface
;
40 import org
.freedesktop
.dbus
.types
.Variant
;
41 import org
.slf4j
.Logger
;
42 import org
.slf4j
.LoggerFactory
;
45 import java
.io
.IOException
;
47 import java
.net
.URISyntaxException
;
48 import java
.util
.ArrayList
;
49 import java
.util
.Arrays
;
50 import java
.util
.Base64
;
51 import java
.util
.Collection
;
52 import java
.util
.HashSet
;
53 import java
.util
.List
;
55 import java
.util
.Objects
;
56 import java
.util
.Optional
;
58 import java
.util
.UUID
;
59 import java
.util
.stream
.Collectors
;
61 import static org
.asamk
.signal
.dbus
.DbusUtils
.makeValidObjectPathElement
;
63 public class DbusSignalImpl
implements Signal
{
65 private final Manager m
;
66 private final DBusConnection connection
;
67 private final String objectPath
;
68 private final boolean noReceiveOnStart
;
70 private DBusPath thisDevice
;
71 private final List
<StructDevice
> devices
= new ArrayList
<>();
72 private final List
<StructGroup
> groups
= new ArrayList
<>();
73 private final List
<StructIdentity
> identities
= new ArrayList
<>();
74 private DbusReceiveMessageHandler dbusMessageHandler
;
75 private int subscriberCount
;
77 private final static Logger logger
= LoggerFactory
.getLogger(DbusSignalImpl
.class);
79 public DbusSignalImpl(
80 final Manager m
, DBusConnection connection
, final String objectPath
, final boolean noReceiveOnStart
83 this.connection
= connection
;
84 this.objectPath
= objectPath
;
85 this.noReceiveOnStart
= noReceiveOnStart
;
87 m
.addAddressChangedListener(() -> {
93 public void initObjects() {
95 if (!noReceiveOnStart
) {
100 private void exportObjects() {
105 updateConfiguration();
109 public void close() {
110 if (dbusMessageHandler
!= null) {
111 m
.removeReceiveHandler(dbusMessageHandler
);
112 dbusMessageHandler
= null;
117 private void unExportObjects() {
120 unExportConfiguration();
121 unExportIdentities();
122 connection
.unExportObject(this.objectPath
);
126 public String
getObjectPath() {
131 public String
getSelfNumber() {
132 return m
.getSelfNumber();
136 public void subscribeReceive() {
137 if (dbusMessageHandler
== null) {
138 dbusMessageHandler
= new DbusReceiveMessageHandler(connection
, objectPath
);
139 m
.addReceiveHandler(dbusMessageHandler
);
145 public void unsubscribeReceive() {
146 subscriberCount
= Math
.max(0, subscriberCount
- 1);
147 if (subscriberCount
== 0 && dbusMessageHandler
!= null) {
148 m
.removeReceiveHandler(dbusMessageHandler
);
149 dbusMessageHandler
= null;
154 public void submitRateLimitChallenge(String challenge
, String captcha
) {
156 m
.submitRateLimitRecaptchaChallenge(challenge
, captcha
);
157 } catch (IOException e
) {
158 throw new Error
.Failure("Submit challenge error: " + e
.getMessage());
164 public void unregister() throws Error
.Failure
{
167 } catch (IOException e
) {
168 throw new Error
.Failure("Failed to unregister: " + e
.getMessage());
173 public void deleteAccount() throws Error
.Failure
{
176 } catch (IOException e
) {
177 throw new Error
.Failure("Failed to delete account: " + e
.getMessage());
182 public void addDevice(String uri
) {
184 var deviceLinkUrl
= DeviceLinkUrl
.parseDeviceLinkUri(new URI(uri
));
185 m
.addDeviceLink(deviceLinkUrl
);
186 } catch (IOException
| InvalidDeviceLinkException e
) {
187 throw new Error
.Failure(e
.getClass().getSimpleName() + " Add device link failed. " + e
.getMessage());
188 } catch (URISyntaxException e
) {
189 throw new Error
.InvalidUri(e
.getClass().getSimpleName()
190 + " Device link uri has invalid format: "
196 public DBusPath
getDevice(long deviceId
) {
198 final var deviceOptional
= devices
.stream().filter(g
-> g
.getId().equals(deviceId
)).findFirst();
199 if (deviceOptional
.isEmpty()) {
200 throw new Error
.DeviceNotFound("Device not found");
202 return deviceOptional
.get().getObjectPath();
206 public List
<StructDevice
> listDevices() {
212 public DBusPath
getThisDevice() {
218 public long sendMessage(final String message
, final List
<String
> attachments
, final String recipient
) {
219 return sendMessage(message
, attachments
, List
.of(recipient
));
223 public long sendMessage(final String message
, final List
<String
> attachments
, final List
<String
> recipients
) {
225 final var results
= m
.sendMessage(new Message(message
,
233 getSingleRecipientIdentifiers(recipients
, m
.getSelfNumber()).stream()
234 .map(RecipientIdentifier
.class::cast
)
235 .collect(Collectors
.toSet()));
237 checkSendMessageResults(results
);
238 return results
.timestamp();
239 } catch (AttachmentInvalidException e
) {
240 throw new Error
.AttachmentInvalid(e
.getMessage());
241 } catch (IOException
| InvalidStickerException e
) {
242 throw new Error
.Failure(e
);
243 } catch (GroupNotFoundException
| NotAGroupMemberException
| GroupSendingNotAllowedException e
) {
244 throw new Error
.GroupNotFound(e
.getMessage());
245 } catch (UnregisteredRecipientException e
) {
246 throw new Error
.UntrustedIdentity(e
.getSender().getIdentifier() + " is not registered.");
251 public long sendRemoteDeleteMessage(
252 final long targetSentTimestamp
, final String recipient
254 return sendRemoteDeleteMessage(targetSentTimestamp
, List
.of(recipient
));
258 public long sendRemoteDeleteMessage(
259 final long targetSentTimestamp
, final List
<String
> recipients
262 final var results
= m
.sendRemoteDeleteMessage(targetSentTimestamp
,
263 getSingleRecipientIdentifiers(recipients
, m
.getSelfNumber()).stream()
264 .map(RecipientIdentifier
.class::cast
)
265 .collect(Collectors
.toSet()));
266 checkSendMessageResults(results
);
267 return results
.timestamp();
268 } catch (IOException e
) {
269 throw new Error
.Failure(e
.getMessage());
270 } catch (GroupNotFoundException
| NotAGroupMemberException
| GroupSendingNotAllowedException e
) {
271 throw new Error
.GroupNotFound(e
.getMessage());
276 public long sendMessageReaction(
278 final boolean remove
,
279 final String targetAuthor
,
280 final long targetSentTimestamp
,
281 final String recipient
283 return sendMessageReaction(emoji
, remove
, targetAuthor
, targetSentTimestamp
, List
.of(recipient
));
287 public long sendMessageReaction(
289 final boolean remove
,
290 final String targetAuthor
,
291 final long targetSentTimestamp
,
292 final List
<String
> recipients
295 final var results
= m
.sendMessageReaction(emoji
,
297 getSingleRecipientIdentifier(targetAuthor
, m
.getSelfNumber()),
299 getSingleRecipientIdentifiers(recipients
, m
.getSelfNumber()).stream()
300 .map(RecipientIdentifier
.class::cast
)
301 .collect(Collectors
.toSet()),
303 checkSendMessageResults(results
);
304 return results
.timestamp();
305 } catch (IOException e
) {
306 throw new Error
.Failure(e
.getMessage());
307 } catch (GroupNotFoundException
| NotAGroupMemberException
| GroupSendingNotAllowedException e
) {
308 throw new Error
.GroupNotFound(e
.getMessage());
309 } catch (UnregisteredRecipientException e
) {
310 throw new Error
.UntrustedIdentity(e
.getSender().getIdentifier() + " is not registered.");
315 public long sendPaymentNotification(
316 final byte[] receipt
, final String note
, final String recipient
317 ) throws Error
.Failure
{
319 final var results
= m
.sendPaymentNotificationMessage(receipt
,
321 getSingleRecipientIdentifier(recipient
, m
.getSelfNumber()));
322 checkSendMessageResults(results
);
323 return results
.timestamp();
324 } catch (IOException e
) {
325 throw new Error
.Failure(e
.getMessage());
330 public void sendTyping(
331 final String recipient
, final boolean stop
332 ) throws Error
.Failure
, Error
.GroupNotFound
, Error
.UntrustedIdentity
{
334 final var results
= m
.sendTypingMessage(stop ? TypingAction
.STOP
: TypingAction
.START
,
335 getSingleRecipientIdentifiers(List
.of(recipient
), m
.getSelfNumber()).stream()
336 .map(RecipientIdentifier
.class::cast
)
337 .collect(Collectors
.toSet()));
338 checkSendMessageResults(results
);
339 } catch (IOException e
) {
340 throw new Error
.Failure(e
.getMessage());
341 } catch (GroupNotFoundException
| NotAGroupMemberException
| GroupSendingNotAllowedException e
) {
342 throw new Error
.GroupNotFound(e
.getMessage());
347 public void sendReadReceipt(
348 final String recipient
, final List
<Long
> messageIds
349 ) throws Error
.Failure
, Error
.UntrustedIdentity
{
351 final var results
= m
.sendReadReceipt(getSingleRecipientIdentifier(recipient
, m
.getSelfNumber()),
353 checkSendMessageResults(results
);
354 } catch (IOException e
) {
355 throw new Error
.Failure(e
.getMessage());
360 public void sendViewedReceipt(
361 final String recipient
, final List
<Long
> messageIds
362 ) throws Error
.Failure
, Error
.UntrustedIdentity
{
364 final var results
= m
.sendViewedReceipt(getSingleRecipientIdentifier(recipient
, m
.getSelfNumber()),
366 checkSendMessageResults(results
);
367 } catch (IOException e
) {
368 throw new Error
.Failure(e
.getMessage());
373 public void sendContacts() {
376 } catch (IOException e
) {
377 throw new Error
.Failure("SendContacts error: " + e
.getMessage());
382 public void sendSyncRequest() {
384 m
.requestAllSyncData();
385 } catch (IOException e
) {
386 throw new Error
.Failure("Request sync data error: " + e
.getMessage());
391 public long sendNoteToSelfMessage(
392 final String message
, final List
<String
> attachments
393 ) throws Error
.AttachmentInvalid
, Error
.Failure
, Error
.UntrustedIdentity
{
395 final var results
= m
.sendMessage(new Message(message
,
402 List
.of()), Set
.of(RecipientIdentifier
.NoteToSelf
.INSTANCE
));
403 checkSendMessageResults(results
);
404 return results
.timestamp();
405 } catch (AttachmentInvalidException e
) {
406 throw new Error
.AttachmentInvalid(e
.getMessage());
407 } catch (IOException
| InvalidStickerException e
) {
408 throw new Error
.Failure(e
.getMessage());
409 } catch (GroupNotFoundException
| NotAGroupMemberException
| GroupSendingNotAllowedException e
) {
410 throw new Error
.GroupNotFound(e
.getMessage());
411 } catch (UnregisteredRecipientException e
) {
412 throw new Error
.UntrustedIdentity(e
.getSender().getIdentifier() + " is not registered.");
417 public void sendEndSessionMessage(final List
<String
> recipients
) {
419 final var results
= m
.sendEndSessionMessage(getSingleRecipientIdentifiers(recipients
, m
.getSelfNumber()));
420 checkSendMessageResults(results
);
421 } catch (IOException e
) {
422 throw new Error
.Failure(e
.getMessage());
427 public void deleteRecipient(final String recipient
) throws Error
.Failure
{
428 m
.deleteRecipient(getSingleRecipientIdentifier(recipient
, m
.getSelfNumber()));
432 public void deleteContact(final String recipient
) throws Error
.Failure
{
433 m
.deleteContact(getSingleRecipientIdentifier(recipient
, m
.getSelfNumber()));
437 public long sendGroupMessage(final String message
, final List
<String
> attachments
, final byte[] groupId
) {
439 var results
= m
.sendMessage(new Message(message
,
446 List
.of()), Set
.of(getGroupRecipientIdentifier(groupId
)));
447 checkSendMessageResults(results
);
448 return results
.timestamp();
449 } catch (IOException
| InvalidStickerException e
) {
450 throw new Error
.Failure(e
.getMessage());
451 } catch (GroupNotFoundException
| NotAGroupMemberException
| GroupSendingNotAllowedException e
) {
452 throw new Error
.GroupNotFound(e
.getMessage());
453 } catch (AttachmentInvalidException e
) {
454 throw new Error
.AttachmentInvalid(e
.getMessage());
455 } catch (UnregisteredRecipientException e
) {
456 throw new Error
.UntrustedIdentity(e
.getSender().getIdentifier() + " is not registered.");
461 public void sendGroupTyping(
462 final byte[] groupId
, final boolean stop
463 ) throws Error
.Failure
, Error
.GroupNotFound
, Error
.UntrustedIdentity
{
465 final var results
= m
.sendTypingMessage(stop ? TypingAction
.STOP
: TypingAction
.START
,
466 Set
.of(getGroupRecipientIdentifier(groupId
)));
467 checkSendMessageResults(results
);
468 } catch (IOException e
) {
469 throw new Error
.Failure(e
.getMessage());
470 } catch (GroupNotFoundException
| NotAGroupMemberException
| GroupSendingNotAllowedException e
) {
471 throw new Error
.GroupNotFound(e
.getMessage());
476 public long sendGroupRemoteDeleteMessage(
477 final long targetSentTimestamp
, final byte[] groupId
480 final var results
= m
.sendRemoteDeleteMessage(targetSentTimestamp
,
481 Set
.of(getGroupRecipientIdentifier(groupId
)));
482 checkSendMessageResults(results
);
483 return results
.timestamp();
484 } catch (IOException e
) {
485 throw new Error
.Failure(e
.getMessage());
486 } catch (GroupNotFoundException
| NotAGroupMemberException
| GroupSendingNotAllowedException e
) {
487 throw new Error
.GroupNotFound(e
.getMessage());
492 public long sendGroupMessageReaction(
494 final boolean remove
,
495 final String targetAuthor
,
496 final long targetSentTimestamp
,
500 final var results
= m
.sendMessageReaction(emoji
,
502 getSingleRecipientIdentifier(targetAuthor
, m
.getSelfNumber()),
504 Set
.of(getGroupRecipientIdentifier(groupId
)),
506 checkSendMessageResults(results
);
507 return results
.timestamp();
508 } catch (IOException e
) {
509 throw new Error
.Failure(e
.getMessage());
510 } catch (GroupNotFoundException
| NotAGroupMemberException
| GroupSendingNotAllowedException e
) {
511 throw new Error
.GroupNotFound(e
.getMessage());
512 } catch (UnregisteredRecipientException e
) {
513 throw new Error
.UntrustedIdentity(e
.getSender().getIdentifier() + " is not registered.");
517 // Since contact names might be empty if not defined, also potentially return
520 public String
getContactName(final String number
) {
521 final var name
= m
.getContactOrProfileName(getSingleRecipientIdentifier(number
, m
.getSelfNumber()));
522 return name
== null ?
"" : name
;
526 public void setContactName(final String number
, final String name
) {
528 m
.setContactName(getSingleRecipientIdentifier(number
, m
.getSelfNumber()), name
, "");
529 } catch (NotPrimaryDeviceException e
) {
530 throw new Error
.Failure("This command doesn't work on linked devices.");
531 } catch (IOException e
) {
532 throw new Error
.Failure("Contact is not registered.");
533 } catch (UnregisteredRecipientException e
) {
534 throw new Error
.UntrustedIdentity(e
.getSender().getIdentifier() + " is not registered.");
539 public void setExpirationTimer(final String number
, final int expiration
) {
541 m
.setExpirationTimer(getSingleRecipientIdentifier(number
, m
.getSelfNumber()), expiration
);
542 } catch (IOException e
) {
543 throw new Error
.Failure(e
.getMessage());
544 } catch (UnregisteredRecipientException e
) {
545 throw new Error
.UntrustedIdentity(e
.getSender().getIdentifier() + " is not registered.");
550 public void setContactBlocked(final String number
, final boolean blocked
) {
552 m
.setContactsBlocked(List
.of(getSingleRecipientIdentifier(number
, m
.getSelfNumber())), blocked
);
553 } catch (NotPrimaryDeviceException e
) {
554 throw new Error
.Failure("This command doesn't work on linked devices.");
555 } catch (IOException e
) {
556 throw new Error
.Failure(e
.getMessage());
557 } catch (UnregisteredRecipientException e
) {
558 throw new Error
.UntrustedIdentity(e
.getSender().getIdentifier() + " is not registered.");
563 public void setGroupBlocked(final byte[] groupId
, final boolean blocked
) {
565 m
.setGroupsBlocked(List
.of(getGroupId(groupId
)), blocked
);
566 } catch (NotPrimaryDeviceException e
) {
567 throw new Error
.Failure("This command doesn't work on linked devices.");
568 } catch (GroupNotFoundException e
) {
569 throw new Error
.GroupNotFound(e
.getMessage());
570 } catch (IOException e
) {
571 throw new Error
.Failure(e
.getMessage());
576 public List
<byte[]> getGroupIds() {
577 var groups
= m
.getGroups();
578 return groups
.stream().map(g
-> g
.groupId().serialize()).toList();
582 public DBusPath
getGroup(final byte[] groupId
) {
584 final var groupOptional
= groups
.stream().filter(g
-> Arrays
.equals(g
.getId(), groupId
)).findFirst();
585 if (groupOptional
.isEmpty()) {
586 throw new Error
.GroupNotFound("Group not found");
588 return groupOptional
.get().getObjectPath();
592 public List
<StructGroup
> listGroups() {
598 public String
getGroupName(final byte[] groupId
) {
599 var group
= m
.getGroup(getGroupId(groupId
));
600 if (group
== null || group
.title() == null) {
603 return group
.title();
608 public List
<String
> getGroupMembers(final byte[] groupId
) {
609 var group
= m
.getGroup(getGroupId(groupId
));
613 final var members
= group
.members();
614 return getRecipientStrings(members
);
619 public byte[] createGroup(
620 final String name
, final List
<String
> members
, final String avatar
621 ) throws Error
.AttachmentInvalid
, Error
.Failure
, Error
.InvalidNumber
{
622 return updateGroup(new byte[0], name
, members
, avatar
);
626 public byte[] updateGroup(byte[] groupId
, String name
, List
<String
> members
, String avatar
) {
628 groupId
= nullIfEmpty(groupId
);
629 name
= nullIfEmpty(name
);
630 avatar
= nullIfEmpty(avatar
);
631 final var memberIdentifiers
= getSingleRecipientIdentifiers(members
, m
.getSelfNumber());
632 if (groupId
== null) {
633 final var results
= m
.createGroup(name
, memberIdentifiers
, avatar
);
635 checkGroupSendMessageResults(results
.second().timestamp(), results
.second().results());
636 return results
.first().serialize();
638 final var results
= m
.updateGroup(getGroupId(groupId
),
639 UpdateGroup
.newBuilder()
641 .withMembers(memberIdentifiers
)
642 .withAvatarFile(avatar
)
644 if (results
!= null) {
645 checkGroupSendMessageResults(results
.timestamp(), results
.results());
649 } catch (IOException e
) {
650 throw new Error
.Failure(e
.getMessage());
651 } catch (GroupNotFoundException
| NotAGroupMemberException
| GroupSendingNotAllowedException e
) {
652 throw new Error
.GroupNotFound(e
.getMessage());
653 } catch (AttachmentInvalidException e
) {
654 throw new Error
.AttachmentInvalid(e
.getMessage());
655 } catch (UnregisteredRecipientException e
) {
656 throw new Error
.UntrustedIdentity(e
.getSender().getIdentifier() + " is not registered.");
661 public boolean isRegistered() {
666 public boolean isRegistered(String number
) {
667 var result
= isRegistered(List
.of(number
));
668 return result
.get(0);
672 public List
<Boolean
> isRegistered(List
<String
> numbers
) {
673 if (numbers
.isEmpty()) {
677 Map
<String
, UserStatus
> registered
;
679 registered
= m
.getUserStatus(new HashSet
<>(numbers
));
680 } catch (IOException e
) {
681 throw new Error
.Failure(e
.getMessage());
684 return numbers
.stream().map(number
-> registered
.get(number
).uuid() != null).toList();
688 public void updateProfile(
694 final boolean removeAvatar
697 givenName
= nullIfEmpty(givenName
);
698 familyName
= nullIfEmpty(familyName
);
699 about
= nullIfEmpty(about
);
700 aboutEmoji
= nullIfEmpty(aboutEmoji
);
701 avatarPath
= nullIfEmpty(avatarPath
);
702 final var avatarFile
= removeAvatar
|| avatarPath
== null ?
null : avatarPath
;
703 m
.updateProfile(UpdateProfile
.newBuilder()
704 .withGivenName(givenName
)
705 .withFamilyName(familyName
)
707 .withAboutEmoji(aboutEmoji
)
708 .withAvatar(avatarFile
)
709 .withDeleteAvatar(removeAvatar
)
711 } catch (IOException e
) {
712 throw new Error
.Failure(e
.getMessage());
717 public void updateProfile(
720 final String aboutEmoji
,
722 final boolean removeAvatar
724 updateProfile(name
, "", about
, aboutEmoji
, avatarPath
, removeAvatar
);
728 public void removePin() {
730 m
.setRegistrationLockPin(Optional
.empty());
731 } catch (IOException e
) {
732 throw new Error
.Failure("Remove pin error: " + e
.getMessage());
733 } catch (NotPrimaryDeviceException e
) {
734 throw new Error
.Failure("This command doesn't work on linked devices.");
739 public void setPin(String registrationLockPin
) {
741 m
.setRegistrationLockPin(Optional
.of(registrationLockPin
));
742 } catch (IOException e
) {
743 throw new Error
.Failure("Set pin error: " + e
.getMessage());
744 } catch (NotPrimaryDeviceException e
) {
745 throw new Error
.Failure("This command doesn't work on linked devices.");
749 // Provide option to query a version string in order to react on potential
750 // future interface changes
752 public String
version() {
753 return BaseConfig
.PROJECT_VERSION
;
756 // Create a unique list of Numbers from Identities and Contacts to really get
757 // all numbers the system knows
759 public List
<String
> listNumbers() {
760 return m
.getRecipients(false, Optional
.empty(), Set
.of(), Optional
.empty())
762 .map(r
-> r
.getAddress().number().orElse(null))
763 .filter(Objects
::nonNull
)
769 public List
<String
> getContactNumber(final String name
) {
770 return m
.getRecipients(false, Optional
.empty(), Set
.of(), Optional
.of(name
))
772 .map(r
-> r
.getAddress().getLegacyIdentifier())
777 public void quitGroup(final byte[] groupId
) {
778 var group
= getGroupId(groupId
);
780 m
.quitGroup(group
, Set
.of());
781 } catch (GroupNotFoundException
| NotAGroupMemberException e
) {
782 throw new Error
.GroupNotFound(e
.getMessage());
783 } catch (IOException
| LastGroupAdminException e
) {
784 throw new Error
.Failure(e
.getMessage());
785 } catch (UnregisteredRecipientException e
) {
786 throw new Error
.UntrustedIdentity(e
.getSender().getIdentifier() + " is not registered.");
791 public byte[] joinGroup(final String groupLink
) {
793 final var linkUrl
= GroupInviteLinkUrl
.fromUri(groupLink
);
794 if (linkUrl
== null) {
795 throw new Error
.Failure("Group link is invalid:");
797 final var result
= m
.joinGroup(linkUrl
);
798 return result
.first().serialize();
799 } catch (PendingAdminApprovalException e
) {
800 throw new Error
.Failure("Pending admin approval: " + e
.getMessage());
801 } catch (GroupInviteLinkUrl
.InvalidGroupLinkException
| InactiveGroupLinkException e
) {
802 throw new Error
.Failure("Group link is invalid: " + e
.getMessage());
803 } catch (GroupInviteLinkUrl
.UnknownGroupLinkVersionException e
) {
804 throw new Error
.Failure("Group link was created with an incompatible version: " + e
.getMessage());
805 } catch (IOException e
) {
806 throw new Error
.Failure(e
.getMessage());
811 public boolean isContactBlocked(final String number
) {
812 return m
.isContactBlocked(getSingleRecipientIdentifier(number
, m
.getSelfNumber()));
816 public boolean isGroupBlocked(final byte[] groupId
) {
817 var group
= m
.getGroup(getGroupId(groupId
));
821 return group
.isBlocked();
826 public boolean isMember(final byte[] groupId
) {
827 var group
= m
.getGroup(getGroupId(groupId
));
831 return group
.isMember();
836 public String
uploadStickerPack(String stickerPackPath
) {
837 File path
= new File(stickerPackPath
);
839 return m
.uploadStickerPack(path
).toString();
840 } catch (IOException e
) {
841 throw new Error
.Failure("Upload error (maybe image size is too large):" + e
.getMessage());
842 } catch (StickerPackInvalidException e
) {
843 throw new Error
.Failure("Invalid sticker pack: " + e
.getMessage());
847 private static void checkSendMessageResult(long timestamp
, SendMessageResult result
) throws DBusExecutionException
{
848 var error
= SendMessageResultUtils
.getErrorMessageFromSendMessageResult(result
);
854 final var message
= "\nFailed to send message:\n" + error
+ '\n' + timestamp
;
856 if (result
.isIdentityFailure()) {
857 throw new Error
.UntrustedIdentity(message
);
859 throw new Error
.Failure(message
);
863 private void checkSendMessageResults(final SendMessageResults results
) {
864 final var sendMessageResults
= results
.results().values().stream().findFirst();
865 if (results
.results().size() == 1 && sendMessageResults
.get().size() == 1) {
866 checkSendMessageResult(results
.timestamp(), sendMessageResults
.get().stream().findFirst().get());
870 if (results
.hasSuccess()) {
874 var message
= new StringBuilder();
875 message
.append("Failed to send messages:\n");
876 var errors
= SendMessageResultUtils
.getErrorMessagesFromSendMessageResults(results
.results());
877 for (var error
: errors
) {
878 message
.append(error
).append('\n');
880 message
.append(results
.timestamp());
882 throw new Error
.Failure(message
.toString());
885 private static void checkGroupSendMessageResults(
886 long timestamp
, Collection
<SendMessageResult
> results
887 ) throws DBusExecutionException
{
888 if (results
.size() == 1) {
889 checkSendMessageResult(timestamp
, results
.stream().findFirst().get());
893 var errors
= SendMessageResultUtils
.getErrorMessagesFromSendMessageResults(results
);
894 if (errors
.size() == 0 || errors
.size() < results
.size()) {
898 var message
= new StringBuilder();
899 message
.append("Failed to send message:\n");
900 for (var error
: errors
) {
901 message
.append(error
).append('\n');
903 message
.append(timestamp
);
905 throw new Error
.Failure(message
.toString());
908 private static List
<String
> getRecipientStrings(final Set
<RecipientAddress
> members
) {
909 return members
.stream().map(RecipientAddress
::getLegacyIdentifier
).toList();
912 private static Set
<RecipientIdentifier
.Single
> getSingleRecipientIdentifiers(
913 final Collection
<String
> recipientStrings
, final String localNumber
914 ) throws DBusExecutionException
{
915 final var identifiers
= new HashSet
<RecipientIdentifier
.Single
>();
916 for (var recipientString
: recipientStrings
) {
917 identifiers
.add(getSingleRecipientIdentifier(recipientString
, localNumber
));
922 private static RecipientIdentifier
.Single
getSingleRecipientIdentifier(
923 final String recipientString
, final String localNumber
924 ) throws DBusExecutionException
{
926 return RecipientIdentifier
.Single
.fromString(recipientString
, localNumber
);
927 } catch (InvalidNumberException e
) {
928 throw new Error
.InvalidNumber(e
.getMessage());
932 private RecipientIdentifier
.Group
getGroupRecipientIdentifier(final byte[] groupId
) {
933 return new RecipientIdentifier
.Group(getGroupId(groupId
));
936 private static GroupId
getGroupId(byte[] groupId
) throws DBusExecutionException
{
938 return GroupId
.unknownVersion(groupId
);
939 } catch (Throwable e
) {
940 throw new Error
.InvalidGroupId("Invalid group id: " + e
.getMessage());
944 private byte[] nullIfEmpty(final byte[] array
) {
945 return array
.length
== 0 ?
null : array
;
948 private String
nullIfEmpty(final String name
) {
949 return name
.isEmpty() ?
null : name
;
952 private String
emptyIfNull(final String string
) {
953 return string
== null ?
"" : string
;
956 private static String
getDeviceObjectPath(String basePath
, long deviceId
) {
957 return basePath
+ "/Devices/" + deviceId
;
960 private void updateDevices() {
961 List
<org
.asamk
.signal
.manager
.api
.Device
> linkedDevices
;
963 linkedDevices
= m
.getLinkedDevices();
964 } catch (IOException e
) {
965 throw new Error
.Failure("Failed to get linked devices: " + e
.getMessage());
970 linkedDevices
.forEach(d
-> {
971 final var object
= new DbusSignalDeviceImpl(d
);
972 final var deviceObjectPath
= object
.getObjectPath();
973 exportObject(object
);
974 if (d
.isThisDevice()) {
975 thisDevice
= new DBusPath(deviceObjectPath
);
977 this.devices
.add(new StructDevice(new DBusPath(deviceObjectPath
), (long) d
.id(), emptyIfNull(d
.name())));
981 private void unExportDevices() {
982 this.devices
.stream()
983 .map(StructDevice
::getObjectPath
)
984 .map(DBusPath
::getPath
)
985 .forEach(connection
::unExportObject
);
986 this.devices
.clear();
989 private static String
getGroupObjectPath(String basePath
, byte[] groupId
) {
990 return basePath
+ "/Groups/" + makeValidObjectPathElement(Base64
.getEncoder().encodeToString(groupId
));
993 private void updateGroups() {
994 List
<org
.asamk
.signal
.manager
.api
.Group
> groups
;
995 groups
= m
.getGroups();
999 groups
.forEach(g
-> {
1000 final var object
= new DbusSignalGroupImpl(g
.groupId());
1001 exportObject(object
);
1002 this.groups
.add(new StructGroup(new DBusPath(object
.getObjectPath()),
1003 g
.groupId().serialize(),
1004 emptyIfNull(g
.title())));
1008 private void unExportGroups() {
1009 this.groups
.stream().map(StructGroup
::getObjectPath
).map(DBusPath
::getPath
).forEach(connection
::unExportObject
);
1010 this.groups
.clear();
1013 private static String
getConfigurationObjectPath(String basePath
) {
1014 return basePath
+ "/Configuration";
1017 private void updateConfiguration() {
1018 unExportConfiguration();
1019 final var object
= new DbusSignalConfigurationImpl();
1020 exportObject(object
);
1023 private void unExportConfiguration() {
1024 final var objectPath
= getConfigurationObjectPath(this.objectPath
);
1025 connection
.unExportObject(objectPath
);
1028 private void exportObject(final DBusInterface object
) {
1030 connection
.exportObject(object
);
1031 logger
.debug("Exported dbus object: " + object
.getObjectPath());
1032 } catch (DBusException e
) {
1033 e
.printStackTrace();
1037 private void updateIdentities() {
1038 List
<org
.asamk
.signal
.manager
.api
.Identity
> identities
;
1039 identities
= m
.getIdentities();
1041 unExportIdentities();
1043 identities
.forEach(i
-> {
1044 final var object
= new DbusSignalIdentityImpl(i
);
1045 exportObject(object
);
1046 this.identities
.add(new StructIdentity(new DBusPath(object
.getObjectPath()),
1047 i
.recipient().uuid().map(UUID
::toString
).orElse(""),
1048 i
.recipient().number().orElse("")));
1052 private static String
getIdentityObjectPath(String basePath
, String id
) {
1053 return basePath
+ "/Identities/" + makeValidObjectPathElement(id
);
1056 private void unExportIdentities() {
1057 this.identities
.stream()
1058 .map(StructIdentity
::getObjectPath
)
1059 .map(DBusPath
::getPath
)
1060 .forEach(connection
::unExportObject
);
1061 this.identities
.clear();
1065 public DBusPath
getIdentity(String number
) throws Error
.Failure
{
1066 final var found
= identities
.stream()
1067 .filter(identity
-> identity
.getNumber().equals(number
) || identity
.getUuid().equals(number
))
1070 if (found
.isEmpty()) {
1071 throw new Error
.Failure("Identity for " + number
+ " unknown");
1073 return found
.get().getObjectPath();
1077 public List
<StructIdentity
> listIdentities() {
1079 return this.identities
;
1082 public class DbusSignalIdentityImpl
extends DbusProperties
implements Signal
.Identity
{
1084 private final org
.asamk
.signal
.manager
.api
.Identity identity
;
1086 public DbusSignalIdentityImpl(final org
.asamk
.signal
.manager
.api
.Identity identity
) {
1087 this.identity
= identity
;
1088 super.addPropertiesHandler(new DbusInterfacePropertiesHandler("org.asamk.Signal.Identity",
1089 List
.of(new DbusProperty
<>("Number", () -> identity
.recipient().number().orElse("")),
1090 new DbusProperty
<>("Uuid",
1091 () -> identity
.recipient().uuid().map(UUID
::toString
).orElse("")),
1092 new DbusProperty
<>("Fingerprint", identity
::getFingerprint
),
1093 new DbusProperty
<>("SafetyNumber", identity
::safetyNumber
),
1094 new DbusProperty
<>("ScannableSafetyNumber", identity
::scannableSafetyNumber
),
1095 new DbusProperty
<>("TrustLevel", identity
::trustLevel
),
1096 new DbusProperty
<>("AddedDate", identity
::dateAddedTimestamp
))));
1100 public String
getObjectPath() {
1101 return getIdentityObjectPath(objectPath
, identity
.recipient().getLegacyIdentifier());
1105 public void trust() throws Error
.Failure
{
1106 var recipient
= RecipientIdentifier
.Single
.fromAddress(identity
.recipient());
1108 m
.trustIdentityAllKeys(recipient
);
1109 } catch (UnregisteredRecipientException e
) {
1110 throw new Error
.Failure("The user " + e
.getSender().getIdentifier() + " is not registered.");
1116 public void trustVerified(String safetyNumber
) throws Error
.Failure
{
1117 var recipient
= RecipientIdentifier
.Single
.fromAddress(identity
.recipient());
1119 if (safetyNumber
== null) {
1120 throw new Error
.Failure("You need to specify a fingerprint/safety number");
1122 final IdentityVerificationCode verificationCode
;
1124 verificationCode
= IdentityVerificationCode
.parse(safetyNumber
);
1125 } catch (Exception e
) {
1126 throw new Error
.Failure(
1127 "Safety number has invalid format, either specify the old hex fingerprint or the new safety number");
1131 final var res
= m
.trustIdentityVerified(recipient
, verificationCode
);
1133 throw new Error
.Failure(
1134 "Failed to set the trust for this number, make sure the number and the fingerprint/safety number are correct.");
1136 } catch (UnregisteredRecipientException e
) {
1137 throw new Error
.Failure("The user " + e
.getSender().getIdentifier() + " is not registered.");
1143 public class DbusSignalDeviceImpl
extends DbusProperties
implements Signal
.Device
{
1145 private final org
.asamk
.signal
.manager
.api
.Device device
;
1147 public DbusSignalDeviceImpl(final org
.asamk
.signal
.manager
.api
.Device device
) {
1148 super.addPropertiesHandler(new DbusInterfacePropertiesHandler("org.asamk.Signal.Device",
1149 List
.of(new DbusProperty
<>("Id", device
::id
),
1150 new DbusProperty
<>("Name", () -> emptyIfNull(device
.name()), this::setDeviceName
),
1151 new DbusProperty
<>("Created", device
::created
),
1152 new DbusProperty
<>("LastSeen", device
::lastSeen
))));
1153 this.device
= device
;
1157 public String
getObjectPath() {
1158 return getDeviceObjectPath(objectPath
, device
.id());
1162 public void removeDevice() throws Error
.Failure
{
1164 m
.removeLinkedDevices(device
.id());
1166 } catch (IOException e
) {
1167 throw new Error
.Failure(e
.getMessage());
1171 private void setDeviceName(String name
) {
1172 if (!device
.isThisDevice()) {
1173 throw new Error
.Failure("Only the name of this device can be changed");
1176 m
.updateAccountAttributes(name
);
1177 // update device list
1179 } catch (IOException e
) {
1180 throw new Error
.Failure(e
.getMessage());
1185 public class DbusSignalConfigurationImpl
extends DbusProperties
implements Signal
.Configuration
{
1187 public DbusSignalConfigurationImpl() {
1188 super.addPropertiesHandler(new DbusInterfacePropertiesHandler("org.asamk.Signal.Configuration",
1189 List
.of(new DbusProperty
<>("ReadReceipts", this::getReadReceipts
, this::setReadReceipts
),
1190 new DbusProperty
<>("UnidentifiedDeliveryIndicators",
1191 this::getUnidentifiedDeliveryIndicators
,
1192 this::setUnidentifiedDeliveryIndicators
),
1193 new DbusProperty
<>("TypingIndicators",
1194 this::getTypingIndicators
,
1195 this::setTypingIndicators
),
1196 new DbusProperty
<>("LinkPreviews", this::getLinkPreviews
, this::setLinkPreviews
))));
1201 public String
getObjectPath() {
1202 return getConfigurationObjectPath(objectPath
);
1205 public void setReadReceipts(Boolean readReceipts
) {
1206 setConfiguration(readReceipts
, null, null, null);
1209 public void setUnidentifiedDeliveryIndicators(Boolean unidentifiedDeliveryIndicators
) {
1210 setConfiguration(null, unidentifiedDeliveryIndicators
, null, null);
1213 public void setTypingIndicators(Boolean typingIndicators
) {
1214 setConfiguration(null, null, typingIndicators
, null);
1217 public void setLinkPreviews(Boolean linkPreviews
) {
1218 setConfiguration(null, null, null, linkPreviews
);
1221 private void setConfiguration(
1222 Boolean readReceipts
,
1223 Boolean unidentifiedDeliveryIndicators
,
1224 Boolean typingIndicators
,
1225 Boolean linkPreviews
1228 m
.updateConfiguration(new org
.asamk
.signal
.manager
.api
.Configuration(Optional
.ofNullable(readReceipts
),
1229 Optional
.ofNullable(unidentifiedDeliveryIndicators
),
1230 Optional
.ofNullable(typingIndicators
),
1231 Optional
.ofNullable(linkPreviews
)));
1232 } catch (IOException e
) {
1233 throw new Error
.Failure("UpdateAccount error: " + e
.getMessage());
1234 } catch (NotPrimaryDeviceException e
) {
1235 throw new Error
.Failure("This command doesn't work on linked devices.");
1239 private boolean getReadReceipts() {
1240 return m
.getConfiguration().readReceipts().orElse(false);
1243 private boolean getUnidentifiedDeliveryIndicators() {
1244 return m
.getConfiguration().unidentifiedDeliveryIndicators().orElse(false);
1247 private boolean getTypingIndicators() {
1248 return m
.getConfiguration().typingIndicators().orElse(false);
1251 private boolean getLinkPreviews() {
1252 return m
.getConfiguration().linkPreviews().orElse(false);
1256 public class DbusSignalGroupImpl
extends DbusProperties
implements Signal
.Group
{
1258 private final GroupId groupId
;
1260 public DbusSignalGroupImpl(final GroupId groupId
) {
1261 this.groupId
= groupId
;
1262 super.addPropertiesHandler(new DbusInterfacePropertiesHandler("org.asamk.Signal.Group",
1263 List
.of(new DbusProperty
<>("Id", groupId
::serialize
),
1264 new DbusProperty
<>("Name", () -> emptyIfNull(getGroup().title()), this::setGroupName
),
1265 new DbusProperty
<>("Description",
1266 () -> emptyIfNull(getGroup().description()),
1267 this::setGroupDescription
),
1268 new DbusProperty
<>("Avatar", this::setGroupAvatar
),
1269 new DbusProperty
<>("IsBlocked", () -> getGroup().isBlocked(), this::setIsBlocked
),
1270 new DbusProperty
<>("IsMember", () -> getGroup().isMember()),
1271 new DbusProperty
<>("IsAdmin", () -> getGroup().isAdmin()),
1272 new DbusProperty
<>("MessageExpirationTimer",
1273 () -> getGroup().messageExpirationTimer(),
1274 this::setMessageExpirationTime
),
1275 new DbusProperty
<>("Members",
1276 () -> new Variant
<>(getRecipientStrings(getGroup().members()), "as")),
1277 new DbusProperty
<>("PendingMembers",
1278 () -> new Variant
<>(getRecipientStrings(getGroup().pendingMembers()), "as")),
1279 new DbusProperty
<>("RequestingMembers",
1280 () -> new Variant
<>(getRecipientStrings(getGroup().requestingMembers()), "as")),
1281 new DbusProperty
<>("Admins",
1282 () -> new Variant
<>(getRecipientStrings(getGroup().adminMembers()), "as")),
1283 new DbusProperty
<>("Banned",
1284 () -> new Variant
<>(getRecipientStrings(getGroup().bannedMembers()), "as")),
1285 new DbusProperty
<>("PermissionAddMember",
1286 () -> getGroup().permissionAddMember().name(),
1287 this::setGroupPermissionAddMember
),
1288 new DbusProperty
<>("PermissionEditDetails",
1289 () -> getGroup().permissionEditDetails().name(),
1290 this::setGroupPermissionEditDetails
),
1291 new DbusProperty
<>("PermissionSendMessage",
1292 () -> getGroup().permissionSendMessage().name(),
1293 this::setGroupPermissionSendMessage
),
1294 new DbusProperty
<>("GroupInviteLink", () -> {
1295 final var groupInviteLinkUrl
= getGroup().groupInviteLinkUrl();
1296 return groupInviteLinkUrl
== null ?
"" : groupInviteLinkUrl
.getUrl();
1301 public String
getObjectPath() {
1302 return getGroupObjectPath(objectPath
, groupId
.serialize());
1306 public void quitGroup() throws Error
.Failure
{
1308 m
.quitGroup(groupId
, Set
.of());
1309 } catch (GroupNotFoundException e
) {
1310 throw new Error
.GroupNotFound(e
.getMessage());
1311 } catch (NotAGroupMemberException e
) {
1312 throw new Error
.NotAGroupMember(e
.getMessage());
1313 } catch (IOException e
) {
1314 throw new Error
.Failure(e
.getMessage());
1315 } catch (LastGroupAdminException e
) {
1316 throw new Error
.LastGroupAdmin(e
.getMessage());
1317 } catch (UnregisteredRecipientException e
) {
1318 throw new Error
.UntrustedIdentity(e
.getSender().getIdentifier() + " is not registered.");
1323 public void deleteGroup() throws Error
.Failure
, Error
.LastGroupAdmin
{
1325 m
.deleteGroup(groupId
);
1326 } catch (IOException e
) {
1327 throw new Error
.Failure(e
.getMessage());
1333 public void addMembers(final List
<String
> recipients
) throws Error
.Failure
{
1334 final var memberIdentifiers
= getSingleRecipientIdentifiers(recipients
, m
.getSelfNumber());
1335 updateGroup(UpdateGroup
.newBuilder().withMembers(memberIdentifiers
).build());
1339 public void removeMembers(final List
<String
> recipients
) throws Error
.Failure
{
1340 final var memberIdentifiers
= getSingleRecipientIdentifiers(recipients
, m
.getSelfNumber());
1341 updateGroup(UpdateGroup
.newBuilder().withRemoveMembers(memberIdentifiers
).build());
1345 public void addAdmins(final List
<String
> recipients
) throws Error
.Failure
{
1346 final var memberIdentifiers
= getSingleRecipientIdentifiers(recipients
, m
.getSelfNumber());
1347 updateGroup(UpdateGroup
.newBuilder().withAdmins(memberIdentifiers
).build());
1351 public void removeAdmins(final List
<String
> recipients
) throws Error
.Failure
{
1352 final var memberIdentifiers
= getSingleRecipientIdentifiers(recipients
, m
.getSelfNumber());
1353 updateGroup(UpdateGroup
.newBuilder().withRemoveAdmins(memberIdentifiers
).build());
1357 public void resetLink() throws Error
.Failure
{
1358 updateGroup(UpdateGroup
.newBuilder().withResetGroupLink(true).build());
1362 public void disableLink() throws Error
.Failure
{
1363 updateGroup(UpdateGroup
.newBuilder().withGroupLinkState(GroupLinkState
.DISABLED
).build());
1367 public void enableLink(final boolean requiresApproval
) throws Error
.Failure
{
1368 updateGroup(UpdateGroup
.newBuilder()
1369 .withGroupLinkState(requiresApproval
1370 ? GroupLinkState
.ENABLED_WITH_APPROVAL
1371 : GroupLinkState
.ENABLED
)
1375 private org
.asamk
.signal
.manager
.api
.Group
getGroup() {
1376 return m
.getGroup(groupId
);
1379 private void setGroupName(final String name
) {
1380 updateGroup(UpdateGroup
.newBuilder().withName(name
).build());
1383 private void setGroupDescription(final String description
) {
1384 updateGroup(UpdateGroup
.newBuilder().withDescription(description
).build());
1387 private void setGroupAvatar(final String avatar
) {
1388 updateGroup(UpdateGroup
.newBuilder().withAvatarFile(avatar
).build());
1391 private void setMessageExpirationTime(final int expirationTime
) {
1392 updateGroup(UpdateGroup
.newBuilder().withExpirationTimer(expirationTime
).build());
1395 private void setGroupPermissionAddMember(final String permission
) {
1396 updateGroup(UpdateGroup
.newBuilder().withAddMemberPermission(GroupPermission
.valueOf(permission
)).build());
1399 private void setGroupPermissionEditDetails(final String permission
) {
1400 updateGroup(UpdateGroup
.newBuilder()
1401 .withEditDetailsPermission(GroupPermission
.valueOf(permission
))
1405 private void setGroupPermissionSendMessage(final String permission
) {
1406 updateGroup(UpdateGroup
.newBuilder()
1407 .withIsAnnouncementGroup(GroupPermission
.valueOf(permission
) == GroupPermission
.ONLY_ADMINS
)
1411 private void setIsBlocked(final boolean isBlocked
) {
1413 m
.setGroupsBlocked(List
.of(groupId
), isBlocked
);
1414 } catch (NotPrimaryDeviceException e
) {
1415 throw new Error
.Failure("This command doesn't work on linked devices.");
1416 } catch (GroupNotFoundException e
) {
1417 throw new Error
.GroupNotFound(e
.getMessage());
1418 } catch (IOException e
) {
1419 throw new Error
.Failure(e
.getMessage());
1423 private void updateGroup(final UpdateGroup updateGroup
) {
1425 m
.updateGroup(groupId
, updateGroup
);
1426 } catch (IOException e
) {
1427 throw new Error
.Failure(e
.getMessage());
1428 } catch (GroupNotFoundException
| NotAGroupMemberException
| GroupSendingNotAllowedException e
) {
1429 throw new Error
.GroupNotFound(e
.getMessage());
1430 } catch (AttachmentInvalidException e
) {
1431 throw new Error
.AttachmentInvalid(e
.getMessage());
1432 } catch (UnregisteredRecipientException e
) {
1433 throw new Error
.UntrustedIdentity(e
.getSender().getIdentifier() + " is not registered.");