From 9ac9ff1800d85b33abb83973bf29ed3f64b27c97 Mon Sep 17 00:00:00 2001 From: syuilo Date: Mon, 27 Feb 2017 16:51:08 +0900 Subject: 良い感じに MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/endpoints.ts | 1 + src/api/endpoints/posts.js | 24 ++++++++++++++++++++++++ 2 files changed, 25 insertions(+) (limited to 'src/api') diff --git a/src/api/endpoints.ts b/src/api/endpoints.ts index 37e3348b86..0ce51e9a51 100644 --- a/src/api/endpoints.ts +++ b/src/api/endpoints.ts @@ -81,6 +81,7 @@ export default [ { name: 'following/create', shouldBeSignin: true, limitDuration: hour, limitMax: 100, kind: 'following-write' }, { name: 'following/delete', shouldBeSignin: true, limitDuration: hour, limitMax: 100, kind: 'following-write' }, + { name: 'posts', shouldBeSignin: false }, { name: 'posts/show', shouldBeSignin: false }, { name: 'posts/replies', shouldBeSignin: false }, { name: 'posts/context', shouldBeSignin: false }, diff --git a/src/api/endpoints/posts.js b/src/api/endpoints/posts.js index 9bc25315a7..59cfb8a441 100644 --- a/src/api/endpoints/posts.js +++ b/src/api/endpoints/posts.js @@ -15,6 +15,22 @@ import serialize from '../serializers/post'; module.exports = (params) => new Promise(async (res, rej) => { + // Get 'include_replies' parameter + let includeReplies = params.include_replies; + if (includeReplies === true) { + includeReplies = true; + } else { + includeReplies = false; + } + + // Get 'include_reposts' parameter + let includeReposts = params.include_reposts; + if (includeReposts === true) { + includeReposts = true; + } else { + includeReposts = false; + } + // Get 'limit' parameter let limit = params.limit; if (limit !== undefined && limit !== null) { @@ -52,6 +68,14 @@ module.exports = (params) => }; } + if (!includeReplies) { + query.reply_to_id = null; + } + + if (!includeReposts) { + query.repost_id = null; + } + // Issue query const posts = await Post .find(query, { -- cgit v1.2.3-freya