diff options
| author | syuilo <syuilotan@yahoo.co.jp> | 2017-03-03 06:37:09 +0900 |
|---|---|---|
| committer | syuilo <syuilotan@yahoo.co.jp> | 2017-03-03 06:37:09 +0900 |
| commit | d3c4cd1c433d2077628d6aba0fb3d053c94ddaa1 (patch) | |
| tree | 54fb1053be527870dad54d607aa2e5886b7a5a69 /src/api/endpoints/posts/mentions.js | |
| parent | wip (diff) | |
| download | misskey-d3c4cd1c433d2077628d6aba0fb3d053c94ddaa1.tar.gz misskey-d3c4cd1c433d2077628d6aba0fb3d053c94ddaa1.tar.bz2 misskey-d3c4cd1c433d2077628d6aba0fb3d053c94ddaa1.zip | |
wip
Diffstat (limited to 'src/api/endpoints/posts/mentions.js')
| -rw-r--r-- | src/api/endpoints/posts/mentions.js | 84 |
1 files changed, 0 insertions, 84 deletions
diff --git a/src/api/endpoints/posts/mentions.js b/src/api/endpoints/posts/mentions.js deleted file mode 100644 index 5a3d72aab8..0000000000 --- a/src/api/endpoints/posts/mentions.js +++ /dev/null @@ -1,84 +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 mentions of myself - * - * @param {any} params - * @param {any} user - * @return {Promise<any>} - */ -module.exports = (params, user) => - new Promise(async (res, rej) => -{ - // Get 'following' parameter - const following = params.following; - - // 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'); - } - - // Construct query - const query = { - mentions: user._id - }; - - const sort = { - _id: -1 - }; - - if (following) { - const followingIds = await getFriends(user._id); - - query.user_id = { - $in: followingIds - }; - } - - if (since) { - sort._id = 1; - query._id = { - $gt: new mongo.ObjectID(since) - }; - } else if (max) { - query._id = { - $lt: new mongo.ObjectID(max) - }; - } - - // Issue query - const mentions = await Post - .find(query, { - limit: limit, - sort: sort - }); - - // Serialize - res(await Promise.all(mentions.map(async mention => - await serialize(mention, user) - ))); -}); |