enhance(Page): ページを非公開にできるように (MisskeyIO#821)

This commit is contained in:
まっちゃてぃー。 2024-12-11 03:23:16 +09:00 committed by GitHub
parent 6a416468e3
commit 1a81d3fa46
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
14 changed files with 75 additions and 16 deletions

View file

@ -65,6 +65,7 @@ export const paramDef = {
font: { type: 'string', enum: ['serif', 'sans-serif'], default: 'sans-serif' },
alignCenter: { type: 'boolean', default: false },
hideTitleWhenPinned: { type: 'boolean', default: false },
visibility: { type: 'string', enum: ['public', 'private'] },
},
required: ['title', 'name', 'content', 'variables', 'script'],
} as const;
@ -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',
visibility: ps.visibility,
alignCenter: ps.alignCenter,
hideTitleWhenPinned: ps.hideTitleWhenPinned,
font: ps.font,

View file

@ -78,6 +78,10 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
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);
});
}

View file

@ -70,6 +70,7 @@ export const paramDef = {
font: { type: 'string', enum: ['serif', 'sans-serif'] },
alignCenter: { type: 'boolean' },
hideTitleWhenPinned: { type: 'boolean' },
visibility: { type: 'string', enum: ['public', 'private'] },
},
required: ['pageId', 'title', 'name', 'content', 'variables', 'script'],
} as const;
@ -129,6 +130,8 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
hideTitleWhenPinned: ps.hideTitleWhenPinned === undefined ? page.hideTitleWhenPinned : ps.hideTitleWhenPinned,
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
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
? null
: ps.eyeCatchingImageId === undefined