diff options
| author | かっこかり <67428053+kakkokari-gtyih@users.noreply.github.com> | 2024-05-27 17:15:11 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-05-27 17:15:11 +0900 |
| commit | 3ffbf6296f44c6f8837f0b8533a3b60b64403bf9 (patch) | |
| tree | 8c550ce179f61238f2a0beaf0209bdcce2799ba5 /packages/backend/src/server/api/endpoints/announcements | |
| parent | fix(backend): `read:admin:show-user` と `read:admin:show-users` を統合 (#... (diff) | |
| download | misskey-3ffbf6296f44c6f8837f0b8533a3b60b64403bf9.tar.gz misskey-3ffbf6296f44c6f8837f0b8533a3b60b64403bf9.tar.bz2 misskey-3ffbf6296f44c6f8837f0b8533a3b60b64403bf9.zip | |
feat: 個別のお知らせにリンクで飛べるように (#13885)
* feat(announcement): 個別のお知らせにリンクで飛べるように (MisskeyIO#639)
(cherry picked from commit f6bf7f992a78e54d86a4701dbd1e4fda7ef4eb27)
* fix
Co-authored-by: まっちゃとーにゅ <17376330+u1-liquid@users.noreply.github.com>
* fix
Co-authored-by: まっちゃとーにゅ <17376330+u1-liquid@users.noreply.github.com>
* 一覧ページではお知らせpanel全体を押せるように
* お知らせバーは個別ページに飛ばすように
* Update Changelog
* spdx
* attempt to fox test
* remove unnecessary thong
* `announcement` → `announcements/show`
* リンクを押せる場所をタイトルと日付部分のみに変更
---------
Co-authored-by: まっちゃとーにゅ <17376330+u1-liquid@users.noreply.github.com>
Diffstat (limited to 'packages/backend/src/server/api/endpoints/announcements')
| -rw-r--r-- | packages/backend/src/server/api/endpoints/announcements/show.ts | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/packages/backend/src/server/api/endpoints/announcements/show.ts b/packages/backend/src/server/api/endpoints/announcements/show.ts new file mode 100644 index 0000000000..6312a0a54c --- /dev/null +++ b/packages/backend/src/server/api/endpoints/announcements/show.ts @@ -0,0 +1,54 @@ +/* + * SPDX-FileCopyrightText: syuilo and misskey-project + * SPDX-License-Identifier: AGPL-3.0-only + */ + +import { Injectable } from '@nestjs/common'; +import { EntityNotFoundError } from 'typeorm'; +import { Endpoint } from '@/server/api/endpoint-base.js'; +import { AnnouncementService } from '@/core/AnnouncementService.js'; +import { ApiError } from '../../error.js'; + +export const meta = { + tags: ['meta'], + + requireCredential: false, + + res: { + type: 'object', + optional: false, nullable: false, + ref: 'Announcement', + }, + + errors: { + noSuchAnnouncement: { + message: 'No such announcement.', + code: 'NO_SUCH_ANNOUNCEMENT', + id: 'b57b5e1d-4f49-404a-9edb-46b00268f121', + }, + }, +} as const; + +export const paramDef = { + type: 'object', + properties: { + announcementId: { type: 'string', format: 'misskey:id' }, + }, + required: ['announcementId'], +} as const; + +@Injectable() +export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-disable-line import/no-default-export + constructor( + private announcementService: AnnouncementService, + ) { + super(meta, paramDef, async (ps, me) => { + try { + return await this.announcementService.getAnnouncement(ps.announcementId, me); + } catch (err) { + if (err instanceof EntityNotFoundError) throw new ApiError(meta.errors.noSuchAnnouncement); + throw err; + } + }); + } +} |