enhance(Page): ページを非公開にできるように (MisskeyIO#821)
This commit is contained in:
parent
6a416468e3
commit
1a81d3fa46
14 changed files with 75 additions and 16 deletions
12
locales/index.d.ts
vendored
12
locales/index.d.ts
vendored
|
@ -9497,6 +9497,18 @@ export interface Locale extends ILocale {
|
||||||
* 特殊
|
* 特殊
|
||||||
*/
|
*/
|
||||||
"specialBlocks": string;
|
"specialBlocks": string;
|
||||||
|
/**
|
||||||
|
* 公開範囲
|
||||||
|
*/
|
||||||
|
"visibility": string;
|
||||||
|
/**
|
||||||
|
* 公開
|
||||||
|
*/
|
||||||
|
"public": string;
|
||||||
|
/**
|
||||||
|
* 非公開
|
||||||
|
*/
|
||||||
|
"private": string;
|
||||||
"blocks": {
|
"blocks": {
|
||||||
/**
|
/**
|
||||||
* テキスト
|
* テキスト
|
||||||
|
|
|
@ -2495,6 +2495,9 @@ _pages:
|
||||||
contentBlocks: "コンテンツ"
|
contentBlocks: "コンテンツ"
|
||||||
inputBlocks: "入力"
|
inputBlocks: "入力"
|
||||||
specialBlocks: "特殊"
|
specialBlocks: "特殊"
|
||||||
|
visibility: "公開範囲"
|
||||||
|
public: "公開"
|
||||||
|
private: "非公開"
|
||||||
blocks:
|
blocks:
|
||||||
text: "テキスト"
|
text: "テキスト"
|
||||||
textarea: "テキストエリア"
|
textarea: "テキストエリア"
|
||||||
|
|
19
packages/backend/migration/1733563840208-page-visibility.js
Normal file
19
packages/backend/migration/1733563840208-page-visibility.js
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
export class PageVisibility1733563840208 {
|
||||||
|
name = 'PageVisibility1733563840208'
|
||||||
|
|
||||||
|
async up(queryRunner) {
|
||||||
|
await queryRunner.query(`ALTER TYPE "public"."page_visibility_enum" RENAME TO "page_visibility_enum_old"`);
|
||||||
|
await queryRunner.query(`CREATE TYPE "public"."page_visibility_enum" AS ENUM('public', 'private')`);
|
||||||
|
await queryRunner.query(`ALTER TABLE "page" ALTER COLUMN "visibility" TYPE "public"."page_visibility_enum" USING "visibility"::"text"::"public"."page_visibility_enum"`);
|
||||||
|
await queryRunner.query(`DROP TYPE "public"."page_visibility_enum_old"`);
|
||||||
|
await queryRunner.query(`ALTER TABLE "page" ALTER COLUMN "visibility" SET DEFAULT 'public'`);
|
||||||
|
}
|
||||||
|
|
||||||
|
async down(queryRunner) {
|
||||||
|
await queryRunner.query(`CREATE TYPE "public"."page_visibility_enum_old" AS ENUM('followers', 'public', 'specified')`);
|
||||||
|
await queryRunner.query(`ALTER TABLE "page" ALTER COLUMN "visibility" TYPE "public"."page_visibility_enum_old" USING "visibility"::"text"::"public"."page_visibility_enum_old"`);
|
||||||
|
await queryRunner.query(`DROP TYPE "public"."page_visibility_enum"`);
|
||||||
|
await queryRunner.query(`ALTER TYPE "public"."page_visibility_enum_old" RENAME TO "page_visibility_enum"`);
|
||||||
|
await queryRunner.query(`ALTER TABLE "page" ALTER COLUMN "visibility" DROP DEFAULT`);
|
||||||
|
}
|
||||||
|
}
|
|
@ -105,6 +105,7 @@ export class PageEntityService {
|
||||||
attachedFiles: this.driveFileEntityService.packMany((await Promise.all(attachedFiles)).filter(isNotNull), me),
|
attachedFiles: this.driveFileEntityService.packMany((await Promise.all(attachedFiles)).filter(isNotNull), me),
|
||||||
likedCount: page.likedCount,
|
likedCount: page.likedCount,
|
||||||
isLiked: meId ? await this.pageLikesRepository.exists({ where: { pageId: page.id, userId: meId } }) : undefined,
|
isLiked: meId ? await this.pageLikesRepository.exists({ where: { pageId: page.id, userId: meId } }) : undefined,
|
||||||
|
visibility: page.visibility,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -99,18 +99,13 @@ export class MiPage {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* public ... 公開
|
* public ... 公開
|
||||||
* followers ... フォロワーのみ
|
* private ... 非公開
|
||||||
* specified ... visibleUserIds で指定したユーザーのみ
|
|
||||||
*/
|
*/
|
||||||
@Column('enum', { enum: ['public', 'followers', 'specified'] })
|
@Column('enum', {
|
||||||
public visibility: 'public' | 'followers' | 'specified';
|
enum: ['public', 'private'],
|
||||||
|
default: 'public',
|
||||||
@Index()
|
|
||||||
@Column({
|
|
||||||
...id(),
|
|
||||||
array: true, default: '{}',
|
|
||||||
})
|
})
|
||||||
public visibleUserIds: MiUser['id'][];
|
public visibility: 'public' | 'private';
|
||||||
|
|
||||||
@Column('integer', {
|
@Column('integer', {
|
||||||
default: 0,
|
default: 0,
|
||||||
|
|
|
@ -205,6 +205,11 @@ export const packedPageSchema = {
|
||||||
type: 'boolean',
|
type: 'boolean',
|
||||||
optional: true, nullable: false,
|
optional: true, nullable: false,
|
||||||
},
|
},
|
||||||
|
visibility: {
|
||||||
|
type: 'string',
|
||||||
|
optional: false, nullable: false,
|
||||||
|
enum: ['public', 'private'],
|
||||||
|
},
|
||||||
},
|
},
|
||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
|
|
|
@ -65,6 +65,7 @@ export const paramDef = {
|
||||||
font: { type: 'string', enum: ['serif', 'sans-serif'], default: 'sans-serif' },
|
font: { type: 'string', enum: ['serif', 'sans-serif'], default: 'sans-serif' },
|
||||||
alignCenter: { type: 'boolean', default: false },
|
alignCenter: { type: 'boolean', default: false },
|
||||||
hideTitleWhenPinned: { type: 'boolean', default: false },
|
hideTitleWhenPinned: { type: 'boolean', default: false },
|
||||||
|
visibility: { type: 'string', enum: ['public', 'private'] },
|
||||||
},
|
},
|
||||||
required: ['title', 'name', 'content', 'variables', 'script'],
|
required: ['title', 'name', 'content', 'variables', 'script'],
|
||||||
} as const;
|
} as const;
|
||||||
|
@ -114,7 +115,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
||||||
script: ps.script,
|
script: ps.script,
|
||||||
eyeCatchingImageId: eyeCatchingImage ? eyeCatchingImage.id : null,
|
eyeCatchingImageId: eyeCatchingImage ? eyeCatchingImage.id : null,
|
||||||
userId: me.id,
|
userId: me.id,
|
||||||
visibility: 'public',
|
visibility: ps.visibility,
|
||||||
alignCenter: ps.alignCenter,
|
alignCenter: ps.alignCenter,
|
||||||
hideTitleWhenPinned: ps.hideTitleWhenPinned,
|
hideTitleWhenPinned: ps.hideTitleWhenPinned,
|
||||||
font: ps.font,
|
font: ps.font,
|
||||||
|
|
|
@ -78,6 +78,10 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
||||||
throw new ApiError(meta.errors.noSuchPage);
|
throw new ApiError(meta.errors.noSuchPage);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (page.visibility === 'private' && (me == null || (page.userId !== me.id))) {
|
||||||
|
throw new ApiError(meta.errors.noSuchPage);
|
||||||
|
}
|
||||||
|
|
||||||
return await this.pageEntityService.pack(page, me);
|
return await this.pageEntityService.pack(page, me);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -70,6 +70,7 @@ export const paramDef = {
|
||||||
font: { type: 'string', enum: ['serif', 'sans-serif'] },
|
font: { type: 'string', enum: ['serif', 'sans-serif'] },
|
||||||
alignCenter: { type: 'boolean' },
|
alignCenter: { type: 'boolean' },
|
||||||
hideTitleWhenPinned: { type: 'boolean' },
|
hideTitleWhenPinned: { type: 'boolean' },
|
||||||
|
visibility: { type: 'string', enum: ['public', 'private'] },
|
||||||
},
|
},
|
||||||
required: ['pageId', 'title', 'name', 'content', 'variables', 'script'],
|
required: ['pageId', 'title', 'name', 'content', 'variables', 'script'],
|
||||||
} as const;
|
} as const;
|
||||||
|
@ -129,6 +130,8 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
||||||
hideTitleWhenPinned: ps.hideTitleWhenPinned === undefined ? page.hideTitleWhenPinned : ps.hideTitleWhenPinned,
|
hideTitleWhenPinned: ps.hideTitleWhenPinned === undefined ? page.hideTitleWhenPinned : ps.hideTitleWhenPinned,
|
||||||
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
|
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
|
||||||
font: ps.font === undefined ? page.font : ps.font,
|
font: ps.font === undefined ? page.font : ps.font,
|
||||||
|
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
|
||||||
|
visibility: ps.visibility === undefined ? page.visibility : ps.visibility,
|
||||||
eyeCatchingImageId: ps.eyeCatchingImageId === null
|
eyeCatchingImageId: ps.eyeCatchingImageId === null
|
||||||
? null
|
? null
|
||||||
: ps.eyeCatchingImageId === undefined
|
: ps.eyeCatchingImageId === undefined
|
||||||
|
|
|
@ -196,6 +196,7 @@ export const page = async (user: UserToken, page: Partial<misskey.entities.Page>
|
||||||
eyeCatchingImageId: null,
|
eyeCatchingImageId: null,
|
||||||
font: 'sans-serif' as FIXME,
|
font: 'sans-serif' as FIXME,
|
||||||
hideTitleWhenPinned: false,
|
hideTitleWhenPinned: false,
|
||||||
|
visibility: 'public',
|
||||||
name: '1678594845072',
|
name: '1678594845072',
|
||||||
script: '',
|
script: '',
|
||||||
summary: null,
|
summary: null,
|
||||||
|
|
|
@ -16,7 +16,7 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||||
</div>
|
</div>
|
||||||
<article>
|
<article>
|
||||||
<header>
|
<header>
|
||||||
<h1 :title="page.title">{{ page.title }}</h1>
|
<h1 :title="page.title">{{ page.title || page.name }} <i v-if="page.visibility === 'private'" class="ti ti-lock"></i></h1>
|
||||||
</header>
|
</header>
|
||||||
<p v-if="page.summary" :title="page.summary">{{ page.summary.length > 85 ? page.summary.slice(0, 85) + '…' : page.summary }}</p>
|
<p v-if="page.summary" :title="page.summary">{{ page.summary.length > 85 ? page.summary.slice(0, 85) + '…' : page.summary }}</p>
|
||||||
<footer>
|
<footer>
|
||||||
|
|
|
@ -37,6 +37,12 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||||
<option value="sans-serif">{{ i18n.ts._pages.fontSansSerif }}</option>
|
<option value="sans-serif">{{ i18n.ts._pages.fontSansSerif }}</option>
|
||||||
</MkSelect>
|
</MkSelect>
|
||||||
|
|
||||||
|
<MkSelect v-model="visibility">
|
||||||
|
<template #label>{{ i18n.ts._pages.visibility }}</template>
|
||||||
|
<option value="public">{{ i18n.ts._pages.public }}</option>
|
||||||
|
<option value="private">{{ i18n.ts._pages.private }}</option>
|
||||||
|
</MkSelect>
|
||||||
|
|
||||||
<MkSwitch v-model="hideTitleWhenPinned">{{ i18n.ts._pages.hideTitleWhenPinned }}</MkSwitch>
|
<MkSwitch v-model="hideTitleWhenPinned">{{ i18n.ts._pages.hideTitleWhenPinned }}</MkSwitch>
|
||||||
|
|
||||||
<div class="eyeCatch">
|
<div class="eyeCatch">
|
||||||
|
@ -96,6 +102,7 @@ const name = ref(Date.now().toString());
|
||||||
const eyeCatchingImage = ref<Misskey.entities.DriveFile | null>(null);
|
const eyeCatchingImage = ref<Misskey.entities.DriveFile | null>(null);
|
||||||
const eyeCatchingImageId = ref<string | null>(null);
|
const eyeCatchingImageId = ref<string | null>(null);
|
||||||
const font = ref('sans-serif');
|
const font = ref('sans-serif');
|
||||||
|
const visibility = ref('public');
|
||||||
const content = ref<Misskey.entities.Page['content']>([]);
|
const content = ref<Misskey.entities.Page['content']>([]);
|
||||||
const alignCenter = ref(false);
|
const alignCenter = ref(false);
|
||||||
const hideTitleWhenPinned = ref(false);
|
const hideTitleWhenPinned = ref(false);
|
||||||
|
@ -119,6 +126,7 @@ function getSaveOptions() {
|
||||||
name: name.value.trim(),
|
name: name.value.trim(),
|
||||||
summary: summary.value,
|
summary: summary.value,
|
||||||
font: font.value,
|
font: font.value,
|
||||||
|
visibility: visibility.value,
|
||||||
script: '',
|
script: '',
|
||||||
hideTitleWhenPinned: hideTitleWhenPinned.value,
|
hideTitleWhenPinned: hideTitleWhenPinned.value,
|
||||||
alignCenter: alignCenter.value,
|
alignCenter: alignCenter.value,
|
||||||
|
@ -256,6 +264,7 @@ async function init() {
|
||||||
currentName.value = page.value.name;
|
currentName.value = page.value.name;
|
||||||
summary.value = page.value.summary;
|
summary.value = page.value.summary;
|
||||||
font.value = page.value.font;
|
font.value = page.value.font;
|
||||||
|
visibility.value = page.value.visibility;
|
||||||
hideTitleWhenPinned.value = page.value.hideTitleWhenPinned;
|
hideTitleWhenPinned.value = page.value.hideTitleWhenPinned;
|
||||||
alignCenter.value = page.value.alignCenter;
|
alignCenter.value = page.value.alignCenter;
|
||||||
content.value = page.value.content;
|
content.value = page.value.content;
|
||||||
|
@ -286,8 +295,8 @@ const headerTabs = computed(() => [{
|
||||||
|
|
||||||
definePageMetadata(() => ({
|
definePageMetadata(() => ({
|
||||||
title: props.initPageId ? i18n.ts._pages.editPage
|
title: props.initPageId ? i18n.ts._pages.editPage
|
||||||
: props.initPageName && props.initUser ? i18n.ts._pages.readPage
|
: props.initPageName && props.initUser ? i18n.ts._pages.readPage
|
||||||
: i18n.ts._pages.newPage,
|
: i18n.ts._pages.newPage,
|
||||||
icon: 'ti ti-pencil',
|
icon: 'ti ti-pencil',
|
||||||
}));
|
}));
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -41,7 +41,7 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div :class="$style.pageBannerTitle" class="_gaps_s">
|
<div :class="$style.pageBannerTitle" class="_gaps_s">
|
||||||
<h1>{{ page.title || page.name }}</h1>
|
<h1>{{ page.title || page.name }} <i v-if="page.visibility === 'private'" class="ti ti-lock"></i></h1>
|
||||||
<div :class="$style.pageBannerTitleSub">
|
<div :class="$style.pageBannerTitleSub">
|
||||||
<div v-if="page.user" :class="$style.pageBannerTitleUser">
|
<div v-if="page.user" :class="$style.pageBannerTitleUser">
|
||||||
<MkAvatar :user="page.user" :class="$style.avatar" indicator link preview/> <MkA :to="`/@${username}`"><MkUserName :user="page.user" :nowrap="false"/></MkA>
|
<MkAvatar :user="page.user" :class="$style.avatar" indicator link preview/> <MkA :to="`/@${username}`"><MkUserName :user="page.user" :nowrap="false"/></MkA>
|
||||||
|
@ -80,7 +80,7 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||||
</div>
|
</div>
|
||||||
<div :class="$style.pageLinks">
|
<div :class="$style.pageLinks">
|
||||||
<MkA v-if="!$i || $i.id !== page.userId" :to="`/@${username}/pages/${pageName}/view-source`" class="link">{{ i18n.ts._pages.viewSource }}</MkA>
|
<MkA v-if="!$i || $i.id !== page.userId" :to="`/@${username}/pages/${pageName}/view-source`" class="link">{{ i18n.ts._pages.viewSource }}</MkA>
|
||||||
<template v-if="$i && $i.id === page.userId">
|
<template v-if="($i && $i.id === page.userId) && page.visibility === 'public'">
|
||||||
<MkA :to="`/pages/edit/${page.id}`" class="link">{{ i18n.ts._pages.editThisPage }}</MkA>
|
<MkA :to="`/pages/edit/${page.id}`" class="link">{{ i18n.ts._pages.editThisPage }}</MkA>
|
||||||
<button v-if="$i.pinnedPageId === page.id" class="link _textButton" @click="pin(false)">{{ i18n.ts.unpin }}</button>
|
<button v-if="$i.pinnedPageId === page.id" class="link _textButton" @click="pin(false)">{{ i18n.ts.unpin }}</button>
|
||||||
<button v-else class="link _textButton" @click="pin(true)">{{ i18n.ts.pin }}</button>
|
<button v-else class="link _textButton" @click="pin(true)">{{ i18n.ts.pin }}</button>
|
||||||
|
|
|
@ -4619,6 +4619,8 @@ export type components = {
|
||||||
attachedFiles: components['schemas']['DriveFile'][];
|
attachedFiles: components['schemas']['DriveFile'][];
|
||||||
likedCount: number;
|
likedCount: number;
|
||||||
isLiked?: boolean;
|
isLiked?: boolean;
|
||||||
|
/** @enum {string} */
|
||||||
|
visibility: 'public' | 'private';
|
||||||
};
|
};
|
||||||
PageBlock: OneOf<[{
|
PageBlock: OneOf<[{
|
||||||
id: string;
|
id: string;
|
||||||
|
@ -25230,6 +25232,8 @@ export type operations = {
|
||||||
alignCenter?: boolean;
|
alignCenter?: boolean;
|
||||||
/** @default false */
|
/** @default false */
|
||||||
hideTitleWhenPinned?: boolean;
|
hideTitleWhenPinned?: boolean;
|
||||||
|
/** @enum {string} */
|
||||||
|
visibility?: 'public' | 'private';
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
@ -25564,6 +25568,8 @@ export type operations = {
|
||||||
font?: 'serif' | 'sans-serif';
|
font?: 'serif' | 'sans-serif';
|
||||||
alignCenter?: boolean;
|
alignCenter?: boolean;
|
||||||
hideTitleWhenPinned?: boolean;
|
hideTitleWhenPinned?: boolean;
|
||||||
|
/** @enum {string} */
|
||||||
|
visibility?: 'public' | 'private';
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue