mirror of
https://github.com/documenso/documenso.git
synced 2026-07-26 18:04:55 +10:00
fix: prevent sending emails for free organisation claims (#2917)
This commit is contained in:
+12
@@ -8,6 +8,7 @@ import { getI18nInstance } from '../../../client-only/providers/i18n-server';
|
|||||||
import { NEXT_PUBLIC_WEBAPP_URL } from '../../../constants/app';
|
import { NEXT_PUBLIC_WEBAPP_URL } from '../../../constants/app';
|
||||||
import { ORGANISATION_MEMBER_ROLE_PERMISSIONS_MAP } from '../../../constants/organisations';
|
import { ORGANISATION_MEMBER_ROLE_PERMISSIONS_MAP } from '../../../constants/organisations';
|
||||||
import { getEmailContext } from '../../../server-only/email/get-email-context';
|
import { getEmailContext } from '../../../server-only/email/get-email-context';
|
||||||
|
import { INTERNAL_CLAIM_ID } from '../../../types/subscription';
|
||||||
import { renderEmailWithI18N } from '../../../utils/render-email-with-i18n';
|
import { renderEmailWithI18N } from '../../../utils/render-email-with-i18n';
|
||||||
import type { JobRunIO } from '../../client/_internal/job';
|
import type { JobRunIO } from '../../client/_internal/job';
|
||||||
import type { TSendOrganisationLimitExceededEmailJobDefinition } from './send-organisation-limit-exceeded-email';
|
import type { TSendOrganisationLimitExceededEmailJobDefinition } from './send-organisation-limit-exceeded-email';
|
||||||
@@ -24,6 +25,7 @@ export const run = async ({
|
|||||||
id: payload.organisationId,
|
id: payload.organisationId,
|
||||||
},
|
},
|
||||||
include: {
|
include: {
|
||||||
|
organisationClaim: true,
|
||||||
members: {
|
members: {
|
||||||
where: {
|
where: {
|
||||||
organisationGroupMembers: {
|
organisationGroupMembers: {
|
||||||
@@ -57,6 +59,16 @@ export const run = async ({
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Do not send emails for "free" claims.
|
||||||
|
if (organisation.organisationClaim.originalSubscriptionClaimId === INTERNAL_CLAIM_ID.FREE) {
|
||||||
|
io.logger.info({
|
||||||
|
msg: 'Skipping organisation limit exceeded email for "free" claim',
|
||||||
|
organisationId: organisation.id,
|
||||||
|
});
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
for (const member of organisation.members) {
|
for (const member of organisation.members) {
|
||||||
await io.runTask(`send-organisation-limit-exceeded-email-${member.id}`, async () => {
|
await io.runTask(`send-organisation-limit-exceeded-email-${member.id}`, async () => {
|
||||||
const emailContent = createElement(OrganisationLimitExceededEmailTemplate, {
|
const emailContent = createElement(OrganisationLimitExceededEmailTemplate, {
|
||||||
|
|||||||
Reference in New Issue
Block a user