From 2ed9e26a4fc6ece9b510538ac6c48a62eb8536d1 Mon Sep 17 00:00:00 2001 From: MeiMei <30769358+mei23@users.noreply.github.com> Date: Tue, 29 Jan 2019 17:34:43 +0900 Subject: リプライ/メンションされていれば非フォロワーへのフォロワー限定でも参照可能に (#4033) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 非メンション/リプライ投稿がmentionsにあるかどうかはvisibilityと関係ないので削除 * リプライ/メンションされていれば非フォロワーでも参照可能に --- src/server/api/endpoints/notes/mentions.ts | 13 +++++++++++-- src/server/api/endpoints/notes/replies.ts | 13 +++++++++++-- 2 files changed, 22 insertions(+), 4 deletions(-) (limited to 'src/server/api') diff --git a/src/server/api/endpoints/notes/mentions.ts b/src/server/api/endpoints/notes/mentions.ts index 8747590606..e37d475df7 100644 --- a/src/server/api/endpoints/notes/mentions.ts +++ b/src/server/api/endpoints/notes/mentions.ts @@ -53,14 +53,23 @@ export default define(meta, (ps, user) => new Promise(async (res, rej) => { const visibleQuery = [{ visibility: { $in: [ 'public', 'home' ] } }, { - // myself (for specified/private) + // myself (for followers/specified/private) userId: user._id }, { // to me (for specified) visibleUserIds: { $in: [ user._id ] } }, { visibility: 'followers', - userId: { $in: followings.map(f => f.id) } + $or: [{ + // フォロワーの投稿 + userId: { $in: followings.map(f => f.id) }, + }, { + // 自分の投稿へのリプライ + '_reply.userId': user._id, + }, { + // 自分へのメンションが含まれている + mentions: { $in: [ user._id ] } + }] }]; const query = { diff --git a/src/server/api/endpoints/notes/replies.ts b/src/server/api/endpoints/notes/replies.ts index 112156403d..199139c8e5 100644 --- a/src/server/api/endpoints/notes/replies.ts +++ b/src/server/api/endpoints/notes/replies.ts @@ -51,14 +51,23 @@ export default define(meta, (ps, user) => new Promise(async (res, rej) => { }] : [{ visibility: { $in: [ 'public', 'home' ] } }, { - // myself (for specified/private) + // myself (for followers/specified/private) userId: user._id }, { // to me (for specified) visibleUserIds: { $in: [ user._id ] } }, { visibility: 'followers', - userId: { $in: followings.map(f => f.id) } + $or: [{ + // フォロワーの投稿 + userId: { $in: followings.map(f => f.id) }, + }, { + // 自分の投稿へのリプライ + '_reply.userId': user._id, + }, { + // 自分へのメンションが含まれている + mentions: { $in: [ user._id ] } + }] }]; const q = { -- cgit v1.2.3-freya