Skip to content

Commit

Permalink
fix(worker): Use susbcriber locale for in-app and email steps (#6134)
Browse files Browse the repository at this point in the history
  • Loading branch information
rifont authored Jul 23, 2024
1 parent 5d1c656 commit 3c63954
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ export class SendMessageEmail extends SendMessageBase {

constructor(
protected environmentRepository: EnvironmentRepository,
protected organizationRepository: OrganizationRepository,
protected subscriberRepository: SubscriberRepository,
protected messageRepository: MessageRepository,
protected layoutRepository: LayoutRepository,
Expand Down Expand Up @@ -212,12 +211,10 @@ export class SendMessageEmail extends SendMessageBase {
}

try {
const organization = await this.getOrganization(command.organizationId);

const i18nInstance = await this.initiateTranslations(
command.environmentId,
command.organizationId,
command.payload.subscriber?.locale || organization?.defaultLocale
subscriber.locale
);

if (!command.bridgeData) {
Expand Down Expand Up @@ -548,16 +545,6 @@ export class SendMessageEmail extends SendMessageBase {
}
}

protected async getOrganization(organizationId: string): Promise<OrganizationEntity | undefined> {
const organization = await this.organizationRepository.findById(organizationId, 'branding defaultLocale');

if (!organization) {
throw new NotFoundException(`Organization ${organizationId} not found`);
}

return organization;
}

public buildFactoryIntegration(integration: IntegrationEntity, senderName?: string) {
return {
...integration,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ export class SendMessageInApp extends SendMessageBase {
constructor(
private invalidateCache: InvalidateCacheService,
protected messageRepository: MessageRepository,
protected organizationRepository: OrganizationRepository,
private webSocketsQueueService: WebSocketsQueueService,
protected createLogUsecase: CreateLog,
protected executionLogRoute: ExecutionLogRoute,
Expand Down Expand Up @@ -108,6 +107,7 @@ export class SendMessageInApp extends SendMessageBase {

const { actor } = command.step.template;

const { subscriber } = command.compileContext;
const template = await this.processVariants(command);

if (template) {
Expand All @@ -116,12 +116,10 @@ export class SendMessageInApp extends SendMessageBase {

try {
if (!command.bridgeData) {
const organization = await this.getOrganization(command.organizationId);

const i18nInstance = await this.initiateTranslations(
command.environmentId,
command.organizationId,
command.payload.subscriber?.locale || organization?.defaultLocale
subscriber.locale
);

const compiled = await this.compileInAppTemplate.execute(
Expand Down Expand Up @@ -271,14 +269,4 @@ export class SendMessageInApp extends SendMessageBase {
})
);
}

protected async getOrganization(organizationId: string): Promise<OrganizationEntity | undefined> {
const organization = await this.organizationRepository.findById(organizationId, 'branding defaultLocale');

if (!organization) {
throw new NotFoundException(`Organization ${organizationId} not found`);
}

return organization;
}
}

0 comments on commit 3c63954

Please sign in to comment.