From a3493c4f07240b1957cb4fe8c17eb79747846bc6 Mon Sep 17 00:00:00 2001 From: syuilo Date: Sat, 29 Dec 2018 02:55:46 +0900 Subject: [PATCH] =?UTF-8?q?Private=E3=81=AE=E5=85=AC=E9=96=8B=E7=AF=84?= =?UTF-8?q?=E5=9B=B2=E3=82=92=E5=BB=83=E6=AD=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/client/app/common/views/components/note-header.vue | 3 +-- src/client/app/common/views/components/renote.vue | 3 +-- .../app/common/views/components/visibility-chooser.vue | 8 +------- src/client/app/desktop/views/components/post-form.vue | 5 ++--- src/client/app/mobile/views/components/note-detail.vue | 3 +-- src/client/app/mobile/views/components/post-form.vue | 5 ++--- src/models/note.ts | 5 ++--- src/remote/activitypub/kernel/announce/note.ts | 2 +- src/server/api/endpoints/notes/create.ts | 5 +++++ src/services/note/create.ts | 9 ++------- 10 files changed, 18 insertions(+), 30 deletions(-) diff --git a/src/client/app/common/views/components/note-header.vue b/src/client/app/common/views/components/note-header.vue index 664cb308e..895313def 100644 --- a/src/client/app/common/views/components/note-header.vue +++ b/src/client/app/common/views/components/note-header.vue @@ -18,8 +18,7 @@ - - + diff --git a/src/client/app/common/views/components/renote.vue b/src/client/app/common/views/components/renote.vue index eae7bd122..4efac8b09 100644 --- a/src/client/app/common/views/components/renote.vue +++ b/src/client/app/common/views/components/renote.vue @@ -13,8 +13,7 @@ - - + diff --git a/src/client/app/common/views/components/visibility-chooser.vue b/src/client/app/common/views/components/visibility-chooser.vue index b7cc56103..66d617bef 100644 --- a/src/client/app/common/views/components/visibility-chooser.vue +++ b/src/client/app/common/views/components/visibility-chooser.vue @@ -23,18 +23,12 @@
-
+
{{ $t('specified') }} {{ $t('specified-desc') }}
-
-
-
- {{ $t('private') }} -
-
diff --git a/src/client/app/desktop/views/components/post-form.vue b/src/client/app/desktop/views/components/post-form.vue index 7e402f2b5..7ed8cf02c 100644 --- a/src/client/app/desktop/views/components/post-form.vue +++ b/src/client/app/desktop/views/components/post-form.vue @@ -50,8 +50,7 @@ - - +

{{ maxNoteTextLength - trimmedLength(text) }}

