プロフィールにその人が作ったPlayの一覧出せるように (#11445)

* プロフィールにその人が作った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 <Syuilotan@yahoo.co.jp>
This commit is contained in:
GrapeApple0 2023-08-21 20:23:09 +09:00 committed by GitHub
parent 77f18f4250
commit 70a7800927
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 143 additions and 0 deletions

View File

@ -23,6 +23,7 @@
- チャンネルをセンシティブ指定できるようになりました - チャンネルをセンシティブ指定できるようになりました
### Client ### Client
- プロフィールにその人が作ったPlayの一覧出せるように
- メニューのスイッチの動作を改善 - メニューのスイッチの動作を改善
- 絵文字ピッカーの検索の表示件数を100件に増加 - 絵文字ピッカーの検索の表示件数を100件に増加
- 投稿フォームのプレビューの表示状態を記憶するように - 投稿フォームのプレビューの表示状態を記憶するように

View File

@ -680,6 +680,7 @@ createNewClip: "Create new clip"
unclip: "Unclip" unclip: "Unclip"
confirmToUnclipAlreadyClippedNote: "This note is already part of the \"{name}\" clip. Do you want to remove it from this clip instead?" confirmToUnclipAlreadyClippedNote: "This note is already part of the \"{name}\" clip. Do you want to remove it from this clip instead?"
public: "Public" public: "Public"
private: "Private"
i18nInfo: "Misskey is being translated into various languages by volunteers. You can help at {link}." i18nInfo: "Misskey is being translated into various languages by volunteers. You can help at {link}."
manageAccessTokens: "Manage access tokens" manageAccessTokens: "Manage access tokens"
accountInfo: "Account Info" accountInfo: "Account Info"

1
locales/index.d.ts vendored
View File

@ -684,6 +684,7 @@ export interface Locale {
"unclip": string; "unclip": string;
"confirmToUnclipAlreadyClippedNote": string; "confirmToUnclipAlreadyClippedNote": string;
"public": string; "public": string;
"private": string;
"i18nInfo": string; "i18nInfo": string;
"manageAccessTokens": string; "manageAccessTokens": string;
"accountInfo": string; "accountInfo": string;

View File

@ -681,6 +681,7 @@ createNewClip: "新しいクリップを作成"
unclip: "クリップ解除" unclip: "クリップ解除"
confirmToUnclipAlreadyClippedNote: "このノートはすでにクリップ「{name}」に含まれています。ノートをこのクリップから除外しますか?" confirmToUnclipAlreadyClippedNote: "このノートはすでにクリップ「{name}」に含まれています。ノートをこのクリップから除外しますか?"
public: "パブリック" public: "パブリック"
private: "非公開"
i18nInfo: "Misskeyは有志によって様々な言語に翻訳されています。{link}で翻訳に協力できます。" i18nInfo: "Misskeyは有志によって様々な言語に翻訳されています。{link}で翻訳に協力できます。"
manageAccessTokens: "アクセストークンの管理" manageAccessTokens: "アクセストークンの管理"
accountInfo: "アカウント情報" accountInfo: "アカウント情報"

View File

@ -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);
}
}

View File

@ -61,4 +61,13 @@ export class MiFlash {
default: 0, default: 0,
}) })
public likedCount: number; public likedCount: number;
/**
* public ...
* private ...
*/
@Column('varchar', {
length: 512, default: 'public',
})
public visibility: 'public' | 'private';
} }

View File

