[API] Better public timeline api (BREAKING)
This commit is contained in:
parent
898daf24d1
commit
6271c70d3c
|
@ -12,13 +12,21 @@ import serialize from '../serializers/post';
|
||||||
* @return {Promise<any>}
|
* @return {Promise<any>}
|
||||||
*/
|
*/
|
||||||
module.exports = (params) => new Promise(async (res, rej) => {
|
module.exports = (params) => new Promise(async (res, rej) => {
|
||||||
// Get 'include_replies' parameter
|
// Get 'reply' parameter
|
||||||
const [includeReplies = true, includeRepliesErr] = $(params.include_replies).optional.boolean().$;
|
const [reply, replyErr] = $(params.reply).optional.boolean().$;
|
||||||
if (includeRepliesErr) return rej('invalid include_replies param');
|
if (replyErr) return rej('invalid reply param');
|
||||||
|
|
||||||
// Get 'include_reposts' parameter
|
// Get 'repost' parameter
|
||||||
const [includeReposts = true, includeRepostsErr] = $(params.include_reposts).optional.boolean().$;
|
const [repost, repostErr] = $(params.repost).optional.boolean().$;
|
||||||
if (includeRepostsErr) return rej('invalid include_reposts param');
|
if (repostErr) return rej('invalid repost param');
|
||||||
|
|
||||||
|
// Get 'media' parameter
|
||||||
|
const [media, mediaErr] = $(params.media).optional.boolean().$;
|
||||||
|
if (mediaErr) return rej('invalid media param');
|
||||||
|
|
||||||
|
// Get 'poll' parameter
|
||||||
|
const [poll, pollErr] = $(params.poll).optional.boolean().$;
|
||||||
|
if (pollErr) return rej('invalid poll param');
|
||||||
|
|
||||||
// Get 'limit' parameter
|
// Get 'limit' parameter
|
||||||
const [limit = 10, limitErr] = $(params.limit).optional.number().range(1, 100).$;
|
const [limit = 10, limitErr] = $(params.limit).optional.number().range(1, 100).$;
|
||||||
|
@ -53,12 +61,20 @@ module.exports = (params) => new Promise(async (res, rej) => {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!includeReplies) {
|
if (reply != undefined) {
|
||||||
query.reply_to_id = null;
|
query.reply_to_id = reply ? { $exists: true, $ne: null } : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!includeReposts) {
|
if (repost != undefined) {
|
||||||
query.repost_id = null;
|
query.repost_id = repost ? { $exists: true, $ne: null } : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (media != undefined) {
|
||||||
|
query.media_ids = media ? { $exists: true, $ne: null } : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (poll != undefined) {
|
||||||
|
query.poll = poll ? { $exists: true, $ne: null } : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Issue query
|
// Issue query
|
||||||
|
|
Loading…
Reference in New Issue