}
messageBuilder.withPreviews(previews);
}
+ if (message.storyReply().isPresent()) {
+ final var storyReply = message.storyReply().get();
+ final var authorServiceId = context.getRecipientHelper()
+ .resolveSignalServiceAddress(context.getRecipientHelper().resolveRecipient(storyReply.author()))
+ .getServiceId();
+ messageBuilder.withStoryContext(new SignalServiceDataMessage.StoryContext(authorServiceId,
+ storyReply.timestamp()));
+ }
}
private ArrayList<SignalServiceDataMessage.Mention> resolveMentions(final List<Message.Mention> mentionList) throws UnregisteredRecipientException {
}
@Override
- public void receiveMessages(Duration timeout, ReceiveMessageHandler handler) throws IOException {
- receiveMessages(timeout, true, handler);
- }
-
- @Override
- public void receiveMessages(ReceiveMessageHandler handler) throws IOException {
- receiveMessages(Duration.ofMinutes(1), false, handler);
+ public void receiveMessages(
+ Optional<Duration> timeout,
+ Optional<Integer> maxMessages,
+ ReceiveMessageHandler handler
+ ) throws IOException {
+ receiveMessages(timeout.orElse(Duration.ofMinutes(1)), timeout.isPresent(), maxMessages.orElse(null), handler);
}
private void receiveMessages(
- Duration timeout, boolean returnOnTimeout, ReceiveMessageHandler handler
+ Duration timeout, boolean returnOnTimeout, Integer maxMessages, ReceiveMessageHandler handler
) throws IOException {
if (isReceiving()) {
throw new IllegalStateException("Already receiving message.");
isReceivingSynchronous = true;
receiveThread = Thread.currentThread();
try {
- context.getReceiveHelper().receiveMessages(timeout, returnOnTimeout, handler);
+ context.getReceiveHelper().receiveMessages(timeout, returnOnTimeout, maxMessages, handler);
} finally {
receiveThread = null;
isReceivingSynchronous = false;