@ -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_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_notes from './endpoints/users/notes.js';
import * as ep___users_pages from './endpoints/users/pages.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_reactions from './endpoints/users/reactions.js';
import * as ep___users_recommendation from './endpoints/users/recommendation.js'; import * as ep___users_recommendation from './endpoints/users/recommendation.js';
import * as ep___users_relation from './endpoints/users/relation.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_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_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_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_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_recommendation: Provider = { provide: 'ep:users/recommendation', useClass: ep___users_recommendation.default };
const $users_relation: Provider = { provide: 'ep:users/relation', useClass: ep___users_relation.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_lists_create_from_public,
$users_notes, $users_notes,
$users_pages, $users_pages,
$users_flashs,
$users_reactions, $users_reactions,
$users_recommendation, $users_recommendation,
$users_relation, $users_relation,
@ -1371,6 +1374,7 @@ const $retention: Provider = { provide: 'ep:retention', useClass: ep___retention
$users_lists_create_from_public, $users_lists_create_from_public,
$users_notes, $users_notes,
$users_pages, $users_pages,
$users_flashs,
$users_reactions, $users_reactions,
$users_recommendation, $users_recommendation,
$users_relation, $users_relation,

View File

@ -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_lists_update from './endpoints/users/lists/update.js';
import * as ep___users_notes from './endpoints/users/notes.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_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_reactions from './endpoints/users/reactions.js';
import * as ep___users_recommendation from './endpoints/users/recommendation.js'; import * as ep___users_recommendation from './endpoints/users/recommendation.js';
import * as ep___users_relation from './endpoints/users/relation.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/lists/create-from-public', ep___users_lists_create_from_public],
['users/notes', ep___users_notes], ['users/notes', ep___users_notes],
['users/pages', ep___users_pages], ['users/pages', ep___users_pages],
['users/flashs', ep___users_flashs],
['users/reactions', ep___users_reactions], ['users/reactions', ep___users_reactions],
['users/recommendation', ep___users_recommendation], ['users/recommendation', ep___users_recommendation],
['users/relation', ep___users_relation], ['users/relation', ep___users_relation],

View File

@ -49,6 +49,7 @@ export const paramDef = {
permissions: { type: 'array', items: { permissions: { type: 'array', items: {
type: 'string', type: 'string',
} }, } },
visibility: { type: 'string', enum: ['public', 'private'] },
}, },
required: ['flashId', 'title', 'summary', 'script', 'permissions'], required: ['flashId', 'title', 'summary', 'script', 'permissions'],
} as const; } as const;

View File

@ -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<typeof meta, typeof paramDef> {
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);
});
}
}

View File

