mirror of
https://git.joinsharkey.org/Sharkey/Sharkey.git
synced 2024-11-10 07:23:09 +02:00
api - endpoint:timeline: unneed promise wrapping
This commit is contained in:
parent
7553c6dd38
commit
7b1fc2c5d6
1 changed files with 8 additions and 7 deletions
|
@ -16,22 +16,22 @@ import serialize from '../../serializers/post';
|
|||
* @param {any} app
|
||||
* @return {Promise<any>}
|
||||
*/
|
||||
module.exports = (params, user, app) => new Promise(async (res, rej) => {
|
||||
module.exports = async (params, user, app) => {
|
||||
// Get 'limit' parameter
|
||||
const [limit = 10, limitErr] = $(params.limit).optional.number().range(1, 100).$;
|
||||
if (limitErr) return rej('invalid limit param');
|
||||
if (limitErr) throw 'invalid limit param';
|
||||
|
||||
// Get 'since_id' parameter
|
||||
const [sinceId, sinceIdErr] = $(params.since_id).optional.id().$;
|
||||
if (sinceIdErr) return rej('invalid since_id param');
|
||||
if (sinceIdErr) throw 'invalid since_id param';
|
||||
|
||||
// Get 'max_id' parameter
|
||||
const [maxId, maxIdErr] = $(params.max_id).optional.id().$;
|
||||
if (maxIdErr) return rej('invalid max_id param');
|
||||
if (maxIdErr) throw 'invalid max_id param';
|
||||
|
||||
// Check if both of since_id and max_id is specified
|
||||
if (sinceId && maxId) {
|
||||
return rej('cannot set since_id and max_id');
|
||||
throw 'cannot set since_id and max_id';
|
||||
}
|
||||
|
||||
const { followingIds, watchChannelIds } = await rap({
|
||||
|
@ -92,5 +92,6 @@ module.exports = (params, user, app) => new Promise(async (res, rej) => {
|
|||
});
|
||||
|
||||
// Serialize
|
||||
res(await Promise.all(timeline.map(post => serialize(post, user))));
|
||||
});
|
||||
const _timeline = await Promise.all(timeline.map(post => serialize(post, user)))
|
||||
return _timeline
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue