1
0
mirror of https://github.com/MisskeyIO/misskey synced 2024-11-27 14:28:49 +09:00

Enhance(Page): ページを非公開にできるように

This commit is contained in:
mattyatea 2024-11-21 00:45:48 +09:00
parent 1bad66913c
commit ff189ea9a7
11 changed files with 45 additions and 15 deletions

4
locales/index.d.ts vendored
View File

@ -5318,6 +5318,10 @@ export interface Locale extends ILocale {
*
*/
"consentSelected": string;
/**
*
*/
"isPublic": string;
"_bubbleGame": {
/**
*

View File

@ -1323,6 +1323,7 @@ pleaseConsentToTracking: "{host}は[プライバシーポリシー]({privacyPoli
consentEssential: "必須項目のみ許可"
consentAll: "全て許可"
consentSelected: "選択した項目のみ許可"
isPublic: "公開"
_bubbleGame:
howToPlay: "遊び方"

View File

@ -0,0 +1,21 @@
export class PageIsPublic1731806320819 {
name = 'PageIsPublic1731806320819'
async up(queryRunner) {
await queryRunner.query(`DROP INDEX "public"."IDX_90148bbc2bf0854428786bfc15"`);
await queryRunner.query(`ALTER TABLE "page" DROP COLUMN "visibility"`);
await queryRunner.query(`DROP TYPE "public"."page_visibility_enum"`);
await queryRunner.query(`ALTER TABLE "page" DROP COLUMN "visibleUserIds"`);
await queryRunner.query(`ALTER TABLE "page" ADD "isPublish" boolean NOT NULL DEFAULT true`);
await queryRunner.query(`CREATE INDEX "IDX_dce798cab7e5478ba4fc15e515" ON "page" ("isPublish") `);
}
async down(queryRunner) {
await queryRunner.query(`DROP INDEX "public"."IDX_dce798cab7e5478ba4fc15e515"`);
await queryRunner.query(`CREATE TYPE "public"."user_profile_followersVisibility_enum_old" AS ENUM('public', 'followers', 'private')`);
await queryRunner.query(`ALTER TABLE "page" ADD "visibleUserIds" character varying(32) array NOT NULL DEFAULT '{}'`);
await queryRunner.query(`CREATE TYPE "public"."page_visibility_enum" AS ENUM('public', 'followers', 'specified')`);
await queryRunner.query(`ALTER TABLE "page" ADD "visibility" "public"."page_visibility_enum" NOT NULL`);
await queryRunner.query(`CREATE INDEX "IDX_90148bbc2bf0854428786bfc15" ON "page" ("visibleUserIds") `);
}
}

View File

@ -99,6 +99,7 @@ export class PageEntityService {
hideTitleWhenPinned: page.hideTitleWhenPinned,
alignCenter: page.alignCenter,
font: page.font,
isPublish: page.isPublish,
script: page.script,
eyeCatchingImageId: page.eyeCatchingImageId,
eyeCatchingImage: page.eyeCatchingImageId ? await this.driveFileEntityService.pack(page.eyeCatchingImageId, me) : null,

View File

@ -97,20 +97,11 @@ export class MiPage {
})
public script: string;
/**
* public ...
* followers ...
* specified ... visibleUserIds
*/
@Column('enum', { enum: ['public', 'followers', 'specified'] })
public visibility: 'public' | 'followers' | 'specified';
@Index()
@Column({
...id(),
array: true, default: '{}',
@Column('boolean', {
default: true,
})
public visibleUserIds: MiUser['id'][];
public isPublish: boolean;
@Column('integer', {
default: 0,

View File

@ -60,6 +60,7 @@ export const paramDef = {
variables: { type: 'array', items: {
type: 'object', additionalProperties: true,
} },
isPublish: { type: 'boolean' },
script: { type: 'string' },
eyeCatchingImageId: { type: 'string', format: 'misskey:id', nullable: true },
font: { type: 'string', enum: ['serif', 'sans-serif'], default: 'sans-serif' },
@ -114,7 +115,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
script: ps.script,
eyeCatchingImageId: eyeCatchingImage ? eyeCatchingImage.id : null,
userId: me.id,
visibility: 'public',
isPublish: ps.isPublish,
alignCenter: ps.alignCenter,
hideTitleWhenPinned: ps.hideTitleWhenPinned,
font: ps.font,

View File

@ -41,7 +41,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
) {
super(meta, paramDef, async (ps, me) => {
const query = this.pagesRepository.createQueryBuilder('page')
.where('page.visibility = \'public\'')
.where('page.isPublish = true')
.andWhere('page.likedCount > 0')
.orderBy('page.likedCount', 'DESC');

View File

@ -78,6 +78,10 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
throw new ApiError(meta.errors.noSuchPage);
}
if (!page.isPublish && (me == null || (page.userId !== me.id))) {
throw new ApiError(meta.errors.noSuchPage);
}
return await this.pageEntityService.pack(page, me);
});
}

View File

@ -65,6 +65,7 @@ export const paramDef = {
variables: { type: 'array', items: {
type: 'object', additionalProperties: true,
} },
isPublish: { type: 'boolean' },
script: { type: 'string' },
eyeCatchingImageId: { type: 'string', format: 'misskey:id', nullable: true },
font: { type: 'string', enum: ['serif', 'sans-serif'] },
@ -123,6 +124,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
content: ps.content,
variables: ps.variables,
script: ps.script,
isPublish: ps.isPublish,
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
alignCenter: ps.alignCenter === undefined ? page.alignCenter : ps.alignCenter,
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing

View File

@ -49,7 +49,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
super(meta, paramDef, async (ps, me) => {
const query = this.queryService.makePaginationQuery(this.pagesRepository.createQueryBuilder('page'), ps.sinceId, ps.untilId)
.andWhere('page.userId = :userId', { userId: ps.userId })
.andWhere('page.visibility = \'public\'');
.andWhere('page.isPublish = true');
const pages = await query
.limit(ps.limit)

View File

@ -31,6 +31,8 @@ SPDX-License-Identifier: AGPL-3.0-only
<MkSwitch v-model="alignCenter">{{ i18n.ts._pages.alignCenter }}</MkSwitch>
<MkSwitch v-model="isPublish">{{ i18n.ts.publish }}</MkSwitch>
<MkSelect v-model="font">
<template #label>{{ i18n.ts._pages.font }}</template>
<option value="serif">{{ i18n.ts._pages.fontSerif }}</option>
@ -98,6 +100,7 @@ const eyeCatchingImageId = ref<string | null>(null);
const font = ref('sans-serif');
const content = ref<Misskey.entities.Page['content']>([]);
const alignCenter = ref(false);
const isPublish = ref(false);
const hideTitleWhenPinned = ref(false);
provide('readonly', readonly.value);
@ -122,6 +125,7 @@ function getSaveOptions() {
script: '',
hideTitleWhenPinned: hideTitleWhenPinned.value,
alignCenter: alignCenter.value,
isPublish: isPublish.value,
content: content.value,
variables: [],
eyeCatchingImageId: eyeCatchingImageId.value,
@ -258,6 +262,7 @@ async function init() {
font.value = page.value.font;
hideTitleWhenPinned.value = page.value.hideTitleWhenPinned;
alignCenter.value = page.value.alignCenter;
isPublish.value = page.value.isPublish;
content.value = page.value.content;
eyeCatchingImageId.value = page.value.eyeCatchingImageId;
} else {