2023-07-27 14:31:52 +09:00
|
|
|
/*
|
2024-02-13 15:59:27 +00:00
|
|
|
* SPDX-FileCopyrightText: syuilo and misskey-project
|
2023-07-27 14:31:52 +09:00
|
|
|
* SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
*/
|
|
|
|
|
|
2023-02-16 15:09:41 +01:00
|
|
|
import { Injectable } from '@nestjs/common';
|
2022-09-18 03:27:08 +09:00
|
|
|
import { Endpoint } from '@/server/api/endpoint-base.js';
|
|
|
|
|
import { GlobalEventService } from '@/core/GlobalEventService.js';
|
2023-01-12 21:02:26 +09:00
|
|
|
import { MetaService } from '@/core/MetaService.js';
|
2018-11-15 04:15:42 +09:00
|
|
|
|
|
|
|
|
export const meta = {
|
2023-01-12 21:02:26 +09:00
|
|
|
tags: ['admin', 'role'],
|
2019-02-23 11:20:58 +09:00
|
|
|
|
2022-01-18 22:27:10 +09:00
|
|
|
requireCredential: true,
|
2018-11-15 04:15:42 +09:00
|
|
|
requireAdmin: true,
|
2023-12-27 15:08:59 +09:00
|
|
|
kind: 'write:admin:roles',
|
2022-02-19 14:05:32 +09:00
|
|
|
} as const;
|
2018-11-15 04:15:42 +09:00
|
|
|
|
2022-02-20 13:15:40 +09:00
|
|
|
export const paramDef = {
|
2022-02-19 14:05:32 +09:00
|
|
|
type: 'object',
|
|
|
|
|
properties: {
|
2023-01-15 20:52:53 +09:00
|
|
|
policies: {
|
2023-01-12 21:02:26 +09:00
|
|
|
type: 'object',
|
|
|
|
|
},
|
2021-12-09 23:58:30 +09:00
|
|
|
},
|
2023-01-12 21:02:26 +09:00
|
|
|
required: [
|
2023-01-15 20:52:53 +09:00
|
|
|
'policies',
|
2023-01-12 21:02:26 +09:00
|
|
|
],
|
2022-01-18 22:27:10 +09:00
|
|
|
} as const;
|
2018-11-15 04:15:42 +09:00
|
|
|
|
2022-09-18 03:27:08 +09:00
|
|
|
@Injectable()
|
2023-08-17 21:20:58 +09:00
|
|
|
export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-disable-line import/no-default-export
|
2022-09-18 03:27:08 +09:00
|
|
|
constructor(
|
2023-01-12 21:02:26 +09:00
|
|
|
private metaService: MetaService,
|
2022-09-18 03:27:08 +09:00
|
|
|
private globalEventService: GlobalEventService,
|
|
|
|
|
) {
|
|
|
|
|
super(meta, paramDef, async (ps) => {
|
2023-01-12 21:02:26 +09:00
|
|
|
await this.metaService.update({
|
2023-01-15 20:52:53 +09:00
|
|
|
policies: ps.policies,
|
2022-09-18 03:27:08 +09:00
|
|
|
});
|
2023-01-15 20:52:53 +09:00
|
|
|
this.globalEventService.publishInternalEvent('policiesUpdated', ps.policies);
|
2022-09-18 03:27:08 +09:00
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|