summaryrefslogtreecommitdiff
path: root/src/server/api/endpoints/posts/categorize.ts
diff options
context:
space:
mode:
authorsyuilo <syuilotan@yahoo.co.jp>2018-03-29 20:32:18 +0900
committersyuilo <syuilotan@yahoo.co.jp>2018-03-29 20:32:18 +0900
commitcf33e483f7e6f40e8cbbbc0118a7df70bdaf651f (patch)
tree318279530d3392ee40d91968477fc0e78d5cf0f7 /src/server/api/endpoints/posts/categorize.ts
parentUpdate .travis.yml (diff)
downloadsharkey-cf33e483f7e6f40e8cbbbc0118a7df70bdaf651f.tar.gz
sharkey-cf33e483f7e6f40e8cbbbc0118a7df70bdaf651f.tar.bz2
sharkey-cf33e483f7e6f40e8cbbbc0118a7df70bdaf651f.zip
整理した
Diffstat (limited to 'src/server/api/endpoints/posts/categorize.ts')
-rw-r--r--src/server/api/endpoints/posts/categorize.ts52
1 files changed, 0 insertions, 52 deletions
diff --git a/src/server/api/endpoints/posts/categorize.ts b/src/server/api/endpoints/posts/categorize.ts
deleted file mode 100644
index 0436c8e697..0000000000
--- a/src/server/api/endpoints/posts/categorize.ts
+++ /dev/null
@@ -1,52 +0,0 @@
-/**
- * Module dependencies
- */
-import $ from 'cafy';
-import Post from '../../models/post';
-
-/**
- * Categorize a post
- *
- * @param {any} params
- * @param {any} user
- * @return {Promise<any>}
- */
-module.exports = (params, user) => new Promise(async (res, rej) => {
- if (!user.account.isPro) {
- return rej('This endpoint is available only from a Pro account');
- }
-
- // Get 'postId' parameter
- const [postId, postIdErr] = $(params.postId).id().$;
- if (postIdErr) return rej('invalid postId param');
-
- // Get categorizee
- const post = await Post.findOne({
- _id: postId
- });
-
- if (post === null) {
- return rej('post not found');
- }
-
- if (post.is_category_verified) {
- return rej('This post already has the verified category');
- }
-
- // Get 'category' parameter
- const [category, categoryErr] = $(params.category).string().or([
- 'music', 'game', 'anime', 'it', 'gadgets', 'photography'
- ]).$;
- if (categoryErr) return rej('invalid category param');
-
- // Set category
- Post.update({ _id: post._id }, {
- $set: {
- category: category,
- is_category_verified: true
- }
- });
-
- // Send response
- res();
-});