refactor(server): mail service (#10934)

This commit is contained in:
forehalo
2025-03-19 17:00:19 +00:00
parent b3a245f47a
commit 21c4a29f55
47 changed files with 2076 additions and 2131 deletions

View File

@@ -2,6 +2,7 @@ import './config';
import { ServerFeature } from '../../core/config';
import { FeatureModule } from '../../core/features';
import { MailModule } from '../../core/mail';
import { PermissionModule } from '../../core/permission';
import { QuotaModule } from '../../core/quota';
import { UserModule } from '../../core/user';
@@ -33,6 +34,7 @@ import { StripeWebhook } from './webhook';
UserModule,
PermissionModule,
WorkspaceModule,
MailModule,
],
providers: [
StripeProvider,

View File

@@ -6,11 +6,8 @@ import { pick } from 'lodash-es';
import Stripe from 'stripe';
import { z } from 'zod';
import {
MailService,
SubscriptionPlanNotFound,
URLHelper,
} from '../../../base';
import { SubscriptionPlanNotFound, URLHelper } from '../../../base';
import { Mailer } from '../../../core/mail';
import {
KnownStripeInvoice,
KnownStripePrice,
@@ -49,7 +46,7 @@ export class SelfhostTeamSubscriptionManager extends SubscriptionManager {
stripe: Stripe,
db: PrismaClient,
private readonly url: URLHelper,
private readonly mailer: MailService
private readonly mailer: Mailer
) {
super(stripe, db);
}
@@ -140,7 +137,11 @@ export class SelfhostTeamSubscriptionManager extends SubscriptionManager {
}),
]);
await this.mailer.sendTeamLicenseMail(userEmail, { license: key });
await this.mailer.send({
name: 'TeamLicense',
to: userEmail,
props: { license: key },
});
return subscription;
} else {