Mail Modul überarbeitet, Korrekturen am PaymentService, neuer customerType seller

This commit is contained in:
2024-08-22 22:59:33 +02:00
parent b4609d07ba
commit 7a286e3519
16 changed files with 183 additions and 76 deletions

View File

@@ -0,0 +1,14 @@
import { registerAs } from '@nestjs/config';
export default registerAs('mail', () => ({
host: 'email-smtp.us-east-2.amazonaws.com',
port: 587,
secure: false,
auth: {
user: process.env.AMAZON_USER,
pass: process.env.AMAZON_PASSWORD,
},
defaults: {
from: '"No Reply" <noreply@example.com>',
},
}));

View File

@@ -1,4 +1,5 @@
import { Body, Controller, Post } from '@nestjs/common';
import { User } from 'src/models/db.model';
import { ErrorResponse, MailInfo } from '../models/main.model';
import { MailService } from './mail.service.js';
@@ -13,4 +14,8 @@ export class MailController {
return this.mailService.sendRequest(mailInfo);
}
}
@Post('subscriptionConfirmation')
sendSubscriptionConfirmation(@Body() user: User): Promise<void | ErrorResponse> {
return this.mailService.sendSubscriptionConfirmation(user);
}
}

View File

@@ -13,33 +13,67 @@ import { MailController } from './mail.controller.js';
import { MailService } from './mail.service.js';
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const user = process.env.amazon_user;
const password = process.env.amazon_password;
const user = process.env.AMAZON_USER;
const password = process.env.AMAZON_PASSWORD;
console.log('Amazon User:', process.env.AMAZON_USER);
console.log('Amazon Password:', process.env.AMAZON_PASSWORD);
@Module({
imports: [
DrizzleModule,
UserModule,
GeoModule,
MailerModule.forRoot({
transport: {
host: 'email-smtp.us-east-2.amazonaws.com',
secure: false,
port: 587,
auth: {
user: 'AKIAU6GDWVAQ2QNFLNWN',
pass: 'BDE9nZv/ARbpotim1mIOir52WgIbpSi9cv1oJoH8oEf7',
// ConfigModule.forFeature(mailConfig),
// MailerModule.forRoot({
// transport: {
// host: 'email-smtp.us-east-2.amazonaws.com',
// secure: false,
// port: 587,
// auth: {
// user: user, //'AKIAU6GDWVAQ2QNFLNWN',
// pass: password, //'BDE9nZv/ARbpotim1mIOir52WgIbpSi9cv1oJoH8oEf7',
// },
// },
// defaults: {
// from: '"No Reply" <noreply@example.com>',
// },
// template: {
// dir: join(__dirname, 'templates'),
// adapter: new HandlebarsAdapter({
// eq: function (a, b) {
// return a === b;
// },
// }),
// options: {
// strict: true,
// },
// },
// }),
MailerModule.forRootAsync({
useFactory: () => ({
transport: {
host: 'email-smtp.us-east-2.amazonaws.com',
secure: false,
port: 587,
auth: {
user: process.env.AMAZON_USER, //'AKIAU6GDWVAQ2QNFLNWN',
pass: process.env.AMAZON_PASSWORD, //'BDE9nZv/ARbpotim1mIOir52WgIbpSi9cv1oJoH8oEf7',
},
},
},
defaults: {
from: '"No Reply" <noreply@example.com>',
},
template: {
dir: join(__dirname, 'templates'),
adapter: new HandlebarsAdapter(), // or new PugAdapter() or new EjsAdapter()
options: {
strict: true,
defaults: {
from: '"No Reply" <noreply@example.com>',
},
},
template: {
dir: join(__dirname, 'templates'),
adapter: new HandlebarsAdapter({
eq: function (a, b) {
return a === b;
},
}),
options: {
strict: true,
},
},
}),
}),
],
providers: [MailService, UserService, FileService, GeoService],

View File

@@ -83,7 +83,7 @@ export class MailService {
}
async sendSubscriptionConfirmation(user: User): Promise<void> {
await this.mailerService.sendMail({
to: 'support@bizmatch.net',
to: user.email,
from: `"Bizmatch Support Team" <info@bizmatch.net>`,
subject: `Subscription Confirmation`,
//template: './inquiry', // `.hbs` extension is appended automatically