整理した

This commit is contained in:
syuilo
2018-03-29 20:32:18 +09:00
parent 8a279a4656
commit cf33e483f7
552 changed files with 360 additions and 1311 deletions

View File

@@ -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();
});

View File

@@ -2,7 +2,7 @@
* Module dependencies
*/
import $ from 'cafy';
import Post, { pack } from '../../models/post';
import Post, { pack } from '../../../../models/post';
/**
* Show a context of a post

View File

@@ -3,21 +3,21 @@
*/
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 User, ILocalAccount, IUser } from '../../models/user';
import { default as Channel, IChannel } from '../../models/channel';
import Following from '../../models/following';
import Mute from '../../models/mute';
import DriveFile from '../../models/drive-file';
import Watching from '../../models/post-watching';
import ChannelWatching from '../../models/channel-watching';
import { pack } from '../../models/post';
import parse from '../../../../common/text';
import { default as Post, IPost, isValidText } 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';
import Mute from '../../../../models/mute';
import DriveFile from '../../../../models/drive-file';
import Watching from '../../../../models/post-watching';
import ChannelWatching from '../../../../models/channel-watching';
import { pack } from '../../../../models/post';
import notify from '../../common/notify';
import watch from '../../common/watch-post';
import event, { pushSw, publishChannelStream } from '../../event';
import getAcct from '../../../common/user/get-acct';
import parseAcct from '../../../common/user/parse-acct';
import getAcct from '../../../../common/user/get-acct';
import parseAcct from '../../../../common/user/parse-acct';
import config from '../../../../conf';
/**

View File

@@ -2,8 +2,8 @@
* Module dependencies
*/
import $ from 'cafy';
import Favorite from '../../../models/favorite';
import Post from '../../../models/post';
import Favorite from '../../../../../models/favorite';
import Post from '../../../../../models/post';
/**
* Favorite a post

View File

@@ -2,8 +2,8 @@
* Module dependencies
*/
import $ from 'cafy';
import Favorite from '../../../models/favorite';
import Post from '../../../models/post';
import Favorite from '../../../../../models/favorite';
import Post from '../../../../../models/post';
/**
* Unfavorite a post

View File

@@ -2,9 +2,9 @@
* Module dependencies
*/
import $ from 'cafy';
import Post from '../../models/post';
import Post from '../../../../models/post';
import getFriends from '../../common/get-friends';
import { pack } from '../../models/post';
import { pack } from '../../../../models/post';
/**
* Get mentions of myself

View File

@@ -2,8 +2,8 @@
* Module dependencies
*/
import $ from 'cafy';
import Vote from '../../../models/poll-vote';
import Post, { pack } from '../../../models/post';
import Vote from '../../../../../models/poll-vote';
import Post, { pack } from '../../../../../models/post';
/**
* Get recommended polls

View File

@@ -2,9 +2,9 @@
* Module dependencies
*/
import $ from 'cafy';
import Vote from '../../../models/poll-vote';
import Post from '../../../models/post';
import Watching from '../../../models/post-watching';
import Vote from '../../../../../models/poll-vote';
import Post from '../../../../../models/post';
import Watching from '../../../../../models/post-watching';
import notify from '../../../common/notify';
import watch from '../../../common/watch-post';
import { publishPostStream } from '../../../event';

View File

@@ -2,8 +2,8 @@
* Module dependencies
*/
import $ from 'cafy';
import Post from '../../models/post';
import Reaction, { pack } from '../../models/post-reaction';
import Post from '../../../../models/post';
import Reaction, { pack } from '../../../../models/post-reaction';
/**
* Show reactions of a post

View File

@@ -2,10 +2,10 @@
* Module dependencies
*/
import $ from 'cafy';
import Reaction from '../../../models/post-reaction';
import Post, { pack as packPost } from '../../../models/post';
import { pack as packUser } from '../../../models/user';
import Watching from '../../../models/post-watching';
import Reaction from '../../../../../models/post-reaction';
import Post, { pack as packPost } from '../../../../../models/post';
import { pack as packUser } from '../../../../../models/user';
import Watching from '../../../../../models/post-watching';
import notify from '../../../common/notify';
import watch from '../../../common/watch-post';
import { publishPostStream, pushSw } from '../../../event';

View File

@@ -2,8 +2,8 @@
* Module dependencies
*/
import $ from 'cafy';
import Reaction from '../../../models/post-reaction';
import Post from '../../../models/post';
import Reaction from '../../../../../models/post-reaction';
import Post from '../../../../../models/post';
// import event from '../../../event';
/**

View File

@@ -2,7 +2,7 @@
* Module dependencies
*/
import $ from 'cafy';
import Post, { pack } from '../../models/post';
import Post, { pack } from '../../../../models/post';
/**
* Show a replies of a post

View File

@@ -2,7 +2,7 @@
* Module dependencies
*/
import $ from 'cafy';
import Post, { pack } from '../../models/post';
import Post, { pack } from '../../../../models/post';
/**
* Show a reposts of a post

View File

@@ -3,11 +3,11 @@
*/
import $ from 'cafy';
const escapeRegexp = require('escape-regexp');
import Post from '../../models/post';
import User from '../../models/user';
import Mute from '../../models/mute';
import Post from '../../../../models/post';
import User from '../../../../models/user';
import Mute from '../../../../models/mute';
import getFriends from '../../common/get-friends';
import { pack } from '../../models/post';
import { pack } from '../../../../models/post';
/**
* Search a post

View File

@@ -2,7 +2,7 @@
* Module dependencies
*/
import $ from 'cafy';
import Post, { pack } from '../../models/post';
import Post, { pack } from '../../../../models/post';
/**
* Show a post

View File

@@ -3,11 +3,11 @@
*/
import $ from 'cafy';
import rap from '@prezzemolo/rap';
import Post from '../../models/post';
import Mute from '../../models/mute';
import ChannelWatching from '../../models/channel-watching';
import Post from '../../../../models/post';
import Mute from '../../../../models/mute';
import ChannelWatching from '../../../../models/channel-watching';
import getFriends from '../../common/get-friends';
import { pack } from '../../models/post';
import { pack } from '../../../../models/post';
/**
* Get timeline of myself

View File

@@ -3,7 +3,7 @@
*/
const ms = require('ms');
import $ from 'cafy';
import Post, { pack } from '../../models/post';
import Post, { pack } from '../../../../models/post';
/**
* Get trend posts