Update cafy to 8.0.0 🚀
This commit is contained in:
parent
0c3e9dd5e0
commit
f664cf09c0
97 changed files with 294 additions and 291 deletions
|
@ -14,11 +14,11 @@ import { IApp } from '../../../../models/app';
|
|||
*/
|
||||
module.exports = (params, user: ILocalUser, app: IApp) => new Promise(async (res, rej) => {
|
||||
// Get 'visibility' parameter
|
||||
const [visibility = 'public', visibilityErr] = $(params.visibility).optional.string().or(['public', 'home', 'followers', 'specified', 'private']).get();
|
||||
const [visibility = 'public', visibilityErr] = $.str.optional().or(['public', 'home', 'followers', 'specified', 'private']).get(params.visibility);
|
||||
if (visibilityErr) return rej('invalid visibility');
|
||||
|
||||
// Get 'visibleUserIds' parameter
|
||||
const [visibleUserIds, visibleUserIdsErr] = $(params.visibleUserIds).optional.array($().type(ID)).unique().min(1).get();
|
||||
const [visibleUserIds, visibleUserIdsErr] = $.arr($.type(ID)).optional().unique().min(1).get(params.visibleUserIds);
|
||||
if (visibleUserIdsErr) return rej('invalid visibleUserIds');
|
||||
|
||||
let visibleUsers = [];
|
||||
|
@ -29,36 +29,36 @@ module.exports = (params, user: ILocalUser, app: IApp) => new Promise(async (res
|
|||
}
|
||||
|
||||
// Get 'text' parameter
|
||||
const [text = null, textErr] = $(params.text).optional.nullable.string().pipe(isValidText).get();
|
||||
const [text = null, textErr] = $.str.optional().nullable().pipe(isValidText).get(params.text);
|
||||
if (textErr) return rej('invalid text');
|
||||
|
||||
// Get 'cw' parameter
|
||||
const [cw, cwErr] = $(params.cw).optional.nullable.string().pipe(isValidCw).get();
|
||||
const [cw, cwErr] = $.str.optional().nullable().pipe(isValidCw).get(params.cw);
|
||||
if (cwErr) return rej('invalid cw');
|
||||
|
||||
// Get 'viaMobile' parameter
|
||||
const [viaMobile = false, viaMobileErr] = $(params.viaMobile).optional.boolean().get();
|
||||
const [viaMobile = false, viaMobileErr] = $.bool.optional().get(params.viaMobile);
|
||||
if (viaMobileErr) return rej('invalid viaMobile');
|
||||
|
||||
// Get 'tags' parameter
|
||||
const [tags = [], tagsErr] = $(params.tags).optional.array($().string().range(1, 32)).unique().get();
|
||||
const [tags = [], tagsErr] = $.arr($.str.optional().range(1, 32)).unique().get(params.tags);
|
||||
if (tagsErr) return rej('invalid tags');
|
||||
|
||||
// Get 'geo' parameter
|
||||
const [geo, geoErr] = $(params.geo).optional.nullable.object(true)
|
||||
.have('coordinates', $().array().length(2)
|
||||
.item(0, $().number().range(-180, 180))
|
||||
.item(1, $().number().range(-90, 90)))
|
||||
.have('altitude', $().nullable.number())
|
||||
.have('accuracy', $().nullable.number())
|
||||
.have('altitudeAccuracy', $().nullable.number())
|
||||
.have('heading', $().nullable.number().range(0, 360))
|
||||
.have('speed', $().nullable.number())
|
||||
.get();
|
||||
const [geo, geoErr] = $.obj.optional().nullable().strict()
|
||||
.have('coordinates', $.arr().length(2)
|
||||
.item(0, $.num.range(-180, 180))
|
||||
.item(1, $.num.range(-90, 90)))
|
||||
.have('altitude', $.num.nullable())
|
||||
.have('accuracy', $.num.nullable())
|
||||
.have('altitudeAccuracy', $.num.nullable())
|
||||
.have('heading', $.num.nullable().range(0, 360))
|
||||
.have('speed', $.num.nullable())
|
||||
.get(params.geo);
|
||||
if (geoErr) return rej('invalid geo');
|
||||
|
||||
// Get 'mediaIds' parameter
|
||||
const [mediaIds, mediaIdsErr] = $(params.mediaIds).optional.array($().type(ID)).unique().range(1, 4).get();
|
||||
const [mediaIds, mediaIdsErr] = $.arr($.type(ID)).optional().unique().range(1, 4).get(params.mediaIds);
|
||||
if (mediaIdsErr) return rej('invalid mediaIds');
|
||||
|
||||
let files = [];
|
||||
|
@ -85,7 +85,7 @@ module.exports = (params, user: ILocalUser, app: IApp) => new Promise(async (res
|
|||
}
|
||||
|
||||
// Get 'renoteId' parameter
|
||||
const [renoteId, renoteIdErr] = $(params.renoteId).optional.type(ID).get();
|
||||
const [renoteId, renoteIdErr] = $.type(ID).optional().get(params.renoteId);
|
||||
if (renoteIdErr) return rej('invalid renoteId');
|
||||
|
||||
let renote: INote = null;
|
||||
|
@ -106,7 +106,7 @@ module.exports = (params, user: ILocalUser, app: IApp) => new Promise(async (res
|
|||
}
|
||||
|
||||
// Get 'replyId' parameter
|
||||
const [replyId, replyIdErr] = $(params.replyId).optional.type(ID).get();
|
||||
const [replyId, replyIdErr] = $.type(ID).optional().get(params.replyId);
|
||||
if (replyIdErr) return rej('invalid replyId');
|
||||
|
||||
let reply: INote = null;
|
||||
|
@ -127,7 +127,7 @@ module.exports = (params, user: ILocalUser, app: IApp) => new Promise(async (res
|
|||
}
|
||||
|
||||
// Get 'channelId' parameter
|
||||
const [channelId, channelIdErr] = $(params.channelId).optional.type(ID).get();
|
||||
const [channelId, channelIdErr] = $.type(ID).optional().get(params.channelId);
|
||||
if (channelIdErr) return rej('invalid channelId');
|
||||
|
||||
let channel: IChannel = null;
|
||||
|
@ -168,12 +168,12 @@ module.exports = (params, user: ILocalUser, app: IApp) => new Promise(async (res
|
|||
}
|
||||
|
||||
// Get 'poll' parameter
|
||||
const [poll, pollErr] = $(params.poll).optional.object(true)
|
||||
.have('choices', $().array($().string())
|
||||
const [poll, pollErr] = $.obj.optional().strict()
|
||||
.have('choices', $.arr($.str)
|
||||
.unique()
|
||||
.range(2, 10)
|
||||
.each(c => c.length > 0 && c.length < 50))
|
||||
.get();
|
||||
.get(params.poll);
|
||||
if (pollErr) return rej('invalid poll');
|
||||
|
||||
if (poll) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue