Skip to content

Commit

Permalink
Set destination account on the request context
Browse files Browse the repository at this point in the history
  • Loading branch information
ravi-signal committed Jan 25, 2024
1 parent 1428ca7 commit 6bda9d8
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,8 @@ private record MultiRecipientDeliveryData(

private static final Logger logger = LoggerFactory.getLogger(MessageController.class);

public static final String DESTINATION_ACCOUNT_PROPERTY_NAME = "destinationAccount";

private final RateLimiters rateLimiters;
private final CardinalityEstimator messageByteLimitEstimator;
private final MessageSender messageSender;
Expand Down Expand Up @@ -284,13 +286,14 @@ public Response sendMessage(@Auth Optional<AuthenticatedAccount> source,
}

Optional<Account> destination;

if (!isSyncMessage) {
destination = accountsManager.getByServiceIdentifier(destinationIdentifier);
} else {
destination = source.map(AuthenticatedAccount::getAccount);
}

destination.ifPresent(account -> context.setProperty(DESTINATION_ACCOUNT_PROPERTY_NAME, account));

// Stories will be checked by the client; we bypass access checks here for stories.
if (!isStory) {
OptionalAccess.verify(source.map(AuthenticatedAccount::getAccount), accessKey, destination);
Expand Down

0 comments on commit 6bda9d8

Please sign in to comment.