X-Git-Url: https://git.nmode.ca/signal-cli/blobdiff_plain/72390e595d1646ba8be9f0ed4455e1c8f2b48874..8a31b7f2c153e89532010b9ab58eb045ddfe43fe:/lib/src/main/java/org/asamk/signal/manager/ManagerImpl.java diff --git a/lib/src/main/java/org/asamk/signal/manager/ManagerImpl.java b/lib/src/main/java/org/asamk/signal/manager/ManagerImpl.java index 9696d956..1cc0629b 100644 --- a/lib/src/main/java/org/asamk/signal/manager/ManagerImpl.java +++ b/lib/src/main/java/org/asamk/signal/manager/ManagerImpl.java @@ -466,6 +466,14 @@ class ManagerImpl implements Manager { private SendMessageResults sendMessage( SignalServiceDataMessage.Builder messageBuilder, Set recipients + ) throws IOException, NotAGroupMemberException, GroupNotFoundException, GroupSendingNotAllowedException { + return sendMessage(messageBuilder, recipients, Optional.empty()); + } + + private SendMessageResults sendMessage( + SignalServiceDataMessage.Builder messageBuilder, + Set recipients, + Optional editTargetTimestamp ) throws IOException, NotAGroupMemberException, GroupNotFoundException, GroupSendingNotAllowedException { var results = new HashMap>(); long timestamp = System.currentTimeMillis(); @@ -474,17 +482,19 @@ class ManagerImpl implements Manager { if (recipient instanceof RecipientIdentifier.Single single) { try { final var recipientId = context.getRecipientHelper().resolveRecipient(single); - final var result = context.getSendHelper().sendMessage(messageBuilder, recipientId); + final var result = context.getSendHelper() + .sendMessage(messageBuilder, recipientId, editTargetTimestamp); results.put(recipient, List.of(toSendMessageResult(result))); } catch (UnregisteredRecipientException e) { results.put(recipient, List.of(SendMessageResult.unregisteredFailure(single.toPartialRecipientAddress()))); } } else if (recipient instanceof RecipientIdentifier.NoteToSelf) { - final var result = context.getSendHelper().sendSelfMessage(messageBuilder); + final var result = context.getSendHelper().sendSelfMessage(messageBuilder, editTargetTimestamp); results.put(recipient, List.of(toSendMessageResult(result))); } else if (recipient instanceof RecipientIdentifier.Group group) { - final var result = context.getSendHelper().sendAsGroupMessage(messageBuilder, group.groupId()); + final var result = context.getSendHelper() + .sendAsGroupMessage(messageBuilder, group.groupId(), editTargetTimestamp); results.put(recipient, result.stream().map(this::toSendMessageResult).toList()); } } @@ -581,6 +591,15 @@ class ManagerImpl implements Manager { return sendMessage(messageBuilder, recipients); } + @Override + public SendMessageResults sendEditMessage( + Message message, Set recipients, long editTargetTimestamp + ) throws IOException, AttachmentInvalidException, NotAGroupMemberException, GroupNotFoundException, GroupSendingNotAllowedException, UnregisteredRecipientException, InvalidStickerException { + final var messageBuilder = SignalServiceDataMessage.newBuilder(); + applyMessage(messageBuilder, message); + return sendMessage(messageBuilder, recipients, Optional.of(editTargetTimestamp)); + } + private void applyMessage( final SignalServiceDataMessage.Builder messageBuilder, final Message message ) throws AttachmentInvalidException, IOException, UnregisteredRecipientException, InvalidStickerException {