forked from nekoplanet/misskey
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7ca0af9
commit f69b50a
Showing
23 changed files
with
278 additions
and
5 deletions.
There are no files selected for viewing
22 changes: 22 additions & 0 deletions
22
packages/backend/migration/1697580470000-approvalSignup.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/* | ||
* SPDX-FileCopyrightText: syuilo and other misskey contributors | ||
* SPDX-License-Identifier: AGPL-3.0-only | ||
*/ | ||
|
||
export class ApprovalSignup1697580470000 { | ||
name = 'ApprovalSignup1697580470000' | ||
|
||
async up(queryRunner) { | ||
await queryRunner.query(`ALTER TABLE "meta" ADD "approvalRequiredForSignup" boolean DEFAULT false NOT NULL`); | ||
await queryRunner.query(`ALTER TABLE "user" ADD "approved" boolean DEFAULT false NOT NULL`); | ||
await queryRunner.query(`ALTER TABLE "user" ADD "signupReason" character varying(1000) NULL`); | ||
await queryRunner.query(`ALTER TABLE "user_pending" ADD "reason" character varying(1000) NULL`); | ||
} | ||
|
||
async down(queryRunner) { | ||
await queryRunner.query(`ALTER TABLE "meta" DROP COLUMN "approvalRequiredForSignup"`); | ||
await queryRunner.query(`ALTER TABLE "user" DROP COLUMN "approved"`); | ||
await queryRunner.query(`ALTER TABLE "user" DROP COLUMN "signupReason"`); | ||
await queryRunner.query(`ALTER TABLE "user_pending" DROP COLUMN "reason"`); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
packages/backend/src/server/api/endpoints/admin/approve-user.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import { Inject, Injectable } from '@nestjs/common'; | ||
import { Endpoint } from '@/server/api/endpoint-base.js'; | ||
import type { UserProfilesRepository, UsersRepository } from '@/models/_.js'; | ||
import { ModerationLogService } from '@/core/ModerationLogService.js'; | ||
import { DI } from '@/di-symbols.js'; | ||
import { EmailService } from '@/core/EmailService.js'; | ||
|
||
export const meta = { | ||
tags: ['admin'], | ||
|
||
requireCredential: true, | ||
requireModerator: true, | ||
} as const; | ||
|
||
export const paramDef = { | ||
type: 'object', | ||
properties: { | ||
userId: { type: 'string', format: 'misskey:id' }, | ||
}, | ||
required: ['userId'], | ||
} as const; | ||
|
||
@Injectable() | ||
export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-disable-line import/no-default-export | ||
constructor( | ||
@Inject(DI.usersRepository) | ||
private usersRepository: UsersRepository, | ||
|
||
@Inject(DI.userProfilesRepository) | ||
private userProfilesRepository: UserProfilesRepository, | ||
|
||
private moderationLogService: ModerationLogService, | ||
private emailService: EmailService, | ||
) { | ||
super(meta, paramDef, async (ps, me) => { | ||
const user = await this.usersRepository.findOneBy({ id: ps.userId }); | ||
|
||
if (user == null) { | ||
throw new Error('user not found'); | ||
} | ||
|
||
const profile = await this.userProfilesRepository.findOneBy({ userId: ps.userId }); | ||
|
||
await this.usersRepository.update(user.id, { | ||
approved: true, | ||
}); | ||
|
||
if (profile?.email) { | ||
this.emailService.sendEmail(profile.email, 'Account Approved', | ||
'Your Account has been approved have fun socializing!', | ||
'Your Account has been approved have fun socializing!'); | ||
} | ||
|
||
this.moderationLogService.log(me, 'approve', { | ||
userId: user.id, | ||
userUsername: user.username, | ||
userHost: user.host, | ||
}); | ||
}); | ||
} | ||
} |
Oops, something went wrong.