summaryrefslogtreecommitdiff
path: root/src/server/api/endpoints/notes/timeline.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/server/api/endpoints/notes/timeline.ts')
-rw-r--r--src/server/api/endpoints/notes/timeline.ts43
1 files changed, 14 insertions, 29 deletions
diff --git a/src/server/api/endpoints/notes/timeline.ts b/src/server/api/endpoints/notes/timeline.ts
index 78786d4a16..f1d741d5ee 100644
--- a/src/server/api/endpoints/notes/timeline.ts
+++ b/src/server/api/endpoints/notes/timeline.ts
@@ -4,7 +4,6 @@
import $ from 'cafy'; import ID from '../../../../cafy-id';
import Note from '../../../../models/note';
import Mute from '../../../../models/mute';
-import ChannelWatching from '../../../../models/channel-watching';
import { getFriends } from '../../common/get-friends';
import { pack } from '../../../../models/note';
@@ -45,18 +44,15 @@ module.exports = async (params, user, app) => {
const [includeRenotedMyNotes = true, includeRenotedMyNotesErr] = $.bool.optional().get(params.includeRenotedMyNotes);
if (includeRenotedMyNotesErr) throw 'invalid includeRenotedMyNotes param';
- const [followings, watchingChannelIds, mutedUserIds] = await Promise.all([
+ // Get 'mediaOnly' parameter
+ const [mediaOnly, mediaOnlyErr] = $.bool.optional().get(params.mediaOnly);
+ if (mediaOnlyErr) throw 'invalid mediaOnly param';
+
+ const [followings, mutedUserIds] = await Promise.all([
// フォローを取得
// Fetch following
getFriends(user._id),
- // Watchしているチャンネルを取得
- ChannelWatching.find({
- userId: user._id,
- // 削除されたドキュメントは除く
- deletedAt: { $exists: false }
- }).then(watches => watches.map(w => w.channelId)),
-
// ミュートしているユーザーを取得
Mute.find({
muterId: user._id
@@ -93,26 +89,9 @@ module.exports = async (params, user, app) => {
const query = {
$and: [{
- $or: [{
- $and: [{
- // フォローしている人のタイムラインへの投稿
- $or: followQuery
- }, {
- // 「タイムラインへの」投稿に限定するためにチャンネルが指定されていないもののみに限る
- $or: [{
- channelId: {
- $exists: false
- }
- }, {
- channelId: null
- }]
- }]
- }, {
- // Watchしているチャンネルへの投稿
- channelId: {
- $in: watchingChannelIds
- }
- }],
+ // フォローしている人の投稿
+ $or: followQuery,
+
// mute
userId: {
$nin: mutedUserIds
@@ -162,6 +141,12 @@ module.exports = async (params, user, app) => {
});
}
+ if (mediaOnly) {
+ query.$and.push({
+ mediaIds: { $exists: true, $ne: [] }
+ });
+ }
+
if (sinceId) {
sort._id = 1;
query._id = {