update invite center staff
This commit is contained in:
@@ -152,12 +152,14 @@ export class CenterStaffSchema extends PothosSchema {
|
||||
// build invite url
|
||||
const inviteUrl = `${process.env.CENTER_BASE_URL}/invite?token=${token}`;
|
||||
// mail to user with params centerId, email
|
||||
await this.mailService.sendEmail(
|
||||
await this.mailService.sendTemplateEmail(
|
||||
args.email,
|
||||
'Invite to center',
|
||||
`You are invited to join the center ${center.name}.
|
||||
Please click the link below to join the center:
|
||||
${inviteUrl}`,
|
||||
'StaffInvitation',
|
||||
{
|
||||
center_name: center.name,
|
||||
invite_url: inviteUrl,
|
||||
},
|
||||
);
|
||||
return null;
|
||||
});
|
||||
|
||||
@@ -79,7 +79,7 @@ import { initContextCache } from '@pothos/core';
|
||||
subscriptions: {
|
||||
'graphql-ws': true,
|
||||
},
|
||||
context: async (req: Request) => ({
|
||||
context: async ({ req }: { req: Request }) => ({
|
||||
...initContextCache(),
|
||||
me: await new GraphqlService(new PrismaService()).acquireContext(req),
|
||||
}),
|
||||
|
||||
@@ -10,12 +10,15 @@ export class GraphqlService {
|
||||
|
||||
async acquireContext(req: Request) {
|
||||
// get x-session-id from headers
|
||||
let sessionId;
|
||||
let sessionId: string;
|
||||
try {
|
||||
sessionId = req.headers['x-session-id'];
|
||||
sessionId = req.headers['x-session-id'] as string;
|
||||
//eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
} catch (error) {
|
||||
if (process.env.NODE_ENV === 'development') {
|
||||
if (
|
||||
process.env.NODE_ENV === 'development' &&
|
||||
process.env.DISABLE_AUTH === 'true'
|
||||
) {
|
||||
return null;
|
||||
}
|
||||
throw new UnauthorizedException('Must provide a session ID');
|
||||
|
||||
@@ -28,13 +28,15 @@ import { PugAdapter } from '@nestjs-modules/mailer/dist/adapters/pug.adapter';
|
||||
defaults: {
|
||||
from: process.env.MAILU_FROM,
|
||||
},
|
||||
// template: {
|
||||
// dir: path.join(__dirname, 'templates'),
|
||||
// adapter: new PugAdapter(),
|
||||
// options: {
|
||||
// strict: true,
|
||||
// },
|
||||
// },
|
||||
template: {
|
||||
dir: path.join(__dirname, 'templates'),
|
||||
adapter: new PugAdapter({
|
||||
inlineCssEnabled: true,
|
||||
}),
|
||||
options: {
|
||||
strict: true,
|
||||
},
|
||||
},
|
||||
}),
|
||||
}),
|
||||
OpenaiModule,
|
||||
|
||||
@@ -21,7 +21,7 @@ export class MailService {
|
||||
const result = await this.mailerService.sendMail({
|
||||
to,
|
||||
subject,
|
||||
text: mailContent ?? text,
|
||||
text: mailContent ?? text,
|
||||
});
|
||||
Logger.log(result, 'MailService');
|
||||
} catch (error) {
|
||||
@@ -33,7 +33,7 @@ export class MailService {
|
||||
to: string,
|
||||
subject: string,
|
||||
template: string,
|
||||
context: User,
|
||||
context: any,
|
||||
) {
|
||||
try {
|
||||
const result = await this.mailerService.sendMail({
|
||||
|
||||
@@ -2,7 +2,7 @@ doctype html
|
||||
html
|
||||
head
|
||||
meta(charset="UTF-8")
|
||||
title Thư mời làm việc từ Trung tâm [center_name]
|
||||
title Thư mời làm việc từ Trung tâm #{center_name}
|
||||
style.
|
||||
body {
|
||||
font-family: Arial, sans-serif;
|
||||
@@ -59,12 +59,12 @@ html
|
||||
body
|
||||
.container
|
||||
.header
|
||||
h1 Thư mời làm việc từ Trung tâm [center_name]
|
||||
h1 Thư mời làm việc từ Trung tâm #{center_name}
|
||||
.content
|
||||
p Chào bạn,
|
||||
p Chúng tôi rất vui mừng thông báo rằng bạn đã được mời làm nhân viên tại trung tâm [center_name].
|
||||
p Chúng tôi rất vui mừng thông báo rằng bạn đã được mời làm nhân viên tại trung tâm #{center_name}.
|
||||
p Để tiếp tục quá trình ứng tuyển, vui lòng nhấn vào nút dưới đây để truy cập vào trang nộp resume của bạn.
|
||||
a.button(href="http://localhost:3000/upload-cv?centerId=[center_id]") Nộp Resume
|
||||
a.button(href=invite_url) Nộp Resume
|
||||
p Nếu bạn có bất kỳ thắc mắc nào, đừng ngần ngại liên hệ với chúng tôi.
|
||||
.footer
|
||||
p Trân trọng,
|
||||
|
||||
@@ -239,7 +239,15 @@ export class UserSchema extends PothosSchema {
|
||||
to: t.arg({ type: 'String', required: true }),
|
||||
},
|
||||
resolve: async (_parent, args, _context, _info) => {
|
||||
await this.mailService.sendEmail(args.to, 'Test', 'Test');
|
||||
await this.mailService.sendTemplateEmail(
|
||||
args.to,
|
||||
'Bạn đã được mời làm việc tại Trung tâm băng đĩa lậu hải ngoại',
|
||||
'StaffInvitation',
|
||||
{
|
||||
center_name: 'băng đĩa lậu hải ngoại',
|
||||
invite_url: 'https://epess.org',
|
||||
},
|
||||
);
|
||||
return 'Email sent';
|
||||
},
|
||||
}),
|
||||
|
||||
@@ -13,7 +13,12 @@ async function bootstrap() {
|
||||
app.enableCors({
|
||||
origin: corsOrigin,
|
||||
methods: ['GET', 'POST', 'PUT', 'DELETE', 'PATCH', 'OPTIONS'],
|
||||
allowedHeaders: ['Content-Type', '*', 'x-apollo-operation-name'],
|
||||
allowedHeaders: [
|
||||
'Content-Type',
|
||||
'*',
|
||||
'x-apollo-operation-name',
|
||||
'x-session-id',
|
||||
],
|
||||
credentials: true,
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user