@ -23,6 +23,11 @@ SPDX-License-Identifier: AGPL-3.0-only
<MkButton @click="show"><i class="ti ti-eye"></i> {{ i18n.ts.show }}</MkButton> <MkButton @click="show"><i class="ti ti-eye"></i> {{ i18n.ts.show }}</MkButton>
<MkButton v-if="flash" danger @click="del"><i class="ti ti-trash"></i> {{ i18n.ts.delete }}</MkButton> <MkButton v-if="flash" danger @click="del"><i class="ti ti-trash"></i> {{ i18n.ts.delete }}</MkButton>
</div> </div>
<MkSelect v-model="visibility">
<template #label>{{ i18n.ts.visibility }}</template>
<option :key="'public'" :value="'public'">{{ i18n.ts.public }}</option>
<option :key="'private'" :value="'private'">{{ i18n.ts.private }}</option>
</MkSelect>
</div> </div>
</MkSpacer> </MkSpacer>
</MkStickyContainer> </MkStickyContainer>
@ -36,6 +41,7 @@ import { i18n } from '@/i18n';
import { definePageMetadata } from '@/scripts/page-metadata'; import { definePageMetadata } from '@/scripts/page-metadata';
import MkTextarea from '@/components/MkTextarea.vue'; import MkTextarea from '@/components/MkTextarea.vue';
import MkInput from '@/components/MkInput.vue'; import MkInput from '@/components/MkInput.vue';
import MkSelect from '@/components/MkSelect.vue';
import { useRouter } from '@/router'; import { useRouter } from '@/router';
const PRESET_DEFAULT = `/// @ 0.15.0 const PRESET_DEFAULT = `/// @ 0.15.0
@ -358,6 +364,7 @@ const props = defineProps<{
}>(); }>();
let flash = $ref(null); let flash = $ref(null);
let visibility = $ref('public');
if (props.id) { if (props.id) {
flash = await os.api('flash/show', { flash = await os.api('flash/show', {
@ -402,6 +409,7 @@ async function save() {
summary, summary,
permissions, permissions,
script, script,
visibility,
}); });
} else { } else {
const created = await os.apiWithDialog('flash/create', { const created = await os.apiWithDialog('flash/create', {

View File

@ -0,0 +1,31 @@
<!--
SPDX-FileCopyrightText: syuilo and other misskey contributors
SPDX-License-Identifier: AGPL-3.0-only
-->
<template>
<MkSpacer :contentMax="700">
<MkPagination v-slot="{items}" ref="list" :pagination="pagination">
<MkFlashPreview v-for="flash in items" :key="flash.id" :flash="flash" class="_margin"/>
</MkPagination>
</MkSpacer>
</template>
<script lang="ts" setup>
import { computed } from 'vue';
import * as misskey from 'misskey-js';
import MkFlashPreview from '@/components/MkFlashPreview.vue';
import MkPagination from '@/components/MkPagination.vue';
const props = defineProps<{
user: misskey.entities.User;
}>();
const pagination = {
endpoint: 'users/flashs' as const,
limit: 20,
params: computed(() => ({
userId: props.user.id,
})),
};
</script>

View File

@ -16,6 +16,7 @@ SPDX-License-Identifier: AGPL-3.0-only
<XClips v-else-if="tab === 'clips'" :user="user"/> <XClips v-else-if="tab === 'clips'" :user="user"/>
<XLists v-else-if="tab === 'lists'" :user="user"/> <XLists v-else-if="tab === 'lists'" :user="user"/>
<XPages v-else-if="tab === 'pages'" :user="user"/> <XPages v-else-if="tab === 'pages'" :user="user"/>
<XFlashs v-else-if="tab === 'flashs'" :user="user"/>
<XGallery v-else-if="tab === 'gallery'" :user="user"/> <XGallery v-else-if="tab === 'gallery'" :user="user"/>
</div> </div>
<MkError v-else-if="error" @retry="fetchUser()"/> <MkError v-else-if="error" @retry="fetchUser()"/>
@ -42,6 +43,7 @@ const XReactions = defineAsyncComponent(() => import('./reactions.vue'));
const XClips = defineAsyncComponent(() => import('./clips.vue')); const XClips = defineAsyncComponent(() => import('./clips.vue'));
const XLists = defineAsyncComponent(() => import('./lists.vue')); const XLists = defineAsyncComponent(() => import('./lists.vue'));
const XPages = defineAsyncComponent(() => import('./pages.vue')); const XPages = defineAsyncComponent(() => import('./pages.vue'));
const XFlashs = defineAsyncComponent(() => import('./flashs.vue'));
const XGallery = defineAsyncComponent(() => import('./gallery.vue')); const XGallery = defineAsyncComponent(() => import('./gallery.vue'));
const props = withDefaults(defineProps<{ const props = withDefaults(defineProps<{
@ -103,6 +105,10 @@ const headerTabs = $computed(() => user ? [{
key: 'pages', key: 'pages',
title: i18n.ts.pages, title: i18n.ts.pages,
icon: 'ti ti-news', icon: 'ti ti-news',
}, {
key: 'flashs',
title: 'Play',
icon: 'ti ti-player-play',
}, { }, {
key: 'gallery', key: 'gallery',
title: i18n.ts.gallery, title: i18n.ts.gallery,

View File

@ -621,6 +621,7 @@ export type Endpoints = {
'users/lists/update': { req: { listId: UserList['id']; name: string; }; res: UserList; }; '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/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/pages': { req: TODO; res: TODO; };
'users/flashs': { req: TODO; res: TODO; };
'users/recommendation': { req: TODO; res: TODO; }; 'users/recommendation': { req: TODO; res: TODO; };
'users/relation': { req: TODO; res: TODO; }; 'users/relation': { req: TODO; res: TODO; };
'users/report-abuse': { req: TODO; res: TODO; }; 'users/report-abuse': { req: TODO; res: TODO; };