@@ -212,7 +211,7 @@ export default Vue.extend({ this.applyVisibility(this.$store.state.settings.rememberNoteVisibility ? (this.$store.state.device.visibility || this.$store.state.settings.defaultNoteVisibility) : this.$store.state.settings.defaultNoteVisibility); // 公開以外へのリプライ時は元の公開範囲を引き継ぐ - if (this.reply && ['home', 'followers', 'specified', 'private'].includes(this.reply.visibility)) { + if (this.reply && ['home', 'followers', 'specified'].includes(this.reply.visibility)) { this.visibility = this.reply.visibility; } diff --git a/src/client/app/mobile/views/components/note-detail.vue b/src/client/app/mobile/views/components/note-detail.vue index 61274a246..72f522bbc 100644 --- a/src/client/app/mobile/views/components/note-detail.vue +++ b/src/client/app/mobile/views/components/note-detail.vue @@ -54,8 +54,7 @@ - - +
diff --git a/src/client/app/mobile/views/components/post-form.vue b/src/client/app/mobile/views/components/post-form.vue index 282ecc387..599547858 100644 --- a/src/client/app/mobile/views/components/post-form.vue +++ b/src/client/app/mobile/views/components/post-form.vue @@ -41,8 +41,7 @@ - - + @@ -202,7 +201,7 @@ export default Vue.extend({ this.applyVisibility(this.$store.state.settings.rememberNoteVisibility ? (this.$store.state.device.visibility || this.$store.state.settings.defaultNoteVisibility) : this.$store.state.settings.defaultNoteVisibility); // 公開以外へのリプライ時は元の公開範囲を引き継ぐ - if (this.reply && ['home', 'followers', 'specified', 'private'].includes(this.reply.visibility)) { + if (this.reply && ['home', 'followers', 'specified'].includes(this.reply.visibility)) { this.visibility = this.reply.visibility; } diff --git a/src/models/note.ts b/src/models/note.ts index f14f4c133..f33497075 100644 --- a/src/models/note.ts +++ b/src/models/note.ts @@ -67,9 +67,8 @@ export type INote = { * home ... ホームタイムライン(ユーザーページのタイムライン含む)のみに流す * followers ... フォロワーのみ * specified ... visibleUserIds で指定したユーザーのみ - * private ... 自分のみ */ - visibility: 'public' | 'home' | 'followers' | 'specified' | 'private'; + visibility: 'public' | 'home' | 'followers' | 'specified'; visibleUserIds: mongo.ObjectID[]; @@ -106,7 +105,7 @@ export type INote = { export const hideNote = async (packedNote: any, meId: mongo.ObjectID) => { let hide = false; - // visibility が private かつ投稿者のIDが自分のIDではなかったら非表示 + // visibility が private かつ投稿者のIDが自分のIDではなかったら非表示(後方互換性のため) if (packedNote.visibility == 'private' && (meId == null || !meId.equals(packedNote.userId))) { hide = true; } diff --git a/src/remote/activitypub/kernel/announce/note.ts b/src/remote/activitypub/kernel/announce/note.ts index 19ea6306e..5eaeaf791 100644 --- a/src/remote/activitypub/kernel/announce/note.ts +++ b/src/remote/activitypub/kernel/announce/note.ts @@ -52,7 +52,7 @@ export default async function(resolver: Resolver, actor: IRemoteUser, activity: }); } -type visibility = 'public' | 'home' | 'followers' | 'specified' | 'private'; +type visibility = 'public' | 'home' | 'followers' | 'specified'; function getVisibility(to: string[], cc: string[], actor: IRemoteUser): visibility { const PUBLIC = 'https://www.w3.org/ns/activitystreams#Public'; diff --git a/src/server/api/endpoints/notes/create.ts b/src/server/api/endpoints/notes/create.ts index e8c37664f..ec84d6497 100644 --- a/src/server/api/endpoints/notes/create.ts +++ b/src/server/api/endpoints/notes/create.ts @@ -247,6 +247,11 @@ export default define(meta, (ps, user, app) => new Promise(async (res, rej) => { return rej('text, fileIds, renoteId or poll is required'); } + // 後方互換性のため + if (ps.visibility == 'private') { + ps.visibility = 'specified'; + } + // 投稿を作成 create(user, { createdAt: new Date(), diff --git a/src/services/note/create.ts b/src/services/note/create.ts index 20fa4a8d5..876097852 100644 --- a/src/services/note/create.ts +++ b/src/services/note/create.ts @@ -133,11 +133,6 @@ export default async (user: IUser, data: Option, silent = false) => new Promise< return rej('Renote target is not public or home'); } - // リプライ対象が自分以外の非公開の投稿なら禁止 - if (data.reply && data.reply.visibility == 'private' && !data.reply.userId.equals(user._id)) { - return rej('Reply target is private of others'); - } - // ローカルのみをRenoteしたらローカルのみにする if (data.renote && data.renote.localOnly) { data.localOnly = true; @@ -282,7 +277,7 @@ export default async (user: IUser, data: Option, silent = false) => new Promise< const noteActivity = await renderActivity(data, note); - if (isLocalUser(user) && note.visibility != 'private') { + if (isLocalUser(user)) { deliverNoteToMentionedRemoteUsers(mentionedUsers, user, noteActivity); } @@ -369,7 +364,7 @@ async function publish(user: IUser, note: INote, noteObj: any, reply: INote, ren deliver(user, noteActivity, renote._user.inbox); } - if (['private', 'followers', 'specified'].includes(note.visibility)) { + if (['followers', 'specified'].includes(note.visibility)) { const detailPackedNote = await pack(note, user, { detail: true });