fix: サーバー設定によりコンテンツの閲覧が制限されている場合のメッセージを区別するように (#16527)
This commit is contained in:
parent
bcb2073715
commit
e504560477
|
@ -29,10 +29,16 @@ export const meta = {
|
||||||
id: '24fcbfc6-2e37-42b6-8388-c29b3861a08d',
|
id: '24fcbfc6-2e37-42b6-8388-c29b3861a08d',
|
||||||
},
|
},
|
||||||
|
|
||||||
signinRequired: {
|
contentRestrictedByUser: {
|
||||||
message: 'Signin required.',
|
message: 'Content restricted by user. Please sign in to view.',
|
||||||
code: 'SIGNIN_REQUIRED',
|
code: 'CONTENT_RESTRICTED_BY_USER',
|
||||||
id: '8e75455b-738c-471d-9f80-62693f33372e',
|
id: 'fbcc002d-37d9-4944-a6b0-d9e29f2d33ab',
|
||||||
|
},
|
||||||
|
|
||||||
|
contentRestrictedByServer: {
|
||||||
|
message: 'Content restricted by server settings. Please sign in to view.',
|
||||||
|
code: 'CONTENT_RESTRICTED_BY_SERVER',
|
||||||
|
id: '145f88d2-b03d-4087-8143-a78928883c4b',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
} as const;
|
} as const;
|
||||||
|
@ -61,15 +67,15 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
||||||
});
|
});
|
||||||
|
|
||||||
if (note.user!.requireSigninToViewContents && me == null) {
|
if (note.user!.requireSigninToViewContents && me == null) {
|
||||||
throw new ApiError(meta.errors.signinRequired);
|
throw new ApiError(meta.errors.contentRestrictedByUser);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.serverSettings.ugcVisibilityForVisitor === 'none' && me == null) {
|
if (this.serverSettings.ugcVisibilityForVisitor === 'none' && me == null) {
|
||||||
throw new ApiError(meta.errors.signinRequired);
|
throw new ApiError(meta.errors.contentRestrictedByServer);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.serverSettings.ugcVisibilityForVisitor === 'local' && note.userHost != null && me == null) {
|
if (this.serverSettings.ugcVisibilityForVisitor === 'local' && note.userHost != null && me == null) {
|
||||||
throw new ApiError(meta.errors.signinRequired);
|
throw new ApiError(meta.errors.contentRestrictedByServer);
|
||||||
}
|
}
|
||||||
|
|
||||||
return await this.noteEntityService.pack(note, me, {
|
return await this.noteEntityService.pack(note, me, {
|
||||||
|
|
|
@ -136,10 +136,10 @@ function fetchNote() {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}).catch(err => {
|
}).catch(err => {
|
||||||
if (err.id === '8e75455b-738c-471d-9f80-62693f33372e') {
|
if (['fbcc002d-37d9-4944-a6b0-d9e29f2d33ab', '145f88d2-b03d-4087-8143-a78928883c4b'].includes(err.id)) {
|
||||||
pleaseLogin({
|
pleaseLogin({
|
||||||
path: '/',
|
path: '/',
|
||||||
message: i18n.ts.thisContentsAreMarkedAsSigninRequiredByAuthor,
|
message: err.id === 'fbcc002d-37d9-4944-a6b0-d9e29f2d33ab' ? i18n.ts.thisContentsAreMarkedAsSigninRequiredByAuthor : i18n.ts.signinOrContinueOnRemote,
|
||||||
openOnRemote: {
|
openOnRemote: {
|
||||||
type: 'lookup',
|
type: 'lookup',
|
||||||
url: `https://${host}/notes/${props.noteId}`,
|
url: `https://${host}/notes/${props.noteId}`,
|
||||||
|
|
Loading…
Reference in New Issue