cafy 5.xに移行
This commit is contained in:
@ -1,7 +1,7 @@
|
||||
/**
|
||||
* Module dependencies
|
||||
*/
|
||||
import $ from 'cafy';
|
||||
import $ from 'cafy'; import ID from '../../../../cafy-id';
|
||||
import User from '../../../../models/user';
|
||||
import Following from '../../../../models/following';
|
||||
import { pack } from '../../../../models/user';
|
||||
@ -9,14 +9,10 @@ import { getFriendIds } from '../../common/get-friends';
|
||||
|
||||
/**
|
||||
* Get followers of a user
|
||||
*
|
||||
* @param {any} params
|
||||
* @param {any} me
|
||||
* @return {Promise<any>}
|
||||
*/
|
||||
module.exports = (params, me) => new Promise(async (res, rej) => {
|
||||
// Get 'userId' parameter
|
||||
const [userId, userIdErr] = $(params.userId).id().$;
|
||||
const [userId, userIdErr] = $(params.userId).type(ID).$;
|
||||
if (userIdErr) return rej('invalid userId param');
|
||||
|
||||
// Get 'iknow' parameter
|
||||
@ -28,7 +24,7 @@ module.exports = (params, me) => new Promise(async (res, rej) => {
|
||||
if (limitErr) return rej('invalid limit param');
|
||||
|
||||
// Get 'cursor' parameter
|
||||
const [cursor = null, cursorErr] = $(params.cursor).optional.id().$;
|
||||
const [cursor = null, cursorErr] = $(params.cursor).optional.type(ID).$;
|
||||
if (cursorErr) return rej('invalid cursor param');
|
||||
|
||||
// Lookup user
|
||||
|
@ -1,7 +1,7 @@
|
||||
/**
|
||||
* Module dependencies
|
||||
*/
|
||||
import $ from 'cafy';
|
||||
import $ from 'cafy'; import ID from '../../../../cafy-id';
|
||||
import User from '../../../../models/user';
|
||||
import Following from '../../../../models/following';
|
||||
import { pack } from '../../../../models/user';
|
||||
@ -16,7 +16,7 @@ import { getFriendIds } from '../../common/get-friends';
|
||||
*/
|
||||
module.exports = (params, me) => new Promise(async (res, rej) => {
|
||||
// Get 'userId' parameter
|
||||
const [userId, userIdErr] = $(params.userId).id().$;
|
||||
const [userId, userIdErr] = $(params.userId).type(ID).$;
|
||||
if (userIdErr) return rej('invalid userId param');
|
||||
|
||||
// Get 'iknow' parameter
|
||||
@ -28,7 +28,7 @@ module.exports = (params, me) => new Promise(async (res, rej) => {
|
||||
if (limitErr) return rej('invalid limit param');
|
||||
|
||||
// Get 'cursor' parameter
|
||||
const [cursor = null, cursorErr] = $(params.cursor).optional.id().$;
|
||||
const [cursor = null, cursorErr] = $(params.cursor).optional.type(ID).$;
|
||||
if (cursorErr) return rej('invalid cursor param');
|
||||
|
||||
// Lookup user
|
||||
|
@ -1,13 +1,13 @@
|
||||
/**
|
||||
* Module dependencies
|
||||
*/
|
||||
import $ from 'cafy';
|
||||
import $ from 'cafy'; import ID from '../../../../cafy-id';
|
||||
import Note from '../../../../models/note';
|
||||
import User, { pack } from '../../../../models/user';
|
||||
|
||||
module.exports = (params, me) => new Promise(async (res, rej) => {
|
||||
// Get 'userId' parameter
|
||||
const [userId, userIdErr] = $(params.userId).id().$;
|
||||
const [userId, userIdErr] = $(params.userId).type(ID).$;
|
||||
if (userIdErr) return rej('invalid userId param');
|
||||
|
||||
// Get 'limit' parameter
|
||||
|
25
src/server/api/endpoints/users/list/create.ts
Normal file
25
src/server/api/endpoints/users/list/create.ts
Normal file
@ -0,0 +1,25 @@
|
||||
/**
|
||||
* Module dependencies
|
||||
*/
|
||||
import $ from 'cafy';
|
||||
import UserList, { pack } from '../../../../../models/user-list';
|
||||
|
||||
/**
|
||||
* Create a user list
|
||||
*/
|
||||
module.exports = async (params, user) => new Promise(async (res, rej) => {
|
||||
// Get 'title' parameter
|
||||
const [title, titleErr] = $(params.title).string().range(1, 100).$;
|
||||
if (titleErr) return rej('invalid title param');
|
||||
|
||||
// insert
|
||||
const userList = await UserList.insert({
|
||||
createdAt: new Date(),
|
||||
userId: user._id,
|
||||
title: title,
|
||||
userIds: []
|
||||
});
|
||||
|
||||
// Response
|
||||
res(await pack(userList));
|
||||
});
|
0
src/server/api/endpoints/users/list/push.ts
Normal file
0
src/server/api/endpoints/users/list/push.ts
Normal file
@ -1,7 +1,7 @@
|
||||
/**
|
||||
* Module dependencies
|
||||
*/
|
||||
import $ from 'cafy';
|
||||
import $ from 'cafy'; import ID from '../../../../cafy-id';
|
||||
import getHostLower from '../../common/get-host-lower';
|
||||
import Note, { pack } from '../../../../models/note';
|
||||
import User from '../../../../models/user';
|
||||
@ -11,7 +11,7 @@ import User from '../../../../models/user';
|
||||
*/
|
||||
module.exports = (params, me) => new Promise(async (res, rej) => {
|
||||
// Get 'userId' parameter
|
||||
const [userId, userIdErr] = $(params.userId).optional.id().$;
|
||||
const [userId, userIdErr] = $(params.userId).optional.type(ID).$;
|
||||
if (userIdErr) return rej('invalid userId param');
|
||||
|
||||
// Get 'username' parameter
|
||||
@ -43,11 +43,11 @@ module.exports = (params, me) => new Promise(async (res, rej) => {
|
||||
if (limitErr) return rej('invalid limit param');
|
||||
|
||||
// Get 'sinceId' parameter
|
||||
const [sinceId, sinceIdErr] = $(params.sinceId).optional.id().$;
|
||||
const [sinceId, sinceIdErr] = $(params.sinceId).optional.type(ID).$;
|
||||
if (sinceIdErr) return rej('invalid sinceId param');
|
||||
|
||||
// Get 'untilId' parameter
|
||||
const [untilId, untilIdErr] = $(params.untilId).optional.id().$;
|
||||
const [untilId, untilIdErr] = $(params.untilId).optional.type(ID).$;
|
||||
if (untilIdErr) return rej('invalid untilId param');
|
||||
|
||||
// Get 'sinceDate' parameter
|
||||
|
@ -2,7 +2,7 @@
|
||||
* Module dependencies
|
||||
*/
|
||||
const ms = require('ms');
|
||||
import $ from 'cafy';
|
||||
import $ from 'cafy'; import ID from '../../../../cafy-id';
|
||||
import User, { pack } from '../../../../models/user';
|
||||
import { getFriendIds } from '../../common/get-friends';
|
||||
import Mute from '../../../../models/mute';
|
||||
|
@ -2,7 +2,7 @@
|
||||
* Module dependencies
|
||||
*/
|
||||
import * as mongo from 'mongodb';
|
||||
import $ from 'cafy';
|
||||
import $ from 'cafy'; import ID from '../../../../cafy-id';
|
||||
import User, { pack } from '../../../../models/user';
|
||||
import config from '../../../../config';
|
||||
const escapeRegexp = require('escape-regexp');
|
||||
|
@ -1,7 +1,7 @@
|
||||
/**
|
||||
* Module dependencies
|
||||
*/
|
||||
import $ from 'cafy';
|
||||
import $ from 'cafy'; import ID from '../../../../cafy-id';
|
||||
import User, { pack } from '../../../../models/user';
|
||||
|
||||
/**
|
||||
|
@ -1,7 +1,7 @@
|
||||
/**
|
||||
* Module dependencies
|
||||
*/
|
||||
import $ from 'cafy';
|
||||
import $ from 'cafy'; import ID from '../../../../cafy-id';
|
||||
import User, { pack } from '../../../../models/user';
|
||||
import resolveRemoteUser from '../../../../remote/resolve-user';
|
||||
|
||||
@ -14,7 +14,7 @@ module.exports = (params, me) => new Promise(async (res, rej) => {
|
||||
let user;
|
||||
|
||||
// Get 'userId' parameter
|
||||
const [userId, userIdErr] = $(params.userId).optional.id().$;
|
||||
const [userId, userIdErr] = $(params.userId).optional.type(ID).$;
|
||||
if (userIdErr) return rej('invalid userId param');
|
||||
|
||||
// Get 'username' parameter
|
||||
|
Reference in New Issue
Block a user