summaryrefslogtreecommitdiff
path: root/src/api/endpoints/posts
diff options
context:
space:
mode:
authorsyuilo <syuilotan@yahoo.co.jp>2017-03-02 05:31:30 +0900
committersyuilo <syuilotan@yahoo.co.jp>2017-03-02 05:31:30 +0900
commitf3f5869f5214085637276b077ece739eac2e5dff (patch)
tree0fde0dcf89140791e902f7b85578d55e30600c57 /src/api/endpoints/posts
parentExtract hasDuplicates function (diff)
downloadsharkey-f3f5869f5214085637276b077ece739eac2e5dff.tar.gz
sharkey-f3f5869f5214085637276b077ece739eac2e5dff.tar.bz2
sharkey-f3f5869f5214085637276b077ece739eac2e5dff.zip
Add 'set' type
Diffstat (limited to 'src/api/endpoints/posts')
-rw-r--r--src/api/endpoints/posts/create.js9
1 files changed, 3 insertions, 6 deletions
diff --git a/src/api/endpoints/posts/create.js b/src/api/endpoints/posts/create.js
index 92aeb3d08e..eadc886c5c 100644
--- a/src/api/endpoints/posts/create.js
+++ b/src/api/endpoints/posts/create.js
@@ -4,7 +4,6 @@
* Module dependencies
*/
import validate from '../../validator';
-import hasDuplicates from '../../../common/has-duplicates';
import parse from '../../../common/text';
import { Post, isValidText } from '../../models/post';
import User from '../../models/user';
@@ -32,10 +31,9 @@ module.exports = (params, user, app) =>
if (textErr) return rej('invalid text');
// Get 'media_ids' parameter
- const [mediaIds, mediaIdsErr] = validate(params.media_ids, 'array', false, [
- x => !hasDuplicates(x),
+ const [mediaIds, mediaIdsErr] = validate(params.media_ids, 'set', false,
x => x.length > 4 ? 'too many media' : true
- ]);
+ );
if (mediaIdsErr) return rej('invalid media_ids');
let files = [];
@@ -135,8 +133,7 @@ module.exports = (params, user, app) =>
let poll = null;
if (_poll !== null) {
- const [pollChoices, pollChoicesErr] = validate(params.poll, 'array', false, [
- choices => !hasDuplicates(choices),
+ const [pollChoices, pollChoicesErr] = validate(params.poll, 'set', false, [
choices => {
const shouldReject = choices.some(choice => {
if (typeof choice != 'string') return true;