wip
This commit is contained in:
parent
bc15dde742
commit
78558eb666
4 changed files with 79 additions and 73 deletions
|
@ -5,37 +5,10 @@ import { Endpoint } from '@/server/api/endpoint-base.js';
|
||||||
import type { UsersRepository, UserProfilesRepository } from '@/models/index.js';
|
import type { UsersRepository, UserProfilesRepository } from '@/models/index.js';
|
||||||
import { DI } from '@/di-symbols.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
|
// eslint-disable-next-line import/no-default-export
|
||||||
@Injectable()
|
@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(
|
constructor(
|
||||||
@Inject(DI.usersRepository)
|
@Inject(DI.usersRepository)
|
||||||
private usersRepository: UsersRepository,
|
private usersRepository: UsersRepository,
|
||||||
|
@ -43,7 +16,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
|
||||||
@Inject(DI.userProfilesRepository)
|
@Inject(DI.userProfilesRepository)
|
||||||
private userProfilesRepository: UserProfilesRepository,
|
private userProfilesRepository: UserProfilesRepository,
|
||||||
) {
|
) {
|
||||||
super(meta, paramDef, async (ps) => {
|
super(async (ps) => {
|
||||||
const user = await this.usersRepository.findOneBy({ id: ps.userId });
|
const user = await this.usersRepository.findOneBy({ id: ps.userId });
|
||||||
|
|
||||||
if (user == null) {
|
if (user == null) {
|
||||||
|
|
|
@ -6,27 +6,12 @@ import { QueueService } from '@/core/QueueService.js';
|
||||||
import { ApRendererService } from '@/core/activitypub/ApRendererService.js';
|
import { ApRendererService } from '@/core/activitypub/ApRendererService.js';
|
||||||
import { DI } from '@/di-symbols.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: ロジックをサービスに切り出す
|
// TODO: ロジックをサービスに切り出す
|
||||||
|
|
||||||
// eslint-disable-next-line import/no-default-export
|
// eslint-disable-next-line import/no-default-export
|
||||||
@Injectable()
|
@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(
|
constructor(
|
||||||
@Inject(DI.usersRepository)
|
@Inject(DI.usersRepository)
|
||||||
private usersRepository: UsersRepository,
|
private usersRepository: UsersRepository,
|
||||||
|
@ -38,7 +23,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
|
||||||
private instanceActorService: InstanceActorService,
|
private instanceActorService: InstanceActorService,
|
||||||
private apRendererService: ApRendererService,
|
private apRendererService: ApRendererService,
|
||||||
) {
|
) {
|
||||||
super(meta, paramDef, async (ps, me) => {
|
super(async (ps, me) => {
|
||||||
const report = await this.abuseUserReportsRepository.findOneBy({ id: ps.reportId });
|
const report = await this.abuseUserReportsRepository.findOneBy({ id: ps.reportId });
|
||||||
|
|
||||||
if (report == null) {
|
if (report == null) {
|
||||||
|
|
|
@ -2,30 +2,14 @@ import { Injectable } from '@nestjs/common';
|
||||||
import { Endpoint } from '@/server/api/endpoint-base.js';
|
import { Endpoint } from '@/server/api/endpoint-base.js';
|
||||||
import { EmailService } from '@/core/EmailService.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
|
// eslint-disable-next-line import/no-default-export
|
||||||
@Injectable()
|
@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(
|
constructor(
|
||||||
private emailService: EmailService,
|
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);
|
await this.emailService.sendEmail(ps.to, ps.subject, ps.text, ps.text);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -1470,7 +1470,7 @@ export const endpoints = {
|
||||||
'admin/get-index-stats': {
|
'admin/get-index-stats': {
|
||||||
requireCredential: true,
|
requireCredential: true,
|
||||||
requireAdmin: true,
|
requireAdmin: true,
|
||||||
|
|
||||||
tags: ['admin'],
|
tags: ['admin'],
|
||||||
|
|
||||||
defines: [{
|
defines: [{
|
||||||
|
@ -1491,9 +1491,9 @@ export const endpoints = {
|
||||||
'admin/get-table-stats': {
|
'admin/get-table-stats': {
|
||||||
requireCredential: true,
|
requireCredential: true,
|
||||||
requireAdmin: true,
|
requireAdmin: true,
|
||||||
|
|
||||||
tags: ['admin'],
|
tags: ['admin'],
|
||||||
|
|
||||||
defines: [{
|
defines: [{
|
||||||
req: undefined,
|
req: undefined,
|
||||||
res: {
|
res: {
|
||||||
|
@ -1511,7 +1511,7 @@ export const endpoints = {
|
||||||
},
|
},
|
||||||
'admin/get-user-ips': {
|
'admin/get-user-ips': {
|
||||||
tags: ['admin'],
|
tags: ['admin'],
|
||||||
|
|
||||||
requireCredential: true,
|
requireCredential: true,
|
||||||
requireModerator: true,
|
requireModerator: true,
|
||||||
|
|
||||||
|
@ -1538,7 +1538,7 @@ export const endpoints = {
|
||||||
},
|
},
|
||||||
'admin/meta': {
|
'admin/meta': {
|
||||||
tags: ['meta'],
|
tags: ['meta'],
|
||||||
|
|
||||||
requireCredential: true,
|
requireCredential: true,
|
||||||
requireAdmin: true,
|
requireAdmin: true,
|
||||||
|
|
||||||
|
@ -1548,7 +1548,71 @@ export const endpoints = {
|
||||||
$ref: 'https://misskey-hub.net/api/schemas/InstanceMetaAdmin',
|
$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; };
|
} as const satisfies { [x: string]: IEndpointMeta; };
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue