diff options
| author | MeiMei <30769358+mei23@users.noreply.github.com> | 2019-01-25 00:06:20 +0900 |
|---|---|---|
| committer | syuilo <Syuilotan@yahoo.co.jp> | 2019-01-25 00:06:20 +0900 |
| commit | 5eca0a31f78493f2cff0fd5f097ee9d007991a87 (patch) | |
| tree | 01cc481c16418086b276d1879a85902e4dc34d23 /src/server/api/endpoints/notes/replies.ts | |
| parent | Update CONTRIBUTING.md (diff) | |
| download | sharkey-5eca0a31f78493f2cff0fd5f097ee9d007991a87.tar.gz sharkey-5eca0a31f78493f2cff0fd5f097ee9d007991a87.tar.bz2 sharkey-5eca0a31f78493f2cff0fd5f097ee9d007991a87.zip | |
Filter hidden replies / mentions (#3981)
* Fix: 非公開投稿が返信一覧に出てくる
* Fix: 非公開投稿がメンション一覧に出てくる
* 非公開投稿は通知/メンション通知しない
* repliesにフォロワー限定がかからなかったのを修正
* Fix: ホームにフォロワー限定投稿が表示されない
* 認証必須エンドポイントで user == null にはならない
* mentionsにフォロワー限定がかからなかったのを修正
Diffstat (limited to 'src/server/api/endpoints/notes/replies.ts')
| -rw-r--r-- | src/server/api/endpoints/notes/replies.ts | 33 |
1 files changed, 28 insertions, 5 deletions
diff --git a/src/server/api/endpoints/notes/replies.ts b/src/server/api/endpoints/notes/replies.ts index 8386d60684..112156403d 100644 --- a/src/server/api/endpoints/notes/replies.ts +++ b/src/server/api/endpoints/notes/replies.ts @@ -2,6 +2,7 @@ import $ from 'cafy'; import ID, { transform } from '../../../../misc/cafy-id'; import Note, { packMany } from '../../../../models/note'; import define from '../../define'; import Mute from '../../../../models/mute'; +import { getFriends } from '../../common/get-friends'; export const meta = { desc: { @@ -34,13 +35,35 @@ export const meta = { }; export default define(meta, (ps, user) => new Promise(async (res, rej) => { - // ミュートしているユーザーを取得 - const mutedUserIds = user ? (await Mute.find({ - muterId: user._id - })).map(m => m.muteeId) : null; + const [followings, mutedUserIds] = await Promise.all([ + // フォローを取得 + // Fetch following + user ? getFriends(user._id) : [], + + // ミュートしているユーザーを取得 + user ? (await Mute.find({ + muterId: user._id + })).map(m => m.muteeId) : null + ]); + + const visibleQuery = user == null ? [{ + visibility: { $in: [ 'public', 'home' ] } + }] : [{ + visibility: { $in: [ 'public', 'home' ] } + }, { + // myself (for specified/private) + userId: user._id + }, { + // to me (for specified) + visibleUserIds: { $in: [ user._id ] } + }, { + visibility: 'followers', + userId: { $in: followings.map(f => f.id) } + }]; const q = { - replyId: ps.noteId + replyId: ps.noteId, + $or: visibleQuery } as any; if (mutedUserIds && mutedUserIds.length > 0) { |