This commit is contained in:
syuilo
2018-06-18 09:54:53 +09:00
parent a766faeae9
commit 80e5645a84
150 changed files with 305 additions and 2334 deletions

View File

@ -1,13 +1,10 @@
/**
* Module dependencies
*/
import $ from 'cafy';
import Note from '../../../../models/note';
/**
* Aggregate notes
*/
module.exports = params => new Promise(async (res, rej) => {
module.exports = (params: any) => new Promise(async (res, rej) => {
// Get 'limit' parameter
const [limit = 365, limitErr] = $.num.optional().range(1, 365).get(params.limit);
if (limitErr) return rej('invalid limit param');

View File

@ -1,13 +1,10 @@
/**
* Module dependencies
*/
import $ from 'cafy';
import User from '../../../../models/user';
/**
* Aggregate users
*/
module.exports = params => new Promise(async (res, rej) => {
module.exports = (params: any) => new Promise(async (res, rej) => {
// Get 'limit' parameter
const [limit = 365, limitErr] = $.num.optional().range(1, 365).get(params.limit);
if (limitErr) return rej('invalid limit param');

View File

@ -1,6 +1,3 @@
/**
* Module dependencies
*/
import $ from 'cafy'; import ID from '../../../../../cafy-id';
import User from '../../../../../models/user';
import Note from '../../../../../models/note';
@ -10,7 +7,7 @@ import Note from '../../../../../models/note';
/**
* Aggregate activity of a user
*/
module.exports = (params) => new Promise(async (res, rej) => {
module.exports = (params: any) => new Promise(async (res, rej) => {
// Get 'limit' parameter
const [limit = 365, limitErr] = $.num.optional().range(1, 365).get(params.limit);
if (limitErr) return rej('invalid limit param');
@ -73,13 +70,13 @@ module.exports = (params) => new Promise(async (res, rej) => {
} }
]);
datas.forEach(data => {
datas.forEach((data: any) => {
data.date = data._id;
delete data._id;
data.notes = (data.data.filter(x => x.type == 'note')[0] || { count: 0 }).count;
data.renotes = (data.data.filter(x => x.type == 'renote')[0] || { count: 0 }).count;
data.replies = (data.data.filter(x => x.type == 'reply')[0] || { count: 0 }).count;
data.notes = (data.data.filter((x: any) => x.type == 'note')[0] || { count: 0 }).count;
data.renotes = (data.data.filter((x: any) => x.type == 'renote')[0] || { count: 0 }).count;
data.replies = (data.data.filter((x: any) => x.type == 'reply')[0] || { count: 0 }).count;
delete data.data;
});
@ -89,7 +86,7 @@ module.exports = (params) => new Promise(async (res, rej) => {
for (let i = 0; i < limit; i++) {
const day = new Date(new Date().setDate(new Date().getDate() - i));
const data = datas.filter(d =>
const data = datas.filter((d: any) =>
d.date.year == day.getFullYear() && d.date.month == day.getMonth() + 1 && d.date.day == day.getDate()
)[0];

View File

@ -8,7 +8,7 @@ import FollowedLog from '../../../../../models/followed-log';
/**
* Aggregate followers of a user
*/
module.exports = (params) => new Promise(async (res, rej) => {
module.exports = (params: any) => new Promise(async (res, rej) => {
// Get 'userId' parameter
const [userId, userIdErr] = $.type(ID).get(params.userId);
if (userIdErr) return rej('invalid userId param');

View File

@ -8,7 +8,7 @@ import FollowingLog from '../../../../../models/following-log';
/**
* Aggregate following of a user
*/
module.exports = (params) => new Promise(async (res, rej) => {
module.exports = (params: any) => new Promise(async (res, rej) => {
// Get 'userId' parameter
const [userId, userIdErr] = $.type(ID).get(params.userId);
if (userIdErr) return rej('invalid userId param');

View File

@ -1,6 +1,3 @@
/**
* Module dependencies
*/
import $ from 'cafy'; import ID from '../../../../../cafy-id';
import User from '../../../../../models/user';
import Note from '../../../../../models/note';
@ -8,7 +5,7 @@ import Note from '../../../../../models/note';
/**
* Aggregate note of a user
*/
module.exports = (params) => new Promise(async (res, rej) => {
module.exports = (params: any) => new Promise(async (res, rej) => {
// Get 'userId' parameter
const [userId, userIdErr] = $.type(ID).get(params.userId);
if (userIdErr) return rej('invalid userId param');
@ -67,13 +64,13 @@ module.exports = (params) => new Promise(async (res, rej) => {
} }
]);
datas.forEach(data => {
datas.forEach((data: any) => {
data.date = data._id;
delete data._id;
data.notes = (data.data.filter(x => x.type == 'note')[0] || { count: 0 }).count;
data.renotes = (data.data.filter(x => x.type == 'renote')[0] || { count: 0 }).count;
data.replies = (data.data.filter(x => x.type == 'reply')[0] || { count: 0 }).count;
data.notes = (data.data.filter((x: any) => x.type == 'note')[0] || { count: 0 }).count;
data.renotes = (data.data.filter((x: any) => x.type == 'renote')[0] || { count: 0 }).count;
data.replies = (data.data.filter((x: any) => x.type == 'reply')[0] || { count: 0 }).count;
delete data.data;
});
@ -83,7 +80,7 @@ module.exports = (params) => new Promise(async (res, rej) => {
for (let i = 0; i < 30; i++) {
const day = new Date(new Date().setDate(new Date().getDate() - i));
const data = datas.filter(d =>
const data = datas.filter((d: any) =>
d.date.year == day.getFullYear() && d.date.month == day.getMonth() + 1 && d.date.day == day.getDate()
)[0];

View File

@ -1,17 +1,11 @@
/**
* Module dependencies
*/
import $ from 'cafy'; import ID from '../../../../../cafy-id';
import User from '../../../../../models/user';
import Reaction from '../../../../../models/note-reaction';
/**
* Aggregate reaction of a user
*
* @param {any} params
* @return {Promise<any>}
*/
module.exports = (params) => new Promise(async (res, rej) => {
module.exports = (params: any) => new Promise(async (res, rej) => {
// Get 'userId' parameter
const [userId, userIdErr] = $.type(ID).get(params.userId);
if (userIdErr) return rej('invalid userId param');
@ -48,7 +42,7 @@ module.exports = (params) => new Promise(async (res, rej) => {
}}
]);
datas.forEach(data => {
datas.forEach((data: any) => {
data.date = data._id;
delete data._id;
});
@ -58,7 +52,7 @@ module.exports = (params) => new Promise(async (res, rej) => {
for (let i = 0; i < 30; i++) {
const day = new Date(new Date().setDate(new Date().getDate() - i));
const data = datas.filter(d =>
const data = datas.filter((d: any) =>
d.date.year == day.getFullYear() && d.date.month == day.getMonth() + 1 && d.date.day == day.getDate()
)[0];

View File

@ -1,9 +1,7 @@
/**
* Module dependencies
*/
import rndstr from 'rndstr';
import $ from 'cafy';
import App, { isValidNameId, pack } from '../../../../models/app';
import { ILocalUser } from '../../../../models/user';
/**
* @swagger
@ -60,12 +58,8 @@ import App, { isValidNameId, pack } from '../../../../models/app';
/**
* Create an app
*
* @param {any} params
* @param {any} user
* @return {Promise<any>}
*/
module.exports = async (params, user) => new Promise(async (res, rej) => {
module.exports = async (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
// Get 'nameId' parameter
const [nameId, nameIdErr] = $.str.pipe(isValidNameId).get(params.nameId);
if (nameIdErr) return rej('invalid nameId param');

View File

@ -40,7 +40,7 @@ import { isValidNameId } from '../../../../../models/app';
* @param {any} params
* @return {Promise<any>}
*/
module.exports = async (params) => new Promise(async (res, rej) => {
module.exports = async (params: any) => new Promise(async (res, rej) => {
// Get 'nameId' parameter
const [nameId, nameIdErr] = $.str.pipe(isValidNameId).get(params.nameId);
if (nameIdErr) return rej('invalid nameId param');

View File

@ -1,8 +1,6 @@
/**
* Module dependencies
*/
import $ from 'cafy'; import ID from '../../../../cafy-id';
import App, { pack } from '../../../../models/app';
import App, { pack, IApp } from '../../../../models/app';
import { ILocalUser } from '../../../../models/user';
/**
* @swagger
@ -37,7 +35,7 @@ import App, { pack } from '../../../../models/app';
/**
* Show an app
*/
module.exports = (params, user, app) => new Promise(async (res, rej) => {
module.exports = (params: any, user: ILocalUser, app: IApp) => new Promise(async (res, rej) => {
const isSecure = user != null && app == null;
// Get 'appId' parameter

View File

@ -1,12 +1,10 @@
/**
* Module dependencies
*/
import rndstr from 'rndstr';
const crypto = require('crypto');
import $ from 'cafy';
import App from '../../../../models/app';
import AuthSess from '../../../../models/auth-session';
import AccessToken from '../../../../models/access-token';
import { ILocalUser } from '../../../../models/user';
/**
* @swagger
@ -33,12 +31,8 @@ import AccessToken from '../../../../models/access-token';
/**
* Accept
*
* @param {any} params
* @param {any} user
* @return {Promise<any>}
*/
module.exports = (params, user) => new Promise(async (res, rej) => {
module.exports = (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
// Get 'token' parameter
const [token, tokenErr] = $.str.get(params.token);
if (tokenErr) return rej('invalid token param');

View File

@ -44,7 +44,7 @@ import config from '../../../../../config';
* @param {any} params
* @return {Promise<any>}
*/
module.exports = (params) => new Promise(async (res, rej) => {
module.exports = (params: any) => new Promise(async (res, rej) => {
// Get 'appSecret' parameter
const [appSecret, appSecretErr] = $.str.get(params.appSecret);
if (appSecretErr) return rej('invalid appSecret param');

View File

@ -1,8 +1,6 @@
/**
* Module dependencies
*/
import $ from 'cafy';
import AuthSess, { pack } from '../../../../../models/auth-session';
import { ILocalUser } from '../../../../../models/user';
/**
* @swagger
@ -46,12 +44,8 @@ import AuthSess, { pack } from '../../../../../models/auth-session';
/**
* Show a session
*
* @param {any} params
* @param {any} user
* @return {Promise<any>}
*/
module.exports = (params, user) => new Promise(async (res, rej) => {
module.exports = (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
// Get 'token' parameter
const [token, tokenErr] = $.str.get(params.token);
if (tokenErr) return rej('invalid token param');

View File

@ -49,7 +49,7 @@ import { pack } from '../../../../../models/user';
* @param {any} params
* @return {Promise<any>}
*/
module.exports = (params) => new Promise(async (res, rej) => {
module.exports = (params: any) => new Promise(async (res, rej) => {
// Get 'appSecret' parameter
const [appSecret, appSecretErr] = $.str.get(params.appSecret);
if (appSecretErr) return rej('invalid appSecret param');

View File

@ -1,9 +1,10 @@
import DriveFile from '../../../models/drive-file';
import { ILocalUser } from '../../../models/user';
/**
* Get drive information
*/
module.exports = (params, user) => new Promise(async (res, rej) => {
module.exports = (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
// Calculate drive usage
const usage = await DriveFile
.aggregate([{

View File

@ -1,13 +1,11 @@
/**
* Module dependencies
*/
import $ from 'cafy'; import ID from '../../../../cafy-id';
import DriveFile, { pack } from '../../../../models/drive-file';
import { ILocalUser } from '../../../../models/user';
/**
* Get drive files
*/
module.exports = async (params, user, app) => {
module.exports = async (params: any, user: ILocalUser) => {
// Get 'limit' parameter
const [limit = 10, limitErr] = $.num.optional().range(1, 100).get(params.limit);
if (limitErr) throw 'invalid limit param';

View File

@ -1,15 +1,13 @@
/**
* Module dependencies
*/
import * as fs from 'fs';
import $ from 'cafy'; import ID from '../../../../../cafy-id';
import { validateFileName, pack } from '../../../../../models/drive-file';
import create from '../../../../../services/drive/add-file';
import { ILocalUser } from '../../../../../models/user';
/**
* Create a file
*/
module.exports = async (file, params, user): Promise<any> => {
module.exports = async (file: any, params: any, user: ILocalUser): Promise<any> => {
if (file == null) {
throw 'file is required';
}

View File

@ -2,11 +2,12 @@ import $ from 'cafy'; import ID from '../../../../../cafy-id';
import DriveFile from '../../../../../models/drive-file';
import del from '../../../../../services/drive/delete-file';
import { publishDriveStream } from '../../../../../publishers/stream';
import { ILocalUser } from '../../../../../models/user';
/**
* Delete a file
*/
module.exports = async (params, user) => {
module.exports = async (params: any, user: ILocalUser) => {
// Get 'fileId' parameter
const [fileId, fileIdErr] = $.type(ID).get(params.fileId);
if (fileIdErr) throw 'invalid fileId param';

View File

@ -1,13 +1,11 @@
/**
* Module dependencies
*/
import $ from 'cafy'; import ID from '../../../../../cafy-id';
import DriveFile, { pack } from '../../../../../models/drive-file';
import { ILocalUser } from '../../../../../models/user';
/**
* Find a file(s)
*/
module.exports = (params, user) => new Promise(async (res, rej) => {
module.exports = (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
// Get 'name' parameter
const [name, nameErr] = $.str.get(params.name);
if (nameErr) return rej('invalid name param');

View File

@ -1,13 +1,11 @@
/**
* Module dependencies
*/
import $ from 'cafy'; import ID from '../../../../../cafy-id';
import DriveFile, { pack } from '../../../../../models/drive-file';
import { ILocalUser } from '../../../../../models/user';
/**
* Show a file
*/
module.exports = async (params, user) => {
module.exports = async (params: any, user: ILocalUser) => {
// Get 'fileId' parameter
const [fileId, fileIdErr] = $.type(ID).get(params.fileId);
if (fileIdErr) throw 'invalid fileId param';

View File

@ -1,15 +1,13 @@
/**
* Module dependencies
*/
import $ from 'cafy'; import ID from '../../../../../cafy-id';
import DriveFolder from '../../../../../models/drive-folder';
import DriveFile, { validateFileName, pack } from '../../../../../models/drive-file';
import { publishDriveStream } from '../../../../../publishers/stream';
import { ILocalUser } from '../../../../../models/user';
/**
* Update a file
*/
module.exports = (params, user) => new Promise(async (res, rej) => {
module.exports = (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
// Get 'fileId' parameter
const [fileId, fileIdErr] = $.type(ID).get(params.fileId);
if (fileIdErr) return rej('invalid fileId param');

View File

@ -7,7 +7,7 @@ import DriveFolder, { pack } from '../../../../models/drive-folder';
/**
* Get drive folders
*/
module.exports = (params, user, app) => new Promise(async (res, rej) => {
module.exports = (params: any, user: ILocalUser, app: IApp) => new Promise(async (res, rej) => {
// Get 'limit' parameter
const [limit = 10, limitErr] = $.num.optional().range(1, 100).get(params.limit);
if (limitErr) return rej('invalid limit param');

View File

@ -1,14 +1,12 @@
/**
* Module dependencies
*/
import $ from 'cafy'; import ID from '../../../../../cafy-id';
import DriveFolder, { isValidFolderName, pack } from '../../../../../models/drive-folder';
import { publishDriveStream } from '../../../../../publishers/stream';
import { ILocalUser } from '../../../../../models/user';
/**
* Create drive folder
*/
module.exports = (params, user) => new Promise(async (res, rej) => {
module.exports = (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
// Get 'name' parameter
const [name = '無題のフォルダー', nameErr] = $.str.optional().pipe(isValidFolderName).get(params.name);
if (nameErr) return rej('invalid name param');

View File

@ -1,13 +1,11 @@
/**
* Module dependencies
*/
import $ from 'cafy'; import ID from '../../../../../cafy-id';
import DriveFolder, { pack } from '../../../../../models/drive-folder';
import { ILocalUser } from '../../../../../models/user';
/**
* Find a folder(s)
*/
module.exports = (params, user) => new Promise(async (res, rej) => {
module.exports = (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
// Get 'name' parameter
const [name, nameErr] = $.str.get(params.name);
if (nameErr) return rej('invalid name param');

View File

@ -1,13 +1,11 @@
/**
* Module dependencies
*/
import $ from 'cafy'; import ID from '../../../../../cafy-id';
import DriveFolder, { pack } from '../../../../../models/drive-folder';
import { ILocalUser } from '../../../../../models/user';
/**
* Show a folder
*/
module.exports = (params, user) => new Promise(async (res, rej) => {
module.exports = (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
// Get 'folderId' parameter
const [folderId, folderIdErr] = $.type(ID).get(params.folderId);
if (folderIdErr) return rej('invalid folderId param');

View File

@ -1,14 +1,12 @@
/**
* Module dependencies
*/
import $ from 'cafy'; import ID from '../../../../../cafy-id';
import DriveFolder, { isValidFolderName, pack } from '../../../../../models/drive-folder';
import { publishDriveStream } from '../../../../../publishers/stream';
import { ILocalUser } from '../../../../../models/user';
/**
* Update a folder
*/
module.exports = (params, user) => new Promise(async (res, rej) => {
module.exports = (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
// Get 'folderId' parameter
const [folderId, folderIdErr] = $.type(ID).get(params.folderId);
if (folderIdErr) return rej('invalid folderId param');
@ -48,7 +46,7 @@ module.exports = (params, user) => new Promise(async (res, rej) => {
}
// Check if the circular reference will occur
async function checkCircle(folderId) {
async function checkCircle(folderId: any): Promise<boolean> {
// Fetch folder
const folder2 = await DriveFolder.findOne({
_id: folderId

View File

@ -1,13 +1,11 @@
/**
* Module dependencies
*/
import $ from 'cafy'; import ID from '../../../../cafy-id';
import DriveFile, { pack } from '../../../../models/drive-file';
import { ILocalUser } from '../../../../models/user';
/**
* Get drive stream
*/
module.exports = (params, user) => new Promise(async (res, rej) => {
module.exports = (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
// Get 'limit' parameter
const [limit = 10, limitErr] = $.num.optional().range(1, 100).get(params.limit);
if (limitErr) return rej('invalid limit param');

View File

@ -1,15 +1,12 @@
/**
* Module dependencies
*/
import $ from 'cafy'; import ID from '../../../../cafy-id';
import User, { pack } from '../../../../models/user';
import User, { pack, ILocalUser } from '../../../../models/user';
import Following from '../../../../models/following';
import create from '../../../../services/following/create';
/**
* Follow a user
*/
module.exports = (params, user) => new Promise(async (res, rej) => {
module.exports = (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
const follower = user;
// Get 'userId' parameter

View File

@ -1,15 +1,12 @@
/**
* Module dependencies
*/
import $ from 'cafy'; import ID from '../../../../cafy-id';
import User, { pack } from '../../../../models/user';
import User, { pack, ILocalUser } from '../../../../models/user';
import Following from '../../../../models/following';
import deleteFollowing from '../../../../services/following/delete';
/**
* Unfollow a user
*/
module.exports = (params, user) => new Promise(async (res, rej) => {
module.exports = (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
const follower = user;
// Get 'userId' parameter

View File

@ -1,11 +1,11 @@
import $ from 'cafy'; import ID from '../../../../../cafy-id';
import acceptFollowRequest from '../../../../../services/following/requests/accept';
import User from '../../../../../models/user';
import User, { ILocalUser } from '../../../../../models/user';
/**
* Accept a follow request
*/
module.exports = (params, user) => new Promise(async (res, rej) => {
module.exports = (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
// Get 'userId' parameter
const [followerId, followerIdErr] = $.type(ID).get(params.userId);
if (followerIdErr) return rej('invalid userId param');

View File

@ -1,11 +1,11 @@
import $ from 'cafy'; import ID from '../../../../../cafy-id';
import cancelFollowRequest from '../../../../../services/following/requests/cancel';
import User, { pack } from '../../../../../models/user';
import User, { pack, ILocalUser } from '../../../../../models/user';
/**
* Cancel a follow request
*/
module.exports = (params, user) => new Promise(async (res, rej) => {
module.exports = (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
// Get 'userId' parameter
const [followeeId, followeeIdErr] = $.type(ID).get(params.userId);
if (followeeIdErr) return rej('invalid userId param');

View File

@ -1,10 +1,11 @@
//import $ from 'cafy'; import ID from '../../../../../cafy-id';
import FollowRequest, { pack } from '../../../../../models/follow-request';
import { ILocalUser } from '../../../../../models/user';
/**
* Get all pending received follow requests
*/
module.exports = (params, user) => new Promise(async (res, rej) => {
module.exports = (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
const reqs = await FollowRequest.find({
followeeId: user._id
});

View File

@ -1,11 +1,11 @@
import $ from 'cafy'; import ID from '../../../../../cafy-id';
import rejectFollowRequest from '../../../../../services/following/requests/reject';
import User from '../../../../../models/user';
import User, { ILocalUser } from '../../../../../models/user';
/**
* Reject a follow request
*/
module.exports = (params, user) => new Promise(async (res, rej) => {
module.exports = (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
// Get 'userId' parameter
const [followerId, followerIdErr] = $.type(ID).get(params.userId);
if (followerIdErr) return rej('invalid userId param');

View File

@ -1,10 +1,11 @@
import $ from 'cafy'; import ID from '../../../../cafy-id';
import Following from '../../../../models/following';
import { ILocalUser } from '../../../../models/user';
/**
* Stalk a user
*/
module.exports = (params, user) => new Promise(async (res, rej) => {
module.exports = (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
const follower = user;
// Get 'userId' parameter

View File

@ -1,10 +1,11 @@
import $ from 'cafy'; import ID from '../../../../cafy-id';
import Following from '../../../../models/following';
import { ILocalUser } from '../../../../models/user';
/**
* Unstalk a user
*/
module.exports = (params, user) => new Promise(async (res, rej) => {
module.exports = (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
const follower = user;
// Get 'userId' parameter

View File

@ -45,7 +45,10 @@ module.exports = () => new Promise(async (res, rej) => {
return res([]);
}
const tags = [];
const tags: Array<{
name: string;
count: number;
}> = [];
// カウント
data.map(x => x._id).forEach(x => {

View File

@ -1,12 +1,10 @@
/**
* Module dependencies
*/
import User, { pack } from '../../../models/user';
import User, { pack, ILocalUser } from '../../../models/user';
import { IApp } from '../../../models/app';
/**
* Show myself
*/
module.exports = (params, user, app) => new Promise(async (res, rej) => {
module.exports = (params: any, user: ILocalUser, app: IApp) => new Promise(async (res, rej) => {
const isSecure = user != null && app == null;
// Serialize

View File

@ -1,11 +1,8 @@
/**
* Module dependencies
*/
import $ from 'cafy';
import * as speakeasy from 'speakeasy';
import User from '../../../../../models/user';
import User, { ILocalUser } from '../../../../../models/user';
module.exports = async (params, user) => new Promise(async (res, rej) => {
module.exports = async (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
// Get 'token' parameter
const [token, tokenErr] = $.str.get(params.token);
if (tokenErr) return rej('invalid token param');

View File

@ -1,14 +1,11 @@
/**
* Module dependencies
*/
import $ from 'cafy';
import * as bcrypt from 'bcryptjs';
import * as speakeasy from 'speakeasy';
import * as QRCode from 'qrcode';
import User from '../../../../../models/user';
import User, { ILocalUser } from '../../../../../models/user';
import config from '../../../../../config';
module.exports = async (params, user) => new Promise(async (res, rej) => {
module.exports = async (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
// Get 'password' parameter
const [password, passwordErr] = $.str.get(params.password);
if (passwordErr) return rej('invalid password param');

View File

@ -1,11 +1,8 @@
/**
* Module dependencies
*/
import $ from 'cafy';
import * as bcrypt from 'bcryptjs';
import User from '../../../../../models/user';
import User, { ILocalUser } from '../../../../../models/user';
module.exports = async (params, user) => new Promise(async (res, rej) => {
module.exports = async (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
// Get 'password' parameter
const [password, passwordErr] = $.str.get(params.password);
if (passwordErr) return rej('invalid password param');

View File

@ -1,14 +1,12 @@
/**
* Module dependencies
*/
import $ from 'cafy';
import AccessToken from '../../../../models/access-token';
import { pack } from '../../../../models/app';
import { ILocalUser } from '../../../../models/user';
/**
* Get authorized apps of my account
*/
module.exports = (params, user) => new Promise(async (res, rej) => {
module.exports = (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
// Get 'limit' parameter
const [limit = 10, limitErr] = $.num.optional().range(1, 100).get(params.limit);
if (limitErr) return rej('invalid limit param');

View File

@ -1,14 +1,11 @@
/**
* Module dependencies
*/
import $ from 'cafy';
import * as bcrypt from 'bcryptjs';
import User from '../../../../models/user';
import User, { ILocalUser } from '../../../../models/user';
/**
* Change password
*/
module.exports = async (params, user) => new Promise(async (res, rej) => {
module.exports = async (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
// Get 'currentPasword' parameter
const [currentPassword, currentPasswordErr] = $.str.get(params.currentPasword);
if (currentPasswordErr) return rej('invalid currentPasword param');

View File

@ -1,13 +1,11 @@
/**
* Module dependencies
*/
import $ from 'cafy'; import ID from '../../../../cafy-id';
import Favorite, { pack } from '../../../../models/favorite';
import { ILocalUser } from '../../../../models/user';
/**
* Get favorited notes
*/
module.exports = (params, user) => new Promise(async (res, rej) => {
module.exports = (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
// Get 'limit' parameter
const [limit = 10, limitErr] = $.num.optional().range(1, 100).get(params.limit);
if (limitErr) return rej('invalid limit param');

View File

@ -1,17 +1,15 @@
/**
* Module dependencies
*/
import $ from 'cafy'; import ID from '../../../../cafy-id';
import Notification from '../../../../models/notification';
import Mute from '../../../../models/mute';
import { pack } from '../../../../models/notification';
import { getFriendIds } from '../../common/get-friends';
import read from '../../common/read-notification';
import { ILocalUser } from '../../../../models/user';
/**
* Get notifications
*/
module.exports = (params, user) => new Promise(async (res, rej) => {
module.exports = (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
// Get 'following' parameter
const [following = false, followingError] =
$.bool.optional().get(params.following);

View File

@ -1,15 +1,12 @@
/**
* Module dependencies
*/
import $ from 'cafy'; import ID from '../../../../cafy-id';
import User from '../../../../models/user';
import User, { ILocalUser } from '../../../../models/user';
import Note from '../../../../models/note';
import { pack } from '../../../../models/user';
/**
* Pin note
*/
module.exports = async (params, user) => new Promise(async (res, rej) => {
module.exports = async (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
// Get 'noteId' parameter
const [noteId, noteIdErr] = $.type(ID).get(params.noteId);
if (noteIdErr) return rej('invalid noteId param');

View File

@ -1,16 +1,13 @@
/**
* Module dependencies
*/
import $ from 'cafy';
import * as bcrypt from 'bcryptjs';
import User from '../../../../models/user';
import User, { ILocalUser } from '../../../../models/user';
import event from '../../../../publishers/stream';
import generateUserToken from '../../common/generate-native-user-token';
/**
* Regenerate native token
*/
module.exports = async (params, user) => new Promise(async (res, rej) => {
module.exports = async (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
// Get 'password' parameter
const [password, passwordErr] = $.str.get(params.password);
if (passwordErr) return rej('invalid password param');

View File

@ -1,13 +1,11 @@
/**
* Module dependencies
*/
import $ from 'cafy'; import ID from '../../../../cafy-id';
import Signin, { pack } from '../../../../models/signin';
import { ILocalUser } from '../../../../models/user';
/**
* Get signin history of my account
*/
module.exports = (params, user) => new Promise(async (res, rej) => {
module.exports = (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
// Get 'limit' parameter
const [limit = 10, limitErr] = $.num.optional().range(1, 100).get(params.limit);
if (limitErr) return rej('invalid limit param');

View File

@ -1,16 +1,14 @@
/**
* Module dependencies
*/
import $ from 'cafy'; import ID from '../../../../cafy-id';
import User, { isValidName, isValidDescription, isValidLocation, isValidBirthday, pack } from '../../../../models/user';
import User, { isValidName, isValidDescription, isValidLocation, isValidBirthday, pack, ILocalUser } from '../../../../models/user';
import event from '../../../../publishers/stream';
import DriveFile from '../../../../models/drive-file';
import acceptAllFollowRequests from '../../../../services/following/requests/accept-all';
import { IApp } from '../../../../models/app';
/**
* Update myself
*/
module.exports = async (params, user, app) => new Promise(async (res, rej) => {
module.exports = async (params: any, user: ILocalUser, app: IApp) => new Promise(async (res, rej) => {
const isSecure = user != null && app == null;
const updates = {} as any;

View File

@ -1,14 +1,11 @@
/**
* Module dependencies
*/
import $ from 'cafy';
import User from '../../../../models/user';
import User, { ILocalUser } from '../../../../models/user';
import event from '../../../../publishers/stream';
/**
* Update myself
*/
module.exports = async (params, user) => new Promise(async (res, rej) => {
module.exports = async (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
// Get 'name' parameter
const [name, nameErr] = $.str.get(params.name);
if (nameErr) return rej('invalid name param');
@ -17,7 +14,7 @@ module.exports = async (params, user) => new Promise(async (res, rej) => {
const [value, valueErr] = $.any.nullable().get(params.value);
if (valueErr) return rej('invalid value param');
const x = {};
const x: any = {};
x[`clientSettings.${name}`] = value;
await User.update(user._id, {

View File

@ -1,8 +1,8 @@
import $ from 'cafy';
import User from '../../../../models/user';
import User, { ILocalUser } from '../../../../models/user';
import event from '../../../../publishers/stream';
module.exports = async (params, user) => new Promise(async (res, rej) => {
module.exports = async (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
// Get 'home' parameter
const [home, homeErr] = $.arr(
$.obj.strict()

View File

@ -1,8 +1,8 @@
import $ from 'cafy';
import User from '../../../../models/user';
import User, { ILocalUser } from '../../../../models/user';
import event from '../../../../publishers/stream';
module.exports = async (params, user) => new Promise(async (res, rej) => {
module.exports = async (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
// Get 'home' parameter
const [home, homeErr] = $.arr(
$.obj.strict()

View File

@ -1,8 +1,8 @@
import $ from 'cafy';
import User from '../../../../models/user';
import User, { ILocalUser } from '../../../../models/user';
import event from '../../../../publishers/stream';
module.exports = async (params, user) => new Promise(async (res, rej) => {
module.exports = async (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
// Get 'id' parameter
const [id, idErr] = $.str.get(params.id);
if (idErr) return rej('invalid id param');
@ -18,7 +18,7 @@ module.exports = async (params, user) => new Promise(async (res, rej) => {
//#region Desktop home
if (widget == null && user.clientSettings.home) {
const desktopHome = user.clientSettings.home;
widget = desktopHome.find(w => w.id == id);
widget = desktopHome.find((w: any) => w.id == id);
if (widget) {
widget.data = data;
@ -34,7 +34,7 @@ module.exports = async (params, user) => new Promise(async (res, rej) => {
//#region Mobile home
if (widget == null && user.clientSettings.mobileHome) {
const mobileHome = user.clientSettings.mobileHome;
widget = mobileHome.find(w => w.id == id);
widget = mobileHome.find((w: any) => w.id == id);
if (widget) {
widget.data = data;
@ -50,8 +50,8 @@ module.exports = async (params, user) => new Promise(async (res, rej) => {
//#region Deck
if (widget == null && user.clientSettings.deck && user.clientSettings.deck.columns) {
const deck = user.clientSettings.deck;
deck.columns.filter(c => c.type == 'widgets').forEach(c => {
c.widgets.forEach(w => {
deck.columns.filter((c: any) => c.type == 'widgets').forEach((c: any) => {
c.widgets.forEach((w: any) => {
if (w.id == id) widget = w;
});
});

View File

@ -1,15 +1,13 @@
/**
* Module dependencies
*/
import $ from 'cafy';
import History from '../../../../models/messaging-history';
import Mute from '../../../../models/mute';
import { pack } from '../../../../models/messaging-message';
import { ILocalUser } from '../../../../models/user';
/**
* Show messaging history
*/
module.exports = (params, user) => new Promise(async (res, rej) => {
module.exports = (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
// Get 'limit' parameter
const [limit = 10, limitErr] = $.num.optional().range(1, 100).get(params.limit);
if (limitErr) return rej('invalid limit param');

View File

@ -1,13 +1,13 @@
import $ from 'cafy'; import ID from '../../../../cafy-id';
import Message from '../../../../models/messaging-message';
import User from '../../../../models/user';
import User, { ILocalUser } from '../../../../models/user';
import { pack } from '../../../../models/messaging-message';
import read from '../../common/read-messaging-message';
/**
* Get messages
*/
module.exports = (params, user) => new Promise(async (res, rej) => {
module.exports = (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
// Get 'userId' parameter
const [recipientId, recipientIdErr] = $.type(ID).get(params.userId);
if (recipientIdErr) return rej('invalid userId param');

View File

@ -1,11 +1,8 @@
/**
* Module dependencies
*/
import $ from 'cafy'; import ID from '../../../../../cafy-id';
import Message from '../../../../../models/messaging-message';
import { isValidText } from '../../../../../models/messaging-message';
import History from '../../../../../models/messaging-history';
import User from '../../../../../models/user';
import User, { ILocalUser } from '../../../../../models/user';
import Mute from '../../../../../models/mute';
import DriveFile from '../../../../../models/drive-file';
import { pack } from '../../../../../models/messaging-message';
@ -17,7 +14,7 @@ import config from '../../../../../config';
/**
* Create a message
*/
module.exports = (params, user) => new Promise(async (res, rej) => {
module.exports = (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
// Get 'userId' parameter
const [recipientId, recipientIdErr] = $.type(ID).get(params.userId);
if (recipientIdErr) return rej('invalid userId param');

View File

@ -38,7 +38,7 @@ const client = require('../../../../built/client/meta.json');
/**
* Show core info
*/
module.exports = (params) => new Promise(async (res, rej) => {
module.exports = (params: any) => new Promise(async (res, rej) => {
const meta: any = (await Meta.findOne()) || {};
res({

View File

@ -1,14 +1,11 @@
/**
* Module dependencies
*/
import $ from 'cafy'; import ID from '../../../../cafy-id';
import User from '../../../../models/user';
import User, { ILocalUser } from '../../../../models/user';
import Mute from '../../../../models/mute';
/**
* Mute a user
*/
module.exports = (params, user) => new Promise(async (res, rej) => {
module.exports = (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
const muter = user;
// Get 'userId' parameter

View File

@ -1,14 +1,11 @@
/**
* Module dependencies
*/
import $ from 'cafy'; import ID from '../../../../cafy-id';
import User from '../../../../models/user';
import User, { ILocalUser } from '../../../../models/user';
import Mute from '../../../../models/mute';
/**
* Unmute a user
*/
module.exports = (params, user) => new Promise(async (res, rej) => {
module.exports = (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
const muter = user;
// Get 'userId' parameter

View File

@ -1,15 +1,12 @@
/**
* Module dependencies
*/
import $ from 'cafy'; import ID from '../../../../cafy-id';
import Mute from '../../../../models/mute';
import { pack } from '../../../../models/user';
import { pack, ILocalUser } from '../../../../models/user';
import { getFriendIds } from '../../common/get-friends';
/**
* Get muted users of a user
*/
module.exports = (params, me) => new Promise(async (res, rej) => {
module.exports = (params: any, me: ILocalUser) => new Promise(async (res, rej) => {
// Get 'iknow' parameter
const [iknow = false, iknowErr] = $.bool.optional().get(params.iknow);
if (iknowErr) return rej('invalid iknow param');

View File

@ -1,13 +1,11 @@
/**
* Module dependencies
*/
import $ from 'cafy';
import App, { pack } from '../../../../models/app';
import { ILocalUser } from '../../../../models/user';
/**
* Get my apps
*/
module.exports = (params, user) => new Promise(async (res, rej) => {
module.exports = (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
// Get 'limit' parameter
const [limit = 10, limitErr] = $.num.optional().range(1, 100).get(params.limit);
if (limitErr) return rej('invalid limit param');

View File

@ -7,7 +7,7 @@ import Note, { pack } from '../../../models/note';
/**
* Get all notes
*/
module.exports = (params) => new Promise(async (res, rej) => {
module.exports = (params: any) => new Promise(async (res, rej) => {
// Get 'local' parameter
const [local, localErr] = $.bool.optional().get(params.local);
if (localErr) return rej('invalid local param');

View File

@ -1,13 +1,11 @@
/**
* Module dependencies
*/
import $ from 'cafy'; import ID from '../../../../cafy-id';
import Note, { pack } from '../../../../models/note';
import Note, { pack, INote } from '../../../../models/note';
import { ILocalUser } from '../../../../models/user';
/**
* Show conversation of a note
*/
module.exports = (params, user) => new Promise(async (res, rej) => {
module.exports = (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
// Get 'noteId' parameter
const [noteId, noteIdErr] = $.type(ID).get(params.noteId);
if (noteIdErr) return rej('invalid noteId param');
@ -29,10 +27,10 @@ module.exports = (params, user) => new Promise(async (res, rej) => {
return rej('note not found');
}
const conversation = [];
const conversation: INote[] = [];
let i = 0;
async function get(id) {
async function get(id: any) {
i++;
const p = await Note.findOne({ _id: id });

View File

@ -1,9 +1,6 @@
/**
* Module dependencies
*/
import $ from 'cafy'; import ID from '../../../../cafy-id';
import Note, { INote, isValidText, isValidCw, pack } from '../../../../models/note';
import User, { ILocalUser } from '../../../../models/user';
import User, { ILocalUser, IUser } from '../../../../models/user';
import DriveFile from '../../../../models/drive-file';
import create from '../../../../services/note/create';
import { IApp } from '../../../../models/app';
@ -11,7 +8,7 @@ import { IApp } from '../../../../models/app';
/**
* Create a note
*/
module.exports = (params, user: ILocalUser, app: IApp) => new Promise(async (res, rej) => {
module.exports = (params: any, user: ILocalUser, app: IApp) => new Promise(async (res, rej) => {
// Get 'visibility' parameter
const [visibility = 'public', visibilityErr] = $.str.optional().or(['public', 'home', 'followers', 'specified', 'private']).get(params.visibility);
if (visibilityErr) return rej('invalid visibility');
@ -20,7 +17,7 @@ module.exports = (params, user: ILocalUser, app: IApp) => new Promise(async (res
const [visibleUserIds, visibleUserIdsErr] = $.arr($.type(ID)).optional().unique().min(1).get(params.visibleUserIds);
if (visibleUserIdsErr) return rej('invalid visibleUserIds');
let visibleUsers = [];
let visibleUsers: IUser[] = [];
if (visibleUserIds !== undefined) {
visibleUsers = await Promise.all(visibleUserIds.map(id => User.findOne({
_id: id
@ -132,7 +129,7 @@ module.exports = (params, user: ILocalUser, app: IApp) => new Promise(async (res
if (pollErr) return rej('invalid poll');
if (poll) {
(poll as any).choices = (poll as any).choices.map((choice, i) => ({
(poll as any).choices = (poll as any).choices.map((choice: string, i: number) => ({
id: i, // IDを付与
text: choice.trim(),
votes: 0

View File

@ -1,11 +1,12 @@
import $ from 'cafy'; import ID from '../../../../cafy-id';
import Note from '../../../../models/note';
import deleteNote from '../../../../services/note/delete';
import { ILocalUser } from '../../../../models/user';
/**
* Delete a note
*/
module.exports = (params, user) => new Promise(async (res, rej) => {
module.exports = (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
// Get 'noteId' parameter
const [noteId, noteIdErr] = $.type(ID).get(params.noteId);
if (noteIdErr) return rej('invalid noteId param');

View File

@ -1,14 +1,12 @@
/**
* Module dependencies
*/
import $ from 'cafy'; import ID from '../../../../../cafy-id';
import Favorite from '../../../../../models/favorite';
import Note from '../../../../../models/note';
import { ILocalUser } from '../../../../../models/user';
/**
* Favorite a note
*/
module.exports = (params, user) => new Promise(async (res, rej) => {
module.exports = (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
// Get 'noteId' parameter
const [noteId, noteIdErr] = $.type(ID).get(params.noteId);
if (noteIdErr) return rej('invalid noteId param');

View File

@ -1,14 +1,12 @@
/**
* Module dependencies
*/
import $ from 'cafy'; import ID from '../../../../../cafy-id';
import Favorite from '../../../../../models/favorite';
import Note from '../../../../../models/note';
import { ILocalUser } from '../../../../../models/user';
/**
* Unfavorite a note
*/
module.exports = (params, user) => new Promise(async (res, rej) => {
module.exports = (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
// Get 'noteId' parameter
const [noteId, noteIdErr] = $.type(ID).get(params.noteId);
if (noteIdErr) return rej('invalid noteId param');

View File

@ -1,15 +1,13 @@
/**
* Module dependencies
*/
import $ from 'cafy'; import ID from '../../../../cafy-id';
import Note from '../../../../models/note';
import Mute from '../../../../models/mute';
import { pack } from '../../../../models/note';
import { ILocalUser } from '../../../../models/user';
/**
* Get timeline of global
*/
module.exports = async (params, user) => {
module.exports = async (params: any, user: ILocalUser) => {
// Get 'limit' parameter
const [limit = 10, limitErr] = $.num.optional().range(1, 100).get(params.limit);
if (limitErr) throw 'invalid limit param';

View File

@ -1,15 +1,13 @@
/**
* Module dependencies
*/
import $ from 'cafy'; import ID from '../../../../cafy-id';
import Note from '../../../../models/note';
import Mute from '../../../../models/mute';
import { pack } from '../../../../models/note';
import { ILocalUser } from '../../../../models/user';
/**
* Get timeline of local
*/
module.exports = async (params, user) => {
module.exports = async (params: any, user: ILocalUser) => {
// Get 'limit' parameter
const [limit = 10, limitErr] = $.num.optional().range(1, 100).get(params.limit);
if (limitErr) throw 'invalid limit param';

View File

@ -1,19 +1,13 @@
/**
* Module dependencies
*/
import $ from 'cafy'; import ID from '../../../../cafy-id';
import Note from '../../../../models/note';
import { getFriendIds } from '../../common/get-friends';
import { pack } from '../../../../models/note';
import { ILocalUser } from '../../../../models/user';
/**
* Get mentions of myself
*
* @param {any} params
* @param {any} user
* @return {Promise<any>}
*/
module.exports = (params, user) => new Promise(async (res, rej) => {
module.exports = (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
// Get 'following' parameter
const [following = false, followingError] =
$.bool.optional().get(params.following);

View File

@ -1,14 +1,12 @@
/**
* Module dependencies
*/
import $ from 'cafy';
import Vote from '../../../../../models/poll-vote';
import Note, { pack } from '../../../../../models/note';
import { ILocalUser } from '../../../../../models/user';
/**
* Get recommended polls
*/
module.exports = (params, user) => new Promise(async (res, rej) => {
module.exports = (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
// Get 'limit' parameter
const [limit = 10, limitErr] = $.num.optional().range(1, 100).get(params.limit);
if (limitErr) return rej('invalid limit param');

View File

@ -1,6 +1,3 @@
/**
* Module dependencies
*/
import $ from 'cafy'; import ID from '../../../../../cafy-id';
import Vote from '../../../../../models/poll-vote';
import Note from '../../../../../models/note';
@ -8,11 +5,12 @@ import Watching from '../../../../../models/note-watching';
import watch from '../../../../../services/note/watch';
import { publishNoteStream } from '../../../../../publishers/stream';
import notify from '../../../../../publishers/notify';
import { ILocalUser } from '../../../../../models/user';
/**
* Vote poll of a note
*/
module.exports = (params, user) => new Promise(async (res, rej) => {
module.exports = (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
// Get 'noteId' parameter
const [noteId, noteIdErr] = $.type(ID).get(params.noteId);
if (noteIdErr) return rej('invalid noteId param');
@ -58,8 +56,8 @@ module.exports = (params, user) => new Promise(async (res, rej) => {
// Send response
res();
const inc = {};
inc[`poll.choices.${findWithAttr(note.poll.choices, 'id', choice)}.votes`] = 1;
const inc: any = {};
inc[`poll.choices.${note.poll.choices.findIndex(c => c.id == choice)}.votes`] = 1;
// Increment votes count
await Note.update({ _id: note._id }, {
@ -100,12 +98,3 @@ module.exports = (params, user) => new Promise(async (res, rej) => {
watch(user._id, note);
}
});
function findWithAttr(array, attr, value) {
for (let i = 0; i < array.length; i += 1) {
if (array[i][attr] === value) {
return i;
}
}
return -1;
}

View File

@ -1,18 +1,12 @@
/**
* Module dependencies
*/
import $ from 'cafy'; import ID from '../../../../cafy-id';
import Note from '../../../../models/note';
import Reaction, { pack } from '../../../../models/note-reaction';
import { ILocalUser } from '../../../../models/user';
/**
* Show reactions of a note
*
* @param {any} params
* @param {any} user
* @return {Promise<any>}
*/
module.exports = (params, user) => new Promise(async (res, rej) => {
module.exports = (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
// Get 'noteId' parameter
const [noteId, noteIdErr] = $.type(ID).get(params.noteId);
if (noteIdErr) return rej('invalid noteId param');

View File

@ -1,15 +1,13 @@
/**
* Module dependencies
*/
import $ from 'cafy'; import ID from '../../../../../cafy-id';
import Note from '../../../../../models/note';
import create from '../../../../../services/note/reaction/create';
import { validateReaction } from '../../../../../models/note-reaction';
import { ILocalUser } from '../../../../../models/user';
/**
* React to a note
*/
module.exports = (params, user) => new Promise(async (res, rej) => {
module.exports = (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
// Get 'noteId' parameter
const [noteId, noteIdErr] = $.type(ID).get(params.noteId);
if (noteIdErr) return rej('invalid noteId param');

View File

@ -1,14 +1,12 @@
/**
* Module dependencies
*/
import $ from 'cafy'; import ID from '../../../../../cafy-id';
import Reaction from '../../../../../models/note-reaction';
import Note from '../../../../../models/note';
import { ILocalUser } from '../../../../../models/user';
/**
* Unreact to a note
*/
module.exports = (params, user) => new Promise(async (res, rej) => {
module.exports = (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
// Get 'noteId' parameter
const [noteId, noteIdErr] = $.type(ID).get(params.noteId);
if (noteIdErr) return rej('invalid noteId param');
@ -45,7 +43,7 @@ module.exports = (params, user) => new Promise(async (res, rej) => {
// Send response
res();
const dec = {};
const dec: any = {};
dec[`reactionCounts.${exist.reaction}`] = -1;
// Decrement reactions count

View File

@ -1,10 +1,11 @@
import $ from 'cafy'; import ID from '../../../../cafy-id';
import Note, { pack } from '../../../../models/note';
import { ILocalUser } from '../../../../models/user';
/**
* Get replies of a note
*/
module.exports = (params, user) => new Promise(async (res, rej) => {
module.exports = (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
// Get 'noteId' parameter
const [noteId, noteIdErr] = $.type(ID).get(params.noteId);
if (noteIdErr) return rej('invalid noteId param');

View File

@ -1,17 +1,11 @@
/**
* Module dependencies
*/
import $ from 'cafy'; import ID from '../../../../cafy-id';
import Note, { pack } from '../../../../models/note';
import { ILocalUser } from '../../../../models/user';
/**
* Show a renotes of a note
*
* @param {any} params
* @param {any} user
* @return {Promise<any>}
*/
module.exports = (params, user) => new Promise(async (res, rej) => {
module.exports = (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
// Get 'noteId' parameter
const [noteId, noteIdErr] = $.type(ID).get(params.noteId);
if (noteIdErr) return rej('invalid noteId param');

View File

@ -1,364 +0,0 @@
/**
* Module dependencies
*/
import $ from 'cafy'; import ID from '../../../../cafy-id';
const escapeRegexp = require('escape-regexp');
import Note from '../../../../models/note';
import User from '../../../../models/user';
import Mute from '../../../../models/mute';
import { getFriendIds } from '../../common/get-friends';
import { pack } from '../../../../models/note';
/**
* Search a note
*
* @param {any} params
* @param {any} me
* @return {Promise<any>}
*/
module.exports = (params, me) => new Promise(async (res, rej) => {
// Get 'text' parameter
const [text, textError] = $.str.optional().get(params.text);
if (textError) return rej('invalid text param');
// Get 'includeUserIds' parameter
const [includeUserIds = [], includeUserIdsErr] = $.arr($.type(ID)).optional().get(params.includeUserIds);
if (includeUserIdsErr) return rej('invalid includeUserIds param');
// Get 'excludeUserIds' parameter
const [excludeUserIds = [], excludeUserIdsErr] = $.arr($.type(ID)).optional().get(params.excludeUserIds);
if (excludeUserIdsErr) return rej('invalid excludeUserIds param');
// Get 'includeUserUsernames' parameter
const [includeUserUsernames = [], includeUserUsernamesErr] = $.arr($.str).optional().get(params.includeUserUsernames);
if (includeUserUsernamesErr) return rej('invalid includeUserUsernames param');
// Get 'excludeUserUsernames' parameter
const [excludeUserUsernames = [], excludeUserUsernamesErr] = $.arr($.str).optional().get(params.excludeUserUsernames);
if (excludeUserUsernamesErr) return rej('invalid excludeUserUsernames param');
// Get 'following' parameter
const [following = null, followingErr] = $.bool.optional().nullable().get(params.following);
if (followingErr) return rej('invalid following param');
// Get 'mute' parameter
const [mute = 'mute_all', muteErr] = $.str.optional().get(params.mute);
if (muteErr) return rej('invalid mute param');
// Get 'reply' parameter
const [reply = null, replyErr] = $.bool.optional().nullable().get(params.reply);
if (replyErr) return rej('invalid reply param');
// Get 'renote' parameter
const [renote = null, renoteErr] = $.bool.optional().nullable().get(params.renote);
if (renoteErr) return rej('invalid renote param');
// Get 'media' parameter
const [media = null, mediaErr] = $.bool.optional().nullable().get(params.media);
if (mediaErr) return rej('invalid media param');
// Get 'poll' parameter
const [poll = null, pollErr] = $.bool.optional().nullable().get(params.poll);
if (pollErr) return rej('invalid poll param');
// Get 'sinceDate' parameter
const [sinceDate, sinceDateErr] = $.num.optional().get(params.sinceDate);
if (sinceDateErr) throw 'invalid sinceDate param';
// Get 'untilDate' parameter
const [untilDate, untilDateErr] = $.num.optional().get(params.untilDate);
if (untilDateErr) throw 'invalid untilDate param';
// Get 'offset' parameter
const [offset = 0, offsetErr] = $.num.optional().min(0).get(params.offset);
if (offsetErr) return rej('invalid offset param');
// Get 'limit' parameter
const [limit = 10, limitErr] = $.num.optional().range(1, 30).get(params.limit);
if (limitErr) return rej('invalid limit param');
let includeUsers = includeUserIds;
if (includeUserUsernames != null) {
const ids = (await Promise.all(includeUserUsernames.map(async (username) => {
const _user = await User.findOne({
usernameLower: username.toLowerCase()
});
return _user ? _user._id : null;
}))).filter(id => id != null);
includeUsers = includeUsers.concat(ids);
}
let excludeUsers = excludeUserIds;
if (excludeUserUsernames != null) {
const ids = (await Promise.all(excludeUserUsernames.map(async (username) => {
const _user = await User.findOne({
usernameLower: username.toLowerCase()
});
return _user ? _user._id : null;
}))).filter(id => id != null);
excludeUsers = excludeUsers.concat(ids);
}
search(res, rej, me, text, includeUsers, excludeUsers, following,
mute, reply, renote, media, poll, sinceDate, untilDate, offset, limit);
});
async function search(
res, rej, me, text, includeUserIds, excludeUserIds, following,
mute, reply, renote, media, poll, sinceDate, untilDate, offset, max) {
let q: any = {
$and: []
};
const push = x => q.$and.push(x);
if (text) {
// 完全一致検索
if (/"""(.+?)"""/.test(text)) {
const x = text.match(/"""(.+?)"""/)[1];
push({
text: x
});
} else {
const tags = text.split(' ').filter(x => x[0] == '#');
if (tags) {
push({
$and: tags.map(x => ({
tags: x
}))
});
}
push({
$and: text.split(' ').map(x => ({
// キーワードが-で始まる場合そのキーワードを除外する
text: x[0] == '-' ? {
$not: new RegExp(escapeRegexp(x.substr(1)))
} : new RegExp(escapeRegexp(x))
}))
});
}
}
if (includeUserIds && includeUserIds.length != 0) {
push({
userId: {
$in: includeUserIds
}
});
} else if (excludeUserIds && excludeUserIds.length != 0) {
push({
userId: {
$nin: excludeUserIds
}
});
}
if (following != null && me != null) {
const ids = await getFriendIds(me._id, false);
push({
userId: following ? {
$in: ids
} : {
$nin: ids.concat(me._id)
}
});
}
if (me != null) {
const mutes = await Mute.find({
muterId: me._id,
deletedAt: { $exists: false }
});
const mutedUserIds = mutes.map(m => m.muteeId);
switch (mute) {
case 'mute_all':
push({
userId: {
$nin: mutedUserIds
},
'_reply.userId': {
$nin: mutedUserIds
},
'_renote.userId': {
$nin: mutedUserIds
}
});
break;
case 'mute_related':
push({
'_reply.userId': {
$nin: mutedUserIds
},
'_renote.userId': {
$nin: mutedUserIds
}
});
break;
case 'mute_direct':
push({
userId: {
$nin: mutedUserIds
}
});
break;
case 'direct_only':
push({
userId: {
$in: mutedUserIds
}
});
break;
case 'related_only':
push({
$or: [{
'_reply.userId': {
$in: mutedUserIds
}
}, {
'_renote.userId': {
$in: mutedUserIds
}
}]
});
break;
case 'all_only':
push({
$or: [{
userId: {
$in: mutedUserIds
}
}, {
'_reply.userId': {
$in: mutedUserIds
}
}, {
'_renote.userId': {
$in: mutedUserIds
}
}]
});
break;
}
}
if (reply != null) {
if (reply) {
push({
replyId: {
$exists: true,
$ne: null
}
});
} else {
push({
$or: [{
replyId: {
$exists: false
}
}, {
replyId: null
}]
});
}
}
if (renote != null) {
if (renote) {
push({
renoteId: {
$exists: true,
$ne: null
}
});
} else {
push({
$or: [{
renoteId: {
$exists: false
}
}, {
renoteId: null
}]
});
}
}
if (media != null) {
if (media) {
push({
mediaIds: {
$exists: true,
$ne: null
}
});
} else {
push({
$or: [{
mediaIds: {
$exists: false
}
}, {
mediaIds: null
}]
});
}
}
if (poll != null) {
if (poll) {
push({
poll: {
$exists: true,
$ne: null
}
});
} else {
push({
$or: [{
poll: {
$exists: false
}
}, {
poll: null
}]
});
}
}
if (sinceDate) {
push({
createdAt: {
$gt: new Date(sinceDate)
}
});
}
if (untilDate) {
push({
createdAt: {
$lt: new Date(untilDate)
}
});
}
if (q.$and.length == 0) {
q = {};
}
// Search notes
const notes = await Note
.find(q, {
sort: {
_id: -1
},
limit: max,
skip: offset
});
// Serialize
res(await Promise.all(notes.map(async note =>
await pack(note, me))));
}

View File

@ -1,6 +1,6 @@
import $ from 'cafy'; import ID from '../../../../cafy-id';
import Note from '../../../../models/note';
import User from '../../../../models/user';
import User, { ILocalUser } from '../../../../models/user';
import Mute from '../../../../models/mute';
import { getFriendIds } from '../../common/get-friends';
import { pack } from '../../../../models/note';
@ -8,7 +8,7 @@ import { pack } from '../../../../models/note';
/**
* Search notes by tag
*/
module.exports = (params, me) => new Promise(async (res, rej) => {
module.exports = (params: any, me: ILocalUser) => new Promise(async (res, rej) => {
// Get 'tag' parameter
const [tag, tagError] = $.str.get(params.tag);
if (tagError) return rej('invalid tag param');
@ -69,7 +69,6 @@ module.exports = (params, me) => new Promise(async (res, rej) => {
const [limit = 10, limitErr] = $.num.optional().range(1, 30).get(params.limit);
if (limitErr) return rej('invalid limit param');
let includeUsers = includeUserIds;
if (includeUserUsernames != null) {
const ids = (await Promise.all(includeUserUsernames.map(async (username) => {
const _user = await User.findOne({
@ -77,10 +76,10 @@ module.exports = (params, me) => new Promise(async (res, rej) => {
});
return _user ? _user._id : null;
}))).filter(id => id != null);
includeUsers = includeUsers.concat(ids);
ids.forEach(id => includeUserIds.push(id));
}
let excludeUsers = excludeUserIds;
if (excludeUserUsernames != null) {
const ids = (await Promise.all(excludeUserUsernames.map(async (username) => {
const _user = await User.findOne({
@ -88,24 +87,17 @@ module.exports = (params, me) => new Promise(async (res, rej) => {
});
return _user ? _user._id : null;
}))).filter(id => id != null);
excludeUsers = excludeUsers.concat(ids);
ids.forEach(id => excludeUserIds.push(id));
}
search(res, rej, me, tag, includeUsers, excludeUsers, following,
mute, reply, renote, media, poll, sinceDate, untilDate, offset, limit);
});
async function search(
res, rej, me, tag, includeUserIds, excludeUserIds, following,
mute, reply, renote, media, poll, sinceDate, untilDate, offset, max) {
let q: any = {
$and: [{
tagsLower: tag.toLowerCase()
}]
};
const push = x => q.$and.push(x);
const push = (x: any) => q.$and.push(x);
if (includeUserIds && includeUserIds.length != 0) {
push({
@ -320,10 +312,10 @@ async function search(
sort: {
_id: -1
},
limit: max,
limit: limit,
skip: offset
});
// Serialize
res(await Promise.all(notes.map(note => pack(note, me))));
}
});

View File

@ -1,17 +1,11 @@
/**
* Module dependencies
*/
import $ from 'cafy'; import ID from '../../../../cafy-id';
import Note, { pack } from '../../../../models/note';
import { ILocalUser } from '../../../../models/user';
/**
* Show a note
*
* @param {any} params
* @param {any} user
* @return {Promise<any>}
*/
module.exports = (params, user) => new Promise(async (res, rej) => {
module.exports = (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
// Get 'noteId' parameter
const [noteId, noteIdErr] = $.type(ID).get(params.noteId);
if (noteIdErr) return rej('invalid noteId param');

View File

@ -1,16 +1,14 @@
/**
* Module dependencies
*/
import $ from 'cafy'; import ID from '../../../../cafy-id';
import Note from '../../../../models/note';
import Mute from '../../../../models/mute';
import { getFriends } from '../../common/get-friends';
import { pack } from '../../../../models/note';
import { ILocalUser } from '../../../../models/user';
/**
* Get timeline of myself
*/
module.exports = async (params, user, app) => {
module.exports = async (params: any, user: ILocalUser) => {
// Get 'limit' parameter
const [limit = 10, limitErr] = $.num.optional().range(1, 100).get(params.limit);
if (limitErr) throw 'invalid limit param';

View File

@ -1,18 +1,12 @@
/**
* Module dependencies
*/
const ms = require('ms');
import $ from 'cafy';
import Note, { pack } from '../../../../models/note';
import { ILocalUser } from '../../../../models/user';
/**
* Get trend notes
*
* @param {any} params
* @param {any} user
* @return {Promise<any>}
*/
module.exports = (params, user) => new Promise(async (res, rej) => {
module.exports = (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
// Get 'limit' parameter
const [limit = 10, limitErr] = $.num.optional().range(1, 100).get(params.limit);
if (limitErr) return rej('invalid limit param');

View File

@ -1,16 +1,14 @@
/**
* Module dependencies
*/
import $ from 'cafy'; import ID from '../../../../cafy-id';
import Note from '../../../../models/note';
import Mute from '../../../../models/mute';
import { pack } from '../../../../models/note';
import UserList from '../../../../models/user-list';
import { ILocalUser } from '../../../../models/user';
/**
* Get timeline of a user list
*/
module.exports = async (params, user, app) => {
module.exports = async (params: any, user: ILocalUser) => {
// Get 'limit' parameter
const [limit = 10, limitErr] = $.num.optional().range(1, 100).get(params.limit);
if (limitErr) throw 'invalid limit param';

View File

@ -1,11 +1,11 @@
import Notification from '../../../../models/notification';
import event from '../../../../publishers/stream';
import User from '../../../../models/user';
import User, { ILocalUser } from '../../../../models/user';
/**
* Mark as read all notifications
*/
module.exports = (params, user) => new Promise(async (res, rej) => {
module.exports = (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
// Update documents
await Notification.update({
notifieeId: user._id,

View File

@ -1,7 +1,8 @@
import $ from 'cafy'; import ID from '../../../../cafy-id';
import ReversiGame, { pack } from '../../../../models/reversi-game';
import { ILocalUser } from '../../../../models/user';
module.exports = (params, user) => new Promise(async (res, rej) => {
module.exports = (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
// Get 'my' parameter
const [my = false, myErr] = $.bool.optional().get(params.my);
if (myErr) return rej('invalid my param');

View File

@ -1,8 +1,9 @@
import $ from 'cafy'; import ID from '../../../../../cafy-id';
import ReversiGame, { pack } from '../../../../../models/reversi-game';
import Reversi from '../../../../../reversi/core';
import { ILocalUser } from '../../../../../models/user';
module.exports = (params, user) => new Promise(async (res, rej) => {
module.exports = (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
// Get 'gameId' parameter
const [gameId, gameIdErr] = $.type(ID).get(params.gameId);
if (gameIdErr) return rej('invalid gameId param');

View File

@ -1,6 +1,7 @@
import Matching, { pack as packMatching } from '../../../../models/reversi-matching';
import { ILocalUser } from '../../../../models/user';
module.exports = (params, user) => new Promise(async (res, rej) => {
module.exports = (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
// Find session
const invitations = await Matching.find({
childId: user._id

View File

@ -1,11 +1,11 @@
import $ from 'cafy'; import ID from '../../../../cafy-id';
import Matching, { pack as packMatching } from '../../../../models/reversi-matching';
import ReversiGame, { pack as packGame } from '../../../../models/reversi-game';
import User from '../../../../models/user';
import User, { ILocalUser } from '../../../../models/user';
import publishUserStream, { publishReversiStream } from '../../../../publishers/stream';
import { eighteight } from '../../../../reversi/maps';
module.exports = (params, user) => new Promise(async (res, rej) => {
module.exports = (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
// Get 'userId' parameter
const [childId, childIdErr] = $.type(ID).get(params.userId);
if (childIdErr) return rej('invalid userId param');

View File

@ -1,6 +1,7 @@
import Matching from '../../../../../models/reversi-matching';
import { ILocalUser } from '../../../../../models/user';
module.exports = (params, user) => new Promise(async (res, rej) => {
module.exports = (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
await Matching.remove({
parentId: user._id
});

View File

@ -1,13 +1,11 @@
/**
* Module dependencies
*/
import $ from 'cafy';
import Subscription from '../../../../models/sw-subscription';
import { ILocalUser } from '../../../../models/user';
/**
* subscribe service worker
*/
module.exports = async (params, user, app) => new Promise(async (res, rej) => {
module.exports = async (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
// Get 'endpoint' parameter
const [endpoint, endpointErr] = $.str.get(params.endpoint);
if (endpointErr) return rej('invalid endpoint param');

View File

@ -1,17 +1,11 @@
/**
* Module dependencies
*/
import $ from 'cafy';
import User from '../../../../models/user';
import { validateUsername } from '../../../../models/user';
/**
* Check available username
*
* @param {any} params
* @return {Promise<any>}
*/
module.exports = async (params) => new Promise(async (res, rej) => {
module.exports = async (params: any) => new Promise(async (res, rej) => {
// Get 'username' parameter
const [username, usernameError] = $.str.pipe(validateUsername).get(params.username);
if (usernameError) return rej('invalid username param');

View File

@ -1,13 +1,10 @@
/**
* Module dependencies
*/
import $ from 'cafy';
import User, { pack } from '../../../models/user';
import User, { pack, ILocalUser } from '../../../models/user';
/**
* Lists all users
*/
module.exports = (params, me) => new Promise(async (res, rej) => {
module.exports = (params: any, me: ILocalUser) => new Promise(async (res, rej) => {
// Get 'limit' parameter
const [limit = 10, limitErr] = $.num.optional().range(1, 100).get(params.limit);
if (limitErr) return rej('invalid limit param');

View File

@ -1,8 +1,5 @@
/**
* Module dependencies
*/
import $ from 'cafy'; import ID from '../../../../cafy-id';
import User from '../../../../models/user';
import User, { ILocalUser } from '../../../../models/user';
import Following from '../../../../models/following';
import { pack } from '../../../../models/user';
import { getFriendIds } from '../../common/get-friends';
@ -10,7 +7,7 @@ import { getFriendIds } from '../../common/get-friends';
/**
* Get followers of a user
*/
module.exports = (params, me) => new Promise(async (res, rej) => {
module.exports = (params: any, me: ILocalUser) => new Promise(async (res, rej) => {
// Get 'userId' parameter
const [userId, userIdErr] = $.type(ID).get(params.userId);
if (userIdErr) return rej('invalid userId param');

View File

@ -1,20 +1,13 @@
/**
* Module dependencies
*/
import $ from 'cafy'; import ID from '../../../../cafy-id';
import User from '../../../../models/user';
import User, { ILocalUser } from '../../../../models/user';
import Following from '../../../../models/following';
import { pack } from '../../../../models/user';
import { getFriendIds } from '../../common/get-friends';
/**
* Get following users of a user
*
* @param {any} params
* @param {any} me
* @return {Promise<any>}
*/
module.exports = (params, me) => new Promise(async (res, rej) => {
module.exports = (params: any, me: ILocalUser) => new Promise(async (res, rej) => {
// Get 'userId' parameter
const [userId, userIdErr] = $.type(ID).get(params.userId);
if (userIdErr) return rej('invalid userId param');

View File

@ -1,11 +1,8 @@
/**
* Module dependencies
*/
import $ from 'cafy'; import ID from '../../../../cafy-id';
import Note from '../../../../models/note';
import User, { pack } from '../../../../models/user';
import User, { pack, ILocalUser } from '../../../../models/user';
module.exports = (params, me) => new Promise(async (res, rej) => {
module.exports = (params: any, me: ILocalUser) => new Promise(async (res, rej) => {
// Get 'userId' parameter
const [userId, userIdErr] = $.type(ID).get(params.userId);
if (userIdErr) return rej('invalid userId param');
@ -64,7 +61,7 @@ module.exports = (params, me) => new Promise(async (res, rej) => {
}
});
const repliedUsers = {};
const repliedUsers: any = {};
// Extract replies from recent notes
replyTargetNotes.forEach(note => {

View File

@ -1,13 +1,11 @@
/**
* Module dependencies
*/
import $ from 'cafy';
import UserList, { pack } from '../../../../../models/user-list';
import { ILocalUser } from '../../../../../models/user';
/**
* Create a user list
*/
module.exports = async (params, user) => new Promise(async (res, rej) => {
module.exports = async (params: any, user: ILocalUser) => new Promise(async (res, rej) => {
// Get 'title' parameter
const [title, titleErr] = $.str.range(1, 100).get(params.title);
if (titleErr) return rej('invalid title param');

View File

@ -1,9 +1,10 @@
import UserList, { pack } from '../../../../../models/user-list';
import { ILocalUser } from '../../../../../models/user';
/**
* Add a user to a user list
*/
module.exports = async (params, me) => new Promise(async (res, rej) => {
module.exports = async (params: any, me: ILocalUser) => new Promise(async (res, rej) => {
// Fetch lists
const userLists = await UserList.find({
userId: me._id,

View File

@ -1,6 +1,6 @@
import $ from 'cafy'; import ID from '../../../../../cafy-id';
import UserList from '../../../../../models/user-list';
import User, { pack as packUser, isRemoteUser, getGhost } from '../../../../../models/user';
import User, { pack as packUser, isRemoteUser, getGhost, ILocalUser } from '../../../../../models/user';
import { publishUserListStream } from '../../../../../publishers/stream';
import ap from '../../../../../remote/activitypub/renderer';
import renderFollow from '../../../../../remote/activitypub/renderer/follow';
@ -9,7 +9,7 @@ import { deliver } from '../../../../../queue';
/**
* Add a user to a user list
*/
module.exports = async (params, me) => new Promise(async (res, rej) => {
module.exports = async (params: any, me: ILocalUser) => new Promise(async (res, rej) => {
// Get 'listId' parameter
const [listId, listIdErr] = $.type(ID).get(params.listId);
if (listIdErr) return rej('invalid listId param');

View File

@ -1,10 +1,11 @@
import $ from 'cafy'; import ID from '../../../../../cafy-id';
import UserList, { pack } from '../../../../../models/user-list';
import { ILocalUser } from '../../../../../models/user';
/**
* Show a user list
*/
module.exports = async (params, me) => new Promise(async (res, rej) => {
module.exports = async (params: any, me: ILocalUser) => new Promise(async (res, rej) => {
// Get 'listId' parameter
const [listId, listIdErr] = $.type(ID).get(params.listId);
if (listIdErr) return rej('invalid listId param');

View File

@ -1,15 +1,12 @@
/**
* Module dependencies
*/
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';
import User, { ILocalUser } from '../../../../models/user';
/**
* Get notes of a user
*/
module.exports = (params, me) => new Promise(async (res, rej) => {
module.exports = (params: any, me: ILocalUser) => new Promise(async (res, rej) => {
// Get 'userId' parameter
const [userId, userIdErr] = $.type(ID).optional().get(params.userId);
if (userIdErr) return rej('invalid userId param');

View File

@ -1,20 +1,13 @@
/**
* Module dependencies
*/
const ms = require('ms');
import $ from 'cafy';
import User, { pack } from '../../../../models/user';
import User, { pack, ILocalUser } from '../../../../models/user';
import { getFriendIds } from '../../common/get-friends';
import Mute from '../../../../models/mute';
/**
* Get recommended users
*
* @param {any} params
* @param {any} me
* @return {Promise<any>}
*/
module.exports = (params, me) => new Promise(async (res, rej) => {
module.exports = (params: any, me: ILocalUser) => new Promise(async (res, rej) => {
// Get 'limit' parameter
const [limit = 10, limitErr] = $.num.optional().range(1, 100).get(params.limit);
if (limitErr) return rej('invalid limit param');

Some files were not shown because too many files have changed in this diff Show More