summaryrefslogtreecommitdiff
path: root/packages/backend/src/server/api/endpoints/flash/show.ts
diff options
context:
space:
mode:
authorsyuilo <Syuilotan@yahoo.co.jp>2023-01-05 13:59:48 +0900
committerGitHub <noreply@github.com>2023-01-05 13:59:48 +0900
commitebe340d5105595abe2406e8f386c3ab69703b73b (patch)
tree36eb93333667353fb71a430b7d5e1a700d0e904e /packages/backend/src/server/api/endpoints/flash/show.ts
parentUpdate CHANGELOG.md (diff)
downloadmisskey-ebe340d5105595abe2406e8f386c3ab69703b73b.tar.gz
misskey-ebe340d5105595abe2406e8f386c3ab69703b73b.tar.bz2
misskey-ebe340d5105595abe2406e8f386c3ab69703b73b.zip
MisskeyPlay (#9467)
* wip * wip * wip * wip * wip * Update ui.ts * wip * wip * wip * wip * wip * wip * wip * wip * Update CHANGELOG.md * wip * wip * wip * wip * :art: * wip * :v:
Diffstat (limited to 'packages/backend/src/server/api/endpoints/flash/show.ts')
-rw-r--r--packages/backend/src/server/api/endpoints/flash/show.ts60
1 files changed, 60 insertions, 0 deletions
diff --git a/packages/backend/src/server/api/endpoints/flash/show.ts b/packages/backend/src/server/api/endpoints/flash/show.ts
new file mode 100644
index 0000000000..48114c5a60
--- /dev/null
+++ b/packages/backend/src/server/api/endpoints/flash/show.ts
@@ -0,0 +1,60 @@
+import { IsNull } from 'typeorm';
+import { Inject, Injectable } from '@nestjs/common';
+import type { UsersRepository, FlashsRepository } from '@/models/index.js';
+import type { Flash } from '@/models/entities/Flash.js';
+import { Endpoint } from '@/server/api/endpoint-base.js';
+import { FlashEntityService } from '@/core/entities/FlashEntityService.js';
+import { DI } from '@/di-symbols.js';
+import { ApiError } from '../../error.js';
+
+export const meta = {
+ tags: ['flashs'],
+
+ requireCredential: false,
+
+ res: {
+ type: 'object',
+ optional: false, nullable: false,
+ ref: 'Flash',
+ },
+
+ errors: {
+ noSuchFlash: {
+ message: 'No such flash.',
+ code: 'NO_SUCH_FLASH',
+ id: 'f0d34a1a-d29a-401d-90ba-1982122b5630',
+ },
+ },
+} as const;
+
+export const paramDef = {
+ type: 'object',
+ properties: {
+ flashId: { type: 'string', format: 'misskey:id' },
+ },
+ required: ['flashId'],
+} as const;
+
+// eslint-disable-next-line import/no-default-export
+@Injectable()
+export default class extends Endpoint<typeof meta, typeof paramDef> {
+ constructor(
+ @Inject(DI.usersRepository)
+ private usersRepository: UsersRepository,
+
+ @Inject(DI.flashsRepository)
+ private flashsRepository: FlashsRepository,
+
+ private flashEntityService: FlashEntityService,
+ ) {
+ super(meta, paramDef, async (ps, me) => {
+ const flash = await this.flashsRepository.findOneBy({ id: ps.flashId });
+
+ if (flash == null) {
+ throw new ApiError(meta.errors.noSuchFlash);
+ }
+
+ return await this.flashEntityService.pack(flash, me);
+ });
+ }
+}