summaryrefslogtreecommitdiff
path: root/src/api/endpoints/posts/timeline.js
diff options
context:
space:
mode:
authorsyuilo <syuilotan@yahoo.co.jp>2017-03-03 06:48:26 +0900
committersyuilo <syuilotan@yahoo.co.jp>2017-03-03 06:48:26 +0900
commit6e181ee0f1ca2ecd0fdf3a78654607ef112f2a6a (patch)
treed9319e37433f57c70cdf9e66b57b525fd7bfc881 /src/api/endpoints/posts/timeline.js
parentwip (diff)
downloadmisskey-6e181ee0f1ca2ecd0fdf3a78654607ef112f2a6a.tar.gz
misskey-6e181ee0f1ca2ecd0fdf3a78654607ef112f2a6a.tar.bz2
misskey-6e181ee0f1ca2ecd0fdf3a78654607ef112f2a6a.zip
wip
Diffstat (limited to 'src/api/endpoints/posts/timeline.js')
-rw-r--r--src/api/endpoints/posts/timeline.js77
1 files changed, 0 insertions, 77 deletions
diff --git a/src/api/endpoints/posts/timeline.js b/src/api/endpoints/posts/timeline.js
deleted file mode 100644
index 48f7c26940..0000000000
--- a/src/api/endpoints/posts/timeline.js
+++ /dev/null
@@ -1,77 +0,0 @@
-'use strict';
-
-/**
- * Module dependencies
- */
-import * as mongo from 'mongodb';
-import Post from '../../models/post';
-import getFriends from '../../common/get-friends';
-import serialize from '../../serializers/post';
-
-/**
- * Get timeline of myself
- *
- * @param {any} params
- * @param {any} user
- * @param {any} app
- * @return {Promise<any>}
- */
-module.exports = (params, user, app) =>
- new Promise(async (res, rej) =>
-{
- // Get 'limit' parameter
- let limit = params.limit;
- if (limit !== undefined && limit !== null) {
- limit = parseInt(limit, 10);
-
- // From 1 to 100
- if (!(1 <= limit && limit <= 100)) {
- return rej('invalid limit range');
- }
- } else {
- limit = 10;
- }
-
- const since = params.since_id || null;
- const max = params.max_id || null;
-
- // Check if both of since_id and max_id is specified
- if (since !== null && max !== null) {
- return rej('cannot set since_id and max_id');
- }
-
- // ID list of the user itself and other users who the user follows
- const followingIds = await getFriends(user._id);
-
- // Construct query
- const sort = {
- _id: -1
- };
- const query = {
- user_id: {
- $in: followingIds
- }
- };
- if (since !== null) {
- sort._id = 1;
- query._id = {
- $gt: new mongo.ObjectID(since)
- };
- } else if (max !== null) {
- query._id = {
- $lt: new mongo.ObjectID(max)
- };
- }
-
- // Issue query
- const timeline = await Post
- .find(query, {
- limit: limit,
- sort: sort
- });
-
- // Serialize
- res(await Promise.all(timeline.map(async post =>
- await serialize(post, user)
- )));
-});