Skip to content

Commit

Permalink
feat(worker): Disable inline-css behind feature flag (#6073)
Browse files Browse the repository at this point in the history
  • Loading branch information
Joel Anton authored Jul 15, 2024
1 parent ddc6aab commit aa51d26
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import {
IAttachmentOptions,
IEmailOptions,
LogCodeEnum,
FeatureFlagsKeysEnum,
} from '@novu/shared';
import {
InstrumentUsecase,
Expand All @@ -34,6 +35,8 @@ import {
SelectVariant,
ExecutionLogRoute,
ExecutionLogRouteCommand,
GetFeatureFlag,
GetFeatureFlagCommand,
} from '@novu/application-generic';
import { EmailOutput } from '@novu/framework';

Expand All @@ -60,7 +63,8 @@ export class SendMessageEmail extends SendMessageBase {
protected selectIntegration: SelectIntegration,
protected getNovuProviderCredentials: GetNovuProviderCredentials,
protected selectVariant: SelectVariant,
protected moduleRef: ModuleRef
protected moduleRef: ModuleRef,
private getFeatureFlag: GetFeatureFlag
) {
super(
messageRepository,
Expand Down Expand Up @@ -242,10 +246,23 @@ export class SendMessageEmail extends SendMessageBase {
);
}

html = await inlineCss(html, {
// Used for style sheet links that starts with / so should not be needed in our case.
url: ' ',
});
// TODO: remove as part of https://linear.app/novu/issue/NV-4117/email-html-content-issue-in-mobile-devices
const shouldDisableInlineCss = await this.getFeatureFlag.execute(
GetFeatureFlagCommand.create({
key: FeatureFlagsKeysEnum.IS_EMAIL_INLINE_CSS_DISABLED,
environmentId: command.environmentId,
organizationId: command.organizationId,
userId: command.userId,
})
);

if (!shouldDisableInlineCss) {
// this is causing rendering issues in Gmail (especially when media queries are used), so we are disabling it
html = await inlineCss(html, {
// Used for style sheet links that starts with / so should not be needed in our case.
url: ' ',
});
}
}
} catch (error) {
Logger.error(
Expand Down
1 change: 1 addition & 0 deletions libs/shared/src/types/feature-flags/feature-flags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@ export enum FeatureFlagsKeysEnum {
IS_MIXPANEL_RECORDING_ENABLED = 'IS_MIXPANEL_RECORDING_ENABLED',
IS_INTEGRATION_INVALIDATION_DISABLED = 'IS_INTEGRATION_INVALIDATION_DISABLED',
IS_V2_ENABLED = 'IS_V2_ENABLED',
IS_EMAIL_INLINE_CSS_DISABLED = 'IS_EMAIL_INLINE_CSS_DISABLED',
}

0 comments on commit aa51d26

Please sign in to comment.