This commit is contained in:
syuilo
2018-03-30 11:24:07 +09:00
parent 5c3ca62426
commit 75c4c844e6
3 changed files with 17 additions and 1 deletions

View File

@ -4,7 +4,7 @@
import $ from 'cafy';
import deepEqual = require('deep-equal');
import parse from '../../../../common/text';
import { default as Post, IPost, isValidText } from '../../../../models/post';
import { default as Post, IPost, isValidText, isValidCw } from '../../../../models/post';
import { default as User, ILocalAccount, IUser } from '../../../../models/user';
import { default as Channel, IChannel } from '../../../../models/channel';
import Following from '../../../../models/following';
@ -33,6 +33,10 @@ module.exports = (params, user: IUser, app) => new Promise(async (res, rej) => {
const [text, textErr] = $(params.text).optional.string().pipe(isValidText).$;
if (textErr) return rej('invalid text');
// Get 'cw' parameter
const [cw, cwErr] = $(params.cw).optional.string().pipe(isValidCw).$;
if (cwErr) return rej('invalid cw');
// Get 'viaMobile' parameter
const [viaMobile = false, viaMobileErr] = $(params.viaMobile).optional.boolean().$;
if (viaMobileErr) return rej('invalid viaMobile');
@ -255,6 +259,7 @@ module.exports = (params, user: IUser, app) => new Promise(async (res, rej) => {
repostId: repost ? repost._id : undefined,
poll: poll,
text: text,
cw: cw,
tags: tags,
userId: user._id,
appId: app ? app._id : null,