wip
This commit is contained in:
@ -13,15 +13,15 @@ module.exports = (params: any, me: ILocalUser) => new Promise(async (res, rej) =
|
||||
if (userIdErr) return rej('invalid userId param');
|
||||
|
||||
// Get 'iknow' parameter
|
||||
const [iknow = false, iknowErr] = $.bool.optional().get(params.iknow);
|
||||
const [iknow = false, iknowErr] = $.bool.optional.get(params.iknow);
|
||||
if (iknowErr) return rej('invalid iknow param');
|
||||
|
||||
// Get 'limit' parameter
|
||||
const [limit = 10, limitErr] = $.num.optional().range(1, 100).get(params.limit);
|
||||
const [limit = 10, limitErr] = $.num.optional.range(1, 100).get(params.limit);
|
||||
if (limitErr) return rej('invalid limit param');
|
||||
|
||||
// Get 'cursor' parameter
|
||||
const [cursor = null, cursorErr] = $.type(ID).optional().get(params.cursor);
|
||||
const [cursor = null, cursorErr] = $.type(ID).optional.get(params.cursor);
|
||||
if (cursorErr) return rej('invalid cursor param');
|
||||
|
||||
// Lookup user
|
||||
|
@ -13,15 +13,15 @@ module.exports = (params: any, me: ILocalUser) => new Promise(async (res, rej) =
|
||||
if (userIdErr) return rej('invalid userId param');
|
||||
|
||||
// Get 'iknow' parameter
|
||||
const [iknow = false, iknowErr] = $.bool.optional().get(params.iknow);
|
||||
const [iknow = false, iknowErr] = $.bool.optional.get(params.iknow);
|
||||
if (iknowErr) return rej('invalid iknow param');
|
||||
|
||||
// Get 'limit' parameter
|
||||
const [limit = 10, limitErr] = $.num.optional().range(1, 100).get(params.limit);
|
||||
const [limit = 10, limitErr] = $.num.optional.range(1, 100).get(params.limit);
|
||||
if (limitErr) return rej('invalid limit param');
|
||||
|
||||
// Get 'cursor' parameter
|
||||
const [cursor = null, cursorErr] = $.type(ID).optional().get(params.cursor);
|
||||
const [cursor = null, cursorErr] = $.type(ID).optional.get(params.cursor);
|
||||
if (cursorErr) return rej('invalid cursor param');
|
||||
|
||||
// Lookup user
|
||||
|
@ -8,7 +8,7 @@ module.exports = (params: any, me: ILocalUser) => new Promise(async (res, rej) =
|
||||
if (userIdErr) return rej('invalid userId param');
|
||||
|
||||
// Get 'limit' parameter
|
||||
const [limit = 10, limitErr] = $.num.optional().range(1, 100).get(params.limit);
|
||||
const [limit = 10, limitErr] = $.num.optional.range(1, 100).get(params.limit);
|
||||
if (limitErr) return rej('invalid limit param');
|
||||
|
||||
// Lookup user
|
||||
|
@ -8,11 +8,11 @@ import User, { ILocalUser } from '../../../../models/user';
|
||||
*/
|
||||
module.exports = (params: any, me: ILocalUser) => new Promise(async (res, rej) => {
|
||||
// Get 'userId' parameter
|
||||
const [userId, userIdErr] = $.type(ID).optional().get(params.userId);
|
||||
const [userId, userIdErr] = $.type(ID).optional.get(params.userId);
|
||||
if (userIdErr) return rej('invalid userId param');
|
||||
|
||||
// Get 'username' parameter
|
||||
const [username, usernameErr] = $.str.optional().get(params.username);
|
||||
const [username, usernameErr] = $.str.optional.get(params.username);
|
||||
if (usernameErr) return rej('invalid username param');
|
||||
|
||||
if (userId === undefined && username === undefined) {
|
||||
@ -20,7 +20,7 @@ module.exports = (params: any, me: ILocalUser) => new Promise(async (res, rej) =
|
||||
}
|
||||
|
||||
// Get 'host' parameter
|
||||
const [host, hostErr] = $.str.optional().get(params.host);
|
||||
const [host, hostErr] = $.str.optional.get(params.host);
|
||||
if (hostErr) return rej('invalid host param');
|
||||
|
||||
if (userId === undefined && host === undefined) {
|
||||
@ -28,31 +28,31 @@ module.exports = (params: any, me: ILocalUser) => new Promise(async (res, rej) =
|
||||
}
|
||||
|
||||
// Get 'includeReplies' parameter
|
||||
const [includeReplies = true, includeRepliesErr] = $.bool.optional().get(params.includeReplies);
|
||||
const [includeReplies = true, includeRepliesErr] = $.bool.optional.get(params.includeReplies);
|
||||
if (includeRepliesErr) return rej('invalid includeReplies param');
|
||||
|
||||
// Get 'withMedia' parameter
|
||||
const [withMedia = false, withMediaErr] = $.bool.optional().get(params.withMedia);
|
||||
const [withMedia = false, withMediaErr] = $.bool.optional.get(params.withMedia);
|
||||
if (withMediaErr) return rej('invalid withMedia param');
|
||||
|
||||
// Get 'limit' parameter
|
||||
const [limit = 10, limitErr] = $.num.optional().range(1, 100).get(params.limit);
|
||||
const [limit = 10, limitErr] = $.num.optional.range(1, 100).get(params.limit);
|
||||
if (limitErr) return rej('invalid limit param');
|
||||
|
||||
// Get 'sinceId' parameter
|
||||
const [sinceId, sinceIdErr] = $.type(ID).optional().get(params.sinceId);
|
||||
const [sinceId, sinceIdErr] = $.type(ID).optional.get(params.sinceId);
|
||||
if (sinceIdErr) return rej('invalid sinceId param');
|
||||
|
||||
// Get 'untilId' parameter
|
||||
const [untilId, untilIdErr] = $.type(ID).optional().get(params.untilId);
|
||||
const [untilId, untilIdErr] = $.type(ID).optional.get(params.untilId);
|
||||
if (untilIdErr) return rej('invalid untilId param');
|
||||
|
||||
// Get 'sinceDate' parameter
|
||||
const [sinceDate, sinceDateErr] = $.num.optional().get(params.sinceDate);
|
||||
const [sinceDate, sinceDateErr] = $.num.optional.get(params.sinceDate);
|
||||
if (sinceDateErr) throw 'invalid sinceDate param';
|
||||
|
||||
// Get 'untilDate' parameter
|
||||
const [untilDate, untilDateErr] = $.num.optional().get(params.untilDate);
|
||||
const [untilDate, untilDateErr] = $.num.optional.get(params.untilDate);
|
||||
if (untilDateErr) throw 'invalid untilDate param';
|
||||
|
||||
// Check if only one of sinceId, untilId, sinceDate, untilDate specified
|
||||
|
@ -9,11 +9,11 @@ import Mute from '../../../../models/mute';
|
||||
*/
|
||||
module.exports = (params: any, me: ILocalUser) => new Promise(async (res, rej) => {
|
||||
// Get 'limit' parameter
|
||||
const [limit = 10, limitErr] = $.num.optional().range(1, 100).get(params.limit);
|
||||
const [limit = 10, limitErr] = $.num.optional.range(1, 100).get(params.limit);
|
||||
if (limitErr) return rej('invalid limit param');
|
||||
|
||||
// Get 'offset' parameter
|
||||
const [offset = 0, offsetErr] = $.num.optional().min(0).get(params.offset);
|
||||
const [offset = 0, offsetErr] = $.num.optional.min(0).get(params.offset);
|
||||
if (offsetErr) return rej('invalid offset param');
|
||||
|
||||
// ID list of the user itself and other users who the user follows
|
||||
|
@ -11,7 +11,7 @@ module.exports = (params: any, me: ILocalUser) => new Promise(async (res, rej) =
|
||||
if (queryError) return rej('invalid query param');
|
||||
|
||||
// Get 'max' parameter
|
||||
const [max = 10, maxErr] = $.num.optional().range(1, 30).get(params.max);
|
||||
const [max = 10, maxErr] = $.num.optional.range(1, 30).get(params.max);
|
||||
if (maxErr) return rej('invalid max param');
|
||||
|
||||
const escapedQuery = escapeRegexp(query);
|
||||
|
@ -10,11 +10,11 @@ module.exports = (params: any, me: ILocalUser) => new Promise(async (res, rej) =
|
||||
if (queryError) return rej('invalid query param');
|
||||
|
||||
// Get 'offset' parameter
|
||||
const [offset = 0, offsetErr] = $.num.optional().min(0).get(params.offset);
|
||||
const [offset = 0, offsetErr] = $.num.optional.min(0).get(params.offset);
|
||||
if (offsetErr) return rej('invalid offset param');
|
||||
|
||||
// Get 'limit' parameter
|
||||
const [limit = 10, limitErr] = $.num.optional().range(1, 100).get(params.limit);
|
||||
const [limit = 10, limitErr] = $.num.optional.range(1, 100).get(params.limit);
|
||||
if (limitErr) return rej('invalid limit param');
|
||||
|
||||
let users = await User
|
||||
|
@ -11,19 +11,19 @@ module.exports = (params: any, me: ILocalUser) => new Promise(async (res, rej) =
|
||||
let user;
|
||||
|
||||
// Get 'userId' parameter
|
||||
const [userId, userIdErr] = $.type(ID).optional().get(params.userId);
|
||||
const [userId, userIdErr] = $.type(ID).optional.get(params.userId);
|
||||
if (userIdErr) return rej('invalid userId param');
|
||||
|
||||
// Get 'userIds' parameter
|
||||
const [userIds, userIdsErr] = $.arr($.type(ID)).optional().get(params.userIds);
|
||||
const [userIds, userIdsErr] = $.arr($.type(ID)).optional.get(params.userIds);
|
||||
if (userIdsErr) return rej('invalid userIds param');
|
||||
|
||||
// Get 'username' parameter
|
||||
const [username, usernameErr] = $.str.optional().get(params.username);
|
||||
const [username, usernameErr] = $.str.optional.get(params.username);
|
||||
if (usernameErr) return rej('invalid username param');
|
||||
|
||||
// Get 'host' parameter
|
||||
const [host, hostErr] = $.str.optional().nullable().get(params.host);
|
||||
const [host, hostErr] = $.str.optional.nullable.get(params.host);
|
||||
if (hostErr) return rej('invalid host param');
|
||||
|
||||
if (userIds) {
|
||||
|
Reference in New Issue
Block a user