summaryrefslogtreecommitdiff
path: root/packages/backend/src/server/api/SignupApiService.ts
diff options
context:
space:
mode:
authorMar0xy <marie@kaifa.ch>2023-10-21 18:39:13 +0200
committerMar0xy <marie@kaifa.ch>2023-10-21 18:39:13 +0200
commitb930b89b3c2179812adc453f6f3315c822a49765 (patch)
treea8c529a27f47901b70abfa185774b1483a621e1e /packages/backend/src/server/api/SignupApiService.ts
parentchore: update compose example to use keydb and fix network related issue (diff)
downloadsharkey-b930b89b3c2179812adc453f6f3315c822a49765.tar.gz
sharkey-b930b89b3c2179812adc453f6f3315c822a49765.tar.bz2
sharkey-b930b89b3c2179812adc453f6f3315c822a49765.zip
upd: send email on new pending approval
Diffstat (limited to 'packages/backend/src/server/api/SignupApiService.ts')
-rw-r--r--packages/backend/src/server/api/SignupApiService.ts27
1 files changed, 27 insertions, 0 deletions
diff --git a/packages/backend/src/server/api/SignupApiService.ts b/packages/backend/src/server/api/SignupApiService.ts
index c07389d975..d3ece10859 100644
--- a/packages/backend/src/server/api/SignupApiService.ts
+++ b/packages/backend/src/server/api/SignupApiService.ts
@@ -23,6 +23,7 @@ import { L_CHARS, secureRndstr } from '@/misc/secure-rndstr.js';
import { SigninService } from './SigninService.js';
import type { FastifyRequest, FastifyReply } from 'fastify';
import instance from './endpoints/charts/instance.js';
+import { RoleService } from '@/core/RoleService.js';
@Injectable()
export class SignupApiService {
@@ -52,6 +53,7 @@ export class SignupApiService {
private signupService: SignupService,
private signinService: SigninService,
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);
return;
} 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.');
}
+
+ 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 };
}