feat(backend): mail module + send personal Gemeinde-Teamer invites
New global mail/ module mirroring the files/storage/ provider pattern: - MailProvider abstraction; default LogMailProvider only logs (no delivery), MAIL_PROVIDER=smtp switches to a nodemailer SMTP transport (SMTP_*, MAIL_FROM). - MailService.sendTeamerInvite() composes the invite email with a link built from APP_BASE_URL. TeamerService.createInvite() now mails personal invites (those with an email) best-effort and returns `emailSent`; group links are unchanged. Delivery failures are logged and swallowed, never blocking invite creation. New env: APP_BASE_URL, MAIL_PROVIDER, MAIL_FROM, SMTP_HOST/PORT/SECURE/ USER/PASS. Tests: teamer spec covers mail-on-personal-invite, no-mail-on-group-link, and transport-drop; npm test green at 56. Docs updated. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
import { Global, Module } from '@nestjs/common';
|
||||
import { ConfigService } from '@nestjs/config';
|
||||
import { MAIL_PROVIDER } from './mail-provider';
|
||||
import { LogMailProvider } from './log-mail.provider';
|
||||
import { SmtpMailProvider } from './smtp-mail.provider';
|
||||
import { MailService } from './mail.service';
|
||||
|
||||
/// Global so any feature module can inject MailService. Provider defaults to
|
||||
/// log-only; MAIL_PROVIDER=smtp switches to a real SMTP transport.
|
||||
@Global()
|
||||
@Module({
|
||||
providers: [
|
||||
MailService,
|
||||
{
|
||||
provide: MAIL_PROVIDER,
|
||||
inject: [ConfigService],
|
||||
useFactory: (config: ConfigService) =>
|
||||
config.get<string>('MAIL_PROVIDER') === 'smtp'
|
||||
? new SmtpMailProvider(config)
|
||||
: new LogMailProvider(),
|
||||
},
|
||||
],
|
||||
exports: [MailService],
|
||||
})
|
||||
export class MailModule {}
|
||||
Reference in New Issue
Block a user