This commit is contained in:
tamaina 2023-05-29 16:09:42 +00:00
parent bc15dde742
commit 78558eb666
4 changed files with 79 additions and 73 deletions

View File

@ -5,37 +5,10 @@ import { Endpoint } from '@/server/api/endpoint-base.js';
import type { UsersRepository, UserProfilesRepository } from '@/models/index.js';
import { DI } from '@/di-symbols.js';
export const meta = {
tags: ['admin'],
requireCredential: true,
requireModerator: true,
res: {
type: 'object',
optional: false, nullable: false,
properties: {
password: {
type: 'string',
optional: false, nullable: false,
minLength: 8,
maxLength: 8,
},
},
},
} as const;
export const paramDef = {
type: 'object',
properties: {
userId: { type: 'string', format: 'misskey:id' },
},
required: ['userId'],
} as const;
// eslint-disable-next-line import/no-default-export
@Injectable()
export default class extends Endpoint<typeof meta, typeof paramDef> {
export default class extends Endpoint<'admin/reset-password'> {
name = 'admin/reset-password' as const;
constructor(
@Inject(DI.usersRepository)
private usersRepository: UsersRepository,
@ -43,7 +16,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
@Inject(DI.userProfilesRepository)
private userProfilesRepository: UserProfilesRepository,
) {
super(meta, paramDef, async (ps) => {
super(async (ps) => {
const user = await this.usersRepository.findOneBy({ id: ps.userId });
if (user == null) {

View File

@ -6,27 +6,12 @@ import { QueueService } from '@/core/QueueService.js';
import { ApRendererService } from '@/core/activitypub/ApRendererService.js';
import { DI } from '@/di-symbols.js';
export const meta = {
tags: ['admin'],
requireCredential: true,
requireModerator: true,
} as const;
export const paramDef = {
type: 'object',
properties: {
reportId: { type: 'string', format: 'misskey:id' },
forward: { type: 'boolean', default: false },
},
required: ['reportId'],
} as const;
// TODO: ロジックをサービスに切り出す
// eslint-disable-next-line import/no-default-export
@Injectable()
export default class extends Endpoint<typeof meta, typeof paramDef> {
export default class extends Endpoint<'admin/resolve-abuse-user-report'> {
name = 'admin/resolve-abuse-user-report' as const;
constructor(
@Inject(DI.usersRepository)
private usersRepository: UsersRepository,
@ -38,7 +23,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
private instanceActorService: InstanceActorService,
private apRendererService: ApRendererService,
) {
super(meta, paramDef, async (ps, me) => {
super(async (ps, me) => {
const report = await this.abuseUserReportsRepository.findOneBy({ id: ps.reportId });
if (report == null) {

View File

@ -2,30 +2,14 @@ import { Injectable } from '@nestjs/common';
import { Endpoint } from '@/server/api/endpoint-base.js';
import { EmailService } from '@/core/EmailService.js';
export const meta = {
tags: ['admin'],
requireCredential: true,
requireModerator: true,
} as const;
export const paramDef = {
type: 'object',
properties: {
to: { type: 'string' },
subject: { type: 'string' },
text: { type: 'string' },
},
required: ['to', 'subject', 'text'],
} as const;
// eslint-disable-next-line import/no-default-export
@Injectable()
export default class extends Endpoint<typeof meta, typeof paramDef> {
export default class extends Endpoint<'admin/send-email'> {
name = 'admin/send-email' as const;
constructor(
private emailService: EmailService,
) {
super(meta, paramDef, async (ps, me) => {
super(async (ps, me) => {
await this.emailService.sendEmail(ps.to, ps.subject, ps.text, ps.text);
});
}

View File

@ -1548,7 +1548,71 @@ export const endpoints = {
$ref: 'https://misskey-hub.net/api/schemas/InstanceMetaAdmin',
},
}],
}
},
'admin/reset-password': {
tags: ['admin'],
requireCredential: true,
requireModerator: true,
defines: [{
req: {
type: 'object',
properties: {
userId: { type: 'string', format: 'misskey:id' },
},
required: ['userId'],
},
res: {
type: 'object',
properties: {
password: {
type: 'string',
minLength: 8,
maxLength: 8,
},
},
required: ['password'],
},
}],
},
'admin/resolve-abuse-user-report': {
tags: ['admin'],
requireCredential: true,
requireModerator: true,
defines: [{
req: {
type: 'object',
properties: {
reportId: { type: 'string', format: 'misskey:id' },
forward: { type: 'boolean', default: false },
},
required: ['reportId'],
},
res: undefined,
}],
},
'admin/send-email': {
tags: ['admin'],
requireCredential: true,
requireModerator: true,
defines: [{
req: {
type: 'object',
properties: {
to: { type: 'string' },
subject: { type: 'string' },
text: { type: 'string' },
},
required: ['to', 'subject', 'text'],
},
res: undefined,
}],
},
} as const satisfies { [x: string]: IEndpointMeta; };
/**