upd: send email on new pending approval
This commit is contained in:
@@ -23,6 +23,7 @@ import { L_CHARS, secureRndstr } from '@/misc/secure-rndstr.js';
|
|||||||
import { SigninService } from './SigninService.js';
|
import { SigninService } from './SigninService.js';
|
||||||
import type { FastifyRequest, FastifyReply } from 'fastify';
|
import type { FastifyRequest, FastifyReply } from 'fastify';
|
||||||
import instance from './endpoints/charts/instance.js';
|
import instance from './endpoints/charts/instance.js';
|
||||||
|
import { RoleService } from '@/core/RoleService.js';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class SignupApiService {
|
export class SignupApiService {
|
||||||
@@ -52,6 +53,7 @@ export class SignupApiService {
|
|||||||
private signupService: SignupService,
|
private signupService: SignupService,
|
||||||
private signinService: SigninService,
|
private signinService: SigninService,
|
||||||
private emailService: EmailService,
|
private emailService: EmailService,
|
||||||
|
private roleService: RoleService,
|
||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -217,6 +219,18 @@ export class SignupApiService {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const moderators = await this.roleService.getModerators();
|
||||||
|
|
||||||
|
for (const moderator of moderators) {
|
||||||
|
const profile = await this.userProfilesRepository.findOneBy({ userId: moderator.id });
|
||||||
|
|
||||||
|
if (profile?.email) {
|
||||||
|
this.emailService.sendEmail(profile.email, 'New user awaiting approval',
|
||||||
|
`A new user called ${account.username} is awaiting approval with the following reason: "${reason}"`,
|
||||||
|
`A new user called ${account.username} is awaiting approval with the following reason: "${reason}"`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
reply.code(204);
|
reply.code(204);
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
@@ -292,6 +306,19 @@ export class SignupApiService {
|
|||||||
'Congratulations! Your account is now pending approval. You will get notified when you have been accepted.',
|
'Congratulations! Your account is now pending approval. You will get notified when you have been accepted.',
|
||||||
'Congratulations! Your account is now pending approval. You will get notified when you have been accepted.');
|
'Congratulations! Your account is now pending approval. You will get notified when you have been accepted.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const moderators = await this.roleService.getModerators();
|
||||||
|
|
||||||
|
for (const moderator of moderators) {
|
||||||
|
const profile = await this.userProfilesRepository.findOneBy({ userId: moderator.id });
|
||||||
|
|
||||||
|
if (profile?.email) {
|
||||||
|
this.emailService.sendEmail(profile.email, 'New user awaiting approval',
|
||||||
|
`A new user called ${pendingUser.username} is awaiting approval with the following reason: "${pendingUser.reason}"`,
|
||||||
|
`A new user called ${pendingUser.username} is awaiting approval with the following reason: "${pendingUser.reason}"`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return { pendingApproval: true };
|
return { pendingApproval: true };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user