Skip to content

Commit

Permalink
Fix the delivery date of forwarded messages should be the server time #…
Browse files Browse the repository at this point in the history
…1591 + Return an error instead of ok if the message for forwarding was not found
  • Loading branch information
JamesChenX committed Dec 12, 2024
1 parent 1cd1745 commit c8fe185
Showing 1 changed file with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,9 @@ public class MessageService extends BaseService {

private static final Logger LOGGER = LoggerFactory.getLogger(MessageService.class);

private static final Mono<MessageAndRecipientIds> ERROR_NOT_MESSAGE_RECIPIENT_OR_SENDER_TO_FORWARD_MESSAGE =
Mono.error(ResponseException.get(NOT_MESSAGE_RECIPIENT_OR_SENDER_TO_FORWARD_MESSAGE));

private static final Method GET_MESSAGES_TO_DELETE_METHOD;

private final MessageRepository messageRepository;
Expand Down Expand Up @@ -1268,8 +1271,7 @@ public Mono<MessageAndRecipientIds> authAndCloneAndSaveMessage(
message.getTargetId(),
message.getSenderId()).flatMap(isMessageRecipientOrSender -> {
if (!isMessageRecipientOrSender) {
return Mono.error(ResponseException
.get(NOT_MESSAGE_RECIPIENT_OR_SENDER_TO_FORWARD_MESSAGE));
return ERROR_NOT_MESSAGE_RECIPIENT_OR_SENDER_TO_FORWARD_MESSAGE;
}
return authAndSaveMessage(queryRecipientIds,
null,
Expand All @@ -1282,10 +1284,13 @@ public Mono<MessageAndRecipientIds> authAndCloneAndSaveMessage(
message.getText(),
message.getRecords(),
message.getBurnAfter(),
message.getDeliveryDate(),
null,
referenceId,
null);
}));
}))
// We should not tell the client that the message was not found.
// Otherwise, the user can check if any message exists or not.
.switchIfEmpty(ERROR_NOT_MESSAGE_RECIPIENT_OR_SENDER_TO_FORWARD_MESSAGE);
}

public Mono<MessageAndRecipientIds> cloneAndSaveMessage(
Expand Down

0 comments on commit c8fe185

Please sign in to comment.