2023-08-15 02:52:38 +09:00
|
|
|
/*
|
|
|
|
|
* SPDX-FileCopyrightText: syuilo and other misskey contributors
|
|
|
|
|
* SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
*/
|
|
|
|
|
|
2023-09-28 06:00:23 +09:00
|
|
|
import { Injectable } from '@nestjs/common';
|
2022-09-18 03:27:08 +09:00
|
|
|
import { Endpoint } from '@/server/api/endpoint-base.js';
|
2023-08-18 08:03:03 +09:00
|
|
|
import { AnnouncementService } from '@/core/AnnouncementService.js';
|
2020-01-30 04:37:25 +09:00
|
|
|
|
|
|
|
|
export const meta = {
|
2020-04-03 22:42:29 +09:00
|
|
|
tags: ['meta'],
|
|
|
|
|
|
2022-01-18 22:27:10 +09:00
|
|
|
requireCredential: false,
|
2020-01-30 04:37:25 +09:00
|
|
|
|
2021-03-06 22:34:11 +09:00
|
|
|
res: {
|
2022-01-18 22:27:10 +09:00
|
|
|
type: 'array',
|
|
|
|
|
optional: false, nullable: false,
|
2021-03-06 22:34:11 +09:00
|
|
|
items: {
|
2022-01-18 22:27:10 +09:00
|
|
|
type: 'object',
|
|
|
|
|
optional: false, nullable: false,
|
2023-08-18 08:03:03 +09:00
|
|
|
ref: 'Announcement',
|
2021-12-09 23:58:30 +09:00
|
|
|
},
|
|
|
|
|
},
|
2022-01-18 22:27:10 +09:00
|
|
|
} as const;
|
2020-01-30 04:37:25 +09:00
|
|
|
|
2022-02-20 13:15:40 +09:00
|
|
|
export const paramDef = {
|
2022-02-19 14:05:32 +09:00
|
|
|
type: 'object',
|
|
|
|
|
properties: {
|
|
|
|
|
limit: { type: 'integer', minimum: 1, maximum: 100, default: 10 },
|
2023-08-19 04:48:28 +09:00
|
|
|
offset: { type: 'integer', default: 0 },
|
2023-08-18 08:03:03 +09:00
|
|
|
isActive: { type: 'boolean', default: true },
|
2022-02-19 14:05:32 +09:00
|
|
|
},
|
|
|
|
|
required: [],
|
|
|
|
|
} as const;
|
|
|
|
|
|
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-08-18 08:03:03 +09:00
|
|
|
private announcementService: AnnouncementService,
|
2022-09-18 03:27:08 +09:00
|
|
|
) {
|
|
|
|
|
super(meta, paramDef, async (ps, me) => {
|
2023-08-19 04:48:28 +09:00
|
|
|
return this.announcementService.getAnnouncements(me, ps.limit, ps.offset, ps.isActive);
|
2022-09-18 03:27:08 +09:00
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|