From 70a78009270df3ff9a76e84a4e2dd0837a1b5f46 Mon Sep 17 00:00:00 2001 From: GrapeApple0 <84321396+GrapeApple0@users.noreply.github.com> Date: Mon, 21 Aug 2023 20:23:09 +0900 Subject: [PATCH] =?UTF-8?q?=E3=83=97=E3=83=AD=E3=83=95=E3=82=A3=E3=83=BC?= =?UTF-8?q?=E3=83=AB=E3=81=AB=E3=81=9D=E3=81=AE=E4=BA=BA=E3=81=8C=E4=BD=9C?= =?UTF-8?q?=E3=81=A3=E3=81=9FPlay=E3=81=AE=E4=B8=80=E8=A6=A7=E5=87=BA?= =?UTF-8?q?=E3=81=9B=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB=20(#11445)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * プロフィールにその人が作ったPlayの一覧出せるように * Update CHANGELOG.md * playの公開範囲を設定できるように * 間違えて変更してしまったのを修正 * Update packages/frontend/src/pages/flash/flash-edit.vue * Update packages/frontend/src/pages/flash/flash-edit.vue * tweak * Update packages/backend/migration/1690796169261-play-visibility.js * Update packages/backend/src/models/entities/Flash.ts * Update packages/backend/src/models/entities/Flash.ts * Update Flash.ts --------- Co-authored-by: syuilo --- CHANGELOG.md | 1 + locales/en-US.yml | 1 + locales/index.d.ts | 1 + locales/ja-JP.yml | 1 + .../1690796169261-play-visibility.js | 15 +++++ packages/backend/src/models/entities/Flash.ts | 9 +++ .../backend/src/server/api/EndpointsModule.ts | 4 ++ packages/backend/src/server/api/endpoints.ts | 2 + .../src/server/api/endpoints/flash/update.ts | 1 + .../src/server/api/endpoints/users/flashs.ts | 62 +++++++++++++++++++ .../frontend/src/pages/flash/flash-edit.vue | 8 +++ packages/frontend/src/pages/user/flashs.vue | 31 ++++++++++ packages/frontend/src/pages/user/index.vue | 6 ++ packages/misskey-js/src/api.types.ts | 1 + 14 files changed, 143 insertions(+) create mode 100644 packages/backend/migration/1690796169261-play-visibility.js create mode 100644 packages/backend/src/server/api/endpoints/users/flashs.ts create mode 100644 packages/frontend/src/pages/user/flashs.vue diff --git a/CHANGELOG.md b/CHANGELOG.md index a768f0ecb2..88c6c36252 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,6 +23,7 @@ - チャンネルをセンシティブ指定できるようになりました ### Client +- プロフィールにその人が作ったPlayの一覧出せるように - メニューのスイッチの動作を改善 - 絵文字ピッカーの検索の表示件数を100件に増加 - 投稿フォームのプレビューの表示状態を記憶するように diff --git a/locales/en-US.yml b/locales/en-US.yml index 097aba76ba..320a2dbcbc 100644 --- a/locales/en-US.yml +++ b/locales/en-US.yml @@ -680,6 +680,7 @@ createNewClip: "Create new clip" unclip: "Unclip" confirmToUnclipAlreadyClippedNote: "This note is already part of the \"{name}\" clip. Do you want to remove it from this clip instead?" public: "Public" +private: "Private" i18nInfo: "Misskey is being translated into various languages by volunteers. You can help at {link}." manageAccessTokens: "Manage access tokens" accountInfo: "Account Info" diff --git a/locales/index.d.ts b/locales/index.d.ts index d7c85b9597..1f25edd0ef 100644 --- a/locales/index.d.ts +++ b/locales/index.d.ts @@ -684,6 +684,7 @@ export interface Locale { "unclip": string; "confirmToUnclipAlreadyClippedNote": string; "public": string; + "private": string; "i18nInfo": string; "manageAccessTokens": string; "accountInfo": string; diff --git a/locales/ja-JP.yml b/locales/ja-JP.yml index 0dfaa43653..2e0e64bbef 100644 --- a/locales/ja-JP.yml +++ b/locales/ja-JP.yml @@ -681,6 +681,7 @@ createNewClip: "新しいクリップを作成" unclip: "クリップ解除" confirmToUnclipAlreadyClippedNote: "このノートはすでにクリップ「{name}」に含まれています。ノートをこのクリップから除外しますか?" public: "パブリック" +private: "非公開" i18nInfo: "Misskeyは有志によって様々な言語に翻訳されています。{link}で翻訳に協力できます。" manageAccessTokens: "アクセストークンの管理" accountInfo: "アカウント情報" diff --git a/packages/backend/migration/1690796169261-play-visibility.js b/packages/backend/migration/1690796169261-play-visibility.js new file mode 100644 index 0000000000..c57fa7a109 --- /dev/null +++ b/packages/backend/migration/1690796169261-play-visibility.js @@ -0,0 +1,15 @@ +/* + * SPDX-FileCopyrightText: syuilo and other misskey contributors + * SPDX-License-Identifier: AGPL-3.0-only + */ + +export class PlayVisibility1689102832143 { + name = 'PlayVisibility1690796169261' + + async up(queryRunner) { + await queryRunner.query(`ALTER TABLE "public"."flash" ADD "visibility" character varying(512) DEFAULT 'public'`, undefined); + } + async down(queryRunner) { + await queryRunner.query(`ALTER TABLE "public"."flash" DROP COLUMN "visibility"`, undefined); + } +} diff --git a/packages/backend/src/models/entities/Flash.ts b/packages/backend/src/models/entities/Flash.ts index af4553ee9b..38e023332e 100644 --- a/packages/backend/src/models/entities/Flash.ts +++ b/packages/backend/src/models/entities/Flash.ts @@ -61,4 +61,13 @@ export class MiFlash { default: 0, }) public likedCount: number; + + /** + * public ... 公開 + * private ... プロフィールには表示しない + */ + @Column('varchar', { + length: 512, default: 'public', + }) + public visibility: 'public' | 'private'; } diff --git a/packages/backend/src/server/api/EndpointsModule.ts b/packages/backend/src/server/api/EndpointsModule.ts index 3be6524689..799ba4498d 100644 --- a/packages/backend/src/server/api/EndpointsModule.ts +++ b/packages/backend/src/server/api/EndpointsModule.ts @@ -336,6 +336,7 @@ import * as ep___users_lists_unfavorite from './endpoints/users/lists/unfavorite import * as ep___users_lists_create_from_public from './endpoints/users/lists/create-from-public.js'; import * as ep___users_notes from './endpoints/users/notes.js'; import * as ep___users_pages from './endpoints/users/pages.js'; +import * as ep___users_flashs from './endpoints/users/flashs.js'; import * as ep___users_reactions from './endpoints/users/reactions.js'; import * as ep___users_recommendation from './endpoints/users/recommendation.js'; import * as ep___users_relation from './endpoints/users/relation.js'; @@ -681,6 +682,7 @@ const $users_lists_unfavorite: Provider = { provide: 'ep:users/lists/unfavorite' const $users_lists_create_from_public: Provider = { provide: 'ep:users/lists/create-from-public', useClass: ep___users_lists_create_from_public.default }; const $users_notes: Provider = { provide: 'ep:users/notes', useClass: ep___users_notes.default }; const $users_pages: Provider = { provide: 'ep:users/pages', useClass: ep___users_pages.default }; +const $users_flashs: Provider = { provide: 'ep:users/flashs', useClass: ep___users_flashs.default }; const $users_reactions: Provider = { provide: 'ep:users/reactions', useClass: ep___users_reactions.default }; const $users_recommendation: Provider = { provide: 'ep:users/recommendation', useClass: ep___users_recommendation.default }; const $users_relation: Provider = { provide: 'ep:users/relation', useClass: ep___users_relation.default }; @@ -1030,6 +1032,7 @@ const $retention: Provider = { provide: 'ep:retention', useClass: ep___retention $users_lists_create_from_public, $users_notes, $users_pages, + $users_flashs, $users_reactions, $users_recommendation, $users_relation, @@ -1371,6 +1374,7 @@ const $retention: Provider = { provide: 'ep:retention', useClass: ep___retention $users_lists_create_from_public, $users_notes, $users_pages, + $users_flashs, $users_reactions, $users_recommendation, $users_relation, diff --git a/packages/backend/src/server/api/endpoints.ts b/packages/backend/src/server/api/endpoints.ts index 5fef975fa6..3924b43d16 100644 --- a/packages/backend/src/server/api/endpoints.ts +++ b/packages/backend/src/server/api/endpoints.ts @@ -336,6 +336,7 @@ import * as ep___users_lists_create_from_public from './endpoints/users/lists/cr import * as ep___users_lists_update from './endpoints/users/lists/update.js'; import * as ep___users_notes from './endpoints/users/notes.js'; import * as ep___users_pages from './endpoints/users/pages.js'; +import * as ep___users_flashs from './endpoints/users/flashs.js'; import * as ep___users_reactions from './endpoints/users/reactions.js'; import * as ep___users_recommendation from './endpoints/users/recommendation.js'; import * as ep___users_relation from './endpoints/users/relation.js'; @@ -679,6 +680,7 @@ const eps = [ ['users/lists/create-from-public', ep___users_lists_create_from_public], ['users/notes', ep___users_notes], ['users/pages', ep___users_pages], + ['users/flashs', ep___users_flashs], ['users/reactions', ep___users_reactions], ['users/recommendation', ep___users_recommendation], ['users/relation', ep___users_relation], diff --git a/packages/backend/src/server/api/endpoints/flash/update.ts b/packages/backend/src/server/api/endpoints/flash/update.ts index 04ed79350e..9da29b50ea 100644 --- a/packages/backend/src/server/api/endpoints/flash/update.ts +++ b/packages/backend/src/server/api/endpoints/flash/update.ts @@ -49,6 +49,7 @@ export const paramDef = { permissions: { type: 'array', items: { type: 'string', } }, + visibility: { type: 'string', enum: ['public', 'private'] }, }, required: ['flashId', 'title', 'summary', 'script', 'permissions'], } as const; diff --git a/packages/backend/src/server/api/endpoints/users/flashs.ts b/packages/backend/src/server/api/endpoints/users/flashs.ts new file mode 100644 index 0000000000..4e267f9003 --- /dev/null +++ b/packages/backend/src/server/api/endpoints/users/flashs.ts @@ -0,0 +1,62 @@ +/* + * SPDX-FileCopyrightText: syuilo and other misskey contributors + * SPDX-License-Identifier: AGPL-3.0-only + */ + +import { Inject, Injectable } from '@nestjs/common'; +import { Endpoint } from '@/server/api/endpoint-base.js'; +import { QueryService } from '@/core/QueryService.js'; +import { FlashEntityService } from '@/core/entities/FlashEntityService.js'; +import type { FlashsRepository } from '@/models/index.js'; +import { DI } from '@/di-symbols.js'; + +export const meta = { + tags: ['users', 'flashs'], + + description: 'Show all flashs this user created.', + + res: { + type: 'array', + optional: false, nullable: false, + items: { + type: 'object', + optional: false, nullable: false, + ref: 'Flash', + }, + }, +} as const; + +export const paramDef = { + type: 'object', + properties: { + userId: { type: 'string', format: 'misskey:id' }, + limit: { type: 'integer', minimum: 1, maximum: 100, default: 10 }, + sinceId: { type: 'string', format: 'misskey:id' }, + untilId: { type: 'string', format: 'misskey:id' }, + }, + required: ['userId'], +} as const; + +// eslint-disable-next-line import/no-default-export +@Injectable() +export default class extends Endpoint { + constructor( + @Inject(DI.flashsRepository) + private flashsRepository: FlashsRepository, + + private flashEntityService: FlashEntityService, + private queryService: QueryService, + ) { + super(meta, paramDef, async (ps, me) => { + const query = this.queryService.makePaginationQuery(this.flashsRepository.createQueryBuilder('flash'), ps.sinceId, ps.untilId) + .andWhere('flash.userId = :userId', { userId: ps.userId }) + .andWhere('flash.visibility = \'public\''); + + const flashs = await query + .limit(ps.limit) + .getMany(); + + return await this.flashEntityService.packMany(flashs); + }); + } +} diff --git a/packages/frontend/src/pages/flash/flash-edit.vue b/packages/frontend/src/pages/flash/flash-edit.vue index fecf6edd0c..414fe4836c 100644 --- a/packages/frontend/src/pages/flash/flash-edit.vue +++ b/packages/frontend/src/pages/flash/flash-edit.vue @@ -23,6 +23,11 @@ SPDX-License-Identifier: AGPL-3.0-only {{ i18n.ts.show }} {{ i18n.ts.delete }} + + + + + @@ -36,6 +41,7 @@ import { i18n } from '@/i18n'; import { definePageMetadata } from '@/scripts/page-metadata'; import MkTextarea from '@/components/MkTextarea.vue'; import MkInput from '@/components/MkInput.vue'; +import MkSelect from '@/components/MkSelect.vue'; import { useRouter } from '@/router'; const PRESET_DEFAULT = `/// @ 0.15.0 @@ -358,6 +364,7 @@ const props = defineProps<{ }>(); let flash = $ref(null); +let visibility = $ref('public'); if (props.id) { flash = await os.api('flash/show', { @@ -402,6 +409,7 @@ async function save() { summary, permissions, script, + visibility, }); } else { const created = await os.apiWithDialog('flash/create', { diff --git a/packages/frontend/src/pages/user/flashs.vue b/packages/frontend/src/pages/user/flashs.vue new file mode 100644 index 0000000000..b91ecb8de6 --- /dev/null +++ b/packages/frontend/src/pages/user/flashs.vue @@ -0,0 +1,31 @@ + + + + + diff --git a/packages/frontend/src/pages/user/index.vue b/packages/frontend/src/pages/user/index.vue index 314548fee3..c014897a24 100644 --- a/packages/frontend/src/pages/user/index.vue +++ b/packages/frontend/src/pages/user/index.vue @@ -16,6 +16,7 @@ SPDX-License-Identifier: AGPL-3.0-only + @@ -42,6 +43,7 @@ const XReactions = defineAsyncComponent(() => import('./reactions.vue')); const XClips = defineAsyncComponent(() => import('./clips.vue')); const XLists = defineAsyncComponent(() => import('./lists.vue')); const XPages = defineAsyncComponent(() => import('./pages.vue')); +const XFlashs = defineAsyncComponent(() => import('./flashs.vue')); const XGallery = defineAsyncComponent(() => import('./gallery.vue')); const props = withDefaults(defineProps<{ @@ -103,6 +105,10 @@ const headerTabs = $computed(() => user ? [{ key: 'pages', title: i18n.ts.pages, icon: 'ti ti-news', +}, { + key: 'flashs', + title: 'Play', + icon: 'ti ti-player-play', }, { key: 'gallery', title: i18n.ts.gallery, diff --git a/packages/misskey-js/src/api.types.ts b/packages/misskey-js/src/api.types.ts index de9af99168..70ef570166 100644 --- a/packages/misskey-js/src/api.types.ts +++ b/packages/misskey-js/src/api.types.ts @@ -621,6 +621,7 @@ export type Endpoints = { 'users/lists/update': { req: { listId: UserList['id']; name: string; }; res: UserList; }; 'users/notes': { req: { userId: User['id']; limit?: number; sinceId?: Note['id']; untilId?: Note['id']; sinceDate?: number; untilDate?: number; }; res: Note[]; }; 'users/pages': { req: TODO; res: TODO; }; + 'users/flashs': { req: TODO; res: TODO; }; 'users/recommendation': { req: TODO; res: TODO; }; 'users/relation': { req: TODO; res: TODO; }; 'users/report-abuse': { req: TODO; res: TODO; };