summaryrefslogtreecommitdiff
path: root/src/server/api/endpoints
diff options
context:
space:
mode:
authorsyuilo <syuilotan@yahoo.co.jp>2018-06-07 06:13:57 +0900
committersyuilo <syuilotan@yahoo.co.jp>2018-06-07 06:13:57 +0900
commitbe9f836b21c3d7dc1b315fa305caf17f04c139c4 (patch)
tree0cbf5b065ac2c0b756d8bdd0e616834e9ea451e1 /src/server/api/endpoints
parent2.28.0 (diff)
downloadsharkey-be9f836b21c3d7dc1b315fa305caf17f04c139c4.tar.gz
sharkey-be9f836b21c3d7dc1b315fa305caf17f04c139c4.tar.bz2
sharkey-be9f836b21c3d7dc1b315fa305caf17f04c139c4.zip
やった
Diffstat (limited to 'src/server/api/endpoints')
-rw-r--r--src/server/api/endpoints/notes/global-timeline.ts8
-rw-r--r--src/server/api/endpoints/notes/local-timeline.ts8
-rw-r--r--src/server/api/endpoints/notes/timeline.ts10
-rw-r--r--src/server/api/endpoints/notes/user-list-timeline.ts10
4 files changed, 36 insertions, 0 deletions
diff --git a/src/server/api/endpoints/notes/global-timeline.ts b/src/server/api/endpoints/notes/global-timeline.ts
index 7cf06c3af1..2d4f2b6368 100644
--- a/src/server/api/endpoints/notes/global-timeline.ts
+++ b/src/server/api/endpoints/notes/global-timeline.ts
@@ -35,6 +35,10 @@ module.exports = async (params, user) => {
throw 'only one of sinceId, untilId, sinceDate, untilDate can be specified';
}
+ // Get 'mediaOnly' parameter
+ const [mediaOnly, mediaOnlyErr] = $.bool.optional().get(params.mediaOnly);
+ if (mediaOnlyErr) throw 'invalid mediaOnly param';
+
// ミュートしているユーザーを取得
const mutedUserIds = user ? (await Mute.find({
muterId: user._id
@@ -64,6 +68,10 @@ module.exports = async (params, user) => {
};
}
+ if (mediaOnly) {
+ query.mediaIds = { $exists: true, $ne: [] };
+ }
+
if (sinceId) {
sort._id = 1;
query._id = {
diff --git a/src/server/api/endpoints/notes/local-timeline.ts b/src/server/api/endpoints/notes/local-timeline.ts
index 7d01de3d43..734cc9af0a 100644
--- a/src/server/api/endpoints/notes/local-timeline.ts
+++ b/src/server/api/endpoints/notes/local-timeline.ts
@@ -35,6 +35,10 @@ module.exports = async (params, user) => {
throw 'only one of sinceId, untilId, sinceDate, untilDate can be specified';
}
+ // Get 'mediaOnly' parameter
+ const [mediaOnly, mediaOnlyErr] = $.bool.optional().get(params.mediaOnly);
+ if (mediaOnlyErr) throw 'invalid mediaOnly param';
+
// ミュートしているユーザーを取得
const mutedUserIds = user ? (await Mute.find({
muterId: user._id
@@ -67,6 +71,10 @@ module.exports = async (params, user) => {
};
}
+ if (mediaOnly) {
+ query.mediaIds = { $exists: true, $ne: [] };
+ }
+
if (sinceId) {
sort._id = 1;
query._id = {
diff --git a/src/server/api/endpoints/notes/timeline.ts b/src/server/api/endpoints/notes/timeline.ts
index 9f32555649..f1d741d5ee 100644
--- a/src/server/api/endpoints/notes/timeline.ts
+++ b/src/server/api/endpoints/notes/timeline.ts
@@ -44,6 +44,10 @@ module.exports = async (params, user, app) => {
const [includeRenotedMyNotes = true, includeRenotedMyNotesErr] = $.bool.optional().get(params.includeRenotedMyNotes);
if (includeRenotedMyNotesErr) throw 'invalid includeRenotedMyNotes param';
+ // 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
@@ -137,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 = {
diff --git a/src/server/api/endpoints/notes/user-list-timeline.ts b/src/server/api/endpoints/notes/user-list-timeline.ts
index 9f8397d679..a74a5141f9 100644
--- a/src/server/api/endpoints/notes/user-list-timeline.ts
+++ b/src/server/api/endpoints/notes/user-list-timeline.ts
@@ -44,6 +44,10 @@ module.exports = async (params, user, app) => {
const [includeRenotedMyNotes = true, includeRenotedMyNotesErr] = $.bool.optional().get(params.includeRenotedMyNotes);
if (includeRenotedMyNotesErr) throw 'invalid includeRenotedMyNotes param';
+ // Get 'mediaOnly' parameter
+ const [mediaOnly, mediaOnlyErr] = $.bool.optional().get(params.mediaOnly);
+ if (mediaOnlyErr) throw 'invalid mediaOnly param';
+
// Get 'listId' parameter
const [listId, listIdErr] = $.type(ID).get(params.listId);
if (listIdErr) throw 'invalid listId param';
@@ -146,6 +150,12 @@ module.exports = async (params, user, app) => {
});
}
+ if (mediaOnly) {
+ query.$and.push({
+ mediaIds: { $exists: true, $ne: [] }
+ });
+ }
+
if (sinceId) {
sort._id = 1;
query._id = {