Use any instead of Object

This commit is contained in:
Aya Morisawa 2017-03-01 17:37:01 +09:00
parent b4c84a9ab4
commit 1b592def23
81 changed files with 398 additions and 397 deletions

View file

@ -10,8 +10,8 @@ import Like from '../../../models/like';
/**
* Aggregate like of a post
*
* @param {Object} params
* @return {Promise<object>}
* @param {any} params
* @return {Promise<any>}
*/
module.exports = (params) =>
new Promise(async (res, rej) =>

View file

@ -10,8 +10,8 @@ import Like from '../../../models/like';
/**
* Aggregate likes of a post
*
* @param {Object} params
* @return {Promise<object>}
* @param {any} params
* @return {Promise<any>}
*/
module.exports = (params) =>
new Promise(async (res, rej) =>

View file

@ -9,8 +9,8 @@ import Post from '../../../models/post';
/**
* Aggregate reply of a post
*
* @param {Object} params
* @return {Promise<object>}
* @param {any} params
* @return {Promise<any>}
*/
module.exports = (params) =>
new Promise(async (res, rej) =>

View file

@ -9,8 +9,8 @@ import Post from '../../../models/post';
/**
* Aggregate repost of a post
*
* @param {Object} params
* @return {Promise<object>}
* @param {any} params
* @return {Promise<any>}
*/
module.exports = (params) =>
new Promise(async (res, rej) =>

View file

@ -10,8 +10,8 @@ import Following from '../../../models/following';
/**
* Aggregate followers of a user
*
* @param {Object} params
* @return {Promise<object>}
* @param {any} params
* @return {Promise<any>}
*/
module.exports = (params) =>
new Promise(async (res, rej) =>

View file

@ -10,8 +10,8 @@ import Following from '../../../models/following';
/**
* Aggregate following of a user
*
* @param {Object} params
* @return {Promise<object>}
* @param {any} params
* @return {Promise<any>}
*/
module.exports = (params) =>
new Promise(async (res, rej) =>

View file

@ -10,8 +10,8 @@ import Like from '../../../models/like';
/**
* Aggregate like of a user
*
* @param {Object} params
* @return {Promise<object>}
* @param {any} params
* @return {Promise<any>}
*/
module.exports = (params) =>
new Promise(async (res, rej) =>

View file

@ -10,8 +10,8 @@ import Post from '../../../models/post';
/**
* Aggregate post of a user
*
* @param {Object} params
* @return {Promise<object>}
* @param {any} params
* @return {Promise<any>}
*/
module.exports = (params) =>
new Promise(async (res, rej) =>

View file

@ -63,9 +63,9 @@ import serialize from '../../serializers/app';
/**
* Create an app
*
* @param {Object} params
* @param {Object} user
* @return {Promise<object>}
* @param {any} params
* @param {any} user
* @return {Promise<any>}
*/
module.exports = async (params, user) =>
new Promise(async (res, rej) =>

View file

@ -37,8 +37,8 @@ import App from '../../../models/app';
/**
* Check available name_id of app
*
* @param {Object} params
* @return {Promise<object>}
* @param {any} params
* @return {Promise<any>}
*/
module.exports = async (params) =>
new Promise(async (res, rej) =>

View file

@ -40,11 +40,11 @@ import serialize from '../../serializers/app';
/**
* Show an app
*
* @param {Object} params
* @param {Object} user
* @param {Object} _
* @param {Object} isSecure
* @return {Promise<object>}
* @param {any} params
* @param {any} user
* @param {any} _
* @param {any} isSecure
* @return {Promise<any>}
*/
module.exports = (params, user, _, isSecure) =>
new Promise(async (res, rej) =>

View file

@ -35,9 +35,9 @@ import AccessToken from '../../models/access-token';
/**
* Accept
*
* @param {Object} params
* @param {Object} user
* @return {Promise<object>}
* @param {any} params
* @param {any} user
* @return {Promise<any>}
*/
module.exports = (params, user) =>
new Promise(async (res, rej) =>

View file

@ -42,8 +42,8 @@ import config from '../../../../conf';
/**
* Generate a session
*
* @param {Object} params
* @return {Promise<object>}
* @param {any} params
* @return {Promise<any>}
*/
module.exports = (params) =>
new Promise(async (res, rej) =>

View file

@ -49,9 +49,9 @@ import serialize from '../../../serializers/auth-session';
/**
* Show a session
*
* @param {Object} params
* @param {Object} user
* @return {Promise<object>}
* @param {any} params
* @param {any} user
* @return {Promise<any>}
*/
module.exports = (params, user) =>
new Promise(async (res, rej) =>

View file

@ -47,8 +47,8 @@ import serialize from '../../../serializers/user';
/**
* Generate a session
*
* @param {Object} params
* @return {Promise<object>}
* @param {any} params
* @return {Promise<any>}
*/
module.exports = (params) =>
new Promise(async (res, rej) => {

View file

@ -8,30 +8,33 @@ import DriveFile from '../models/drive-file';
/**
* Get drive information
*
* @param {Object} params
* @param {Object} user
* @return {Promise<object>}
* @param {any} params
* @param {any} user
* @return {Promise<any>}
*/
module.exports = (params, user) =>
new Promise(async (res, rej) =>
{
// Calculate drive usage
const usage = ((await DriveFile
.aggregate([
{ $match: { user_id: user._id } },
{ $project: {
datasize: true
}},
{ $group: {
_id: null,
usage: { $sum: '$datasize' }
}}
]))[0] || {
usage: 0
}).usage;
new Promise(async (res, rej) => {
// Calculate drive usage
const usage = ((await DriveFile
.aggregate([
{ $match: { user_id: user._id } },
{
$project: {
datasize: true
}
},
{
$group: {
_id: null,
usage: { $sum: '$datasize' }
}
}
]))[0] || {
usage: 0
}).usage;
res({
capacity: user.drive_capacity,
usage: usage
res({
capacity: user.drive_capacity,
usage: usage
});
});
});

View file

@ -10,10 +10,10 @@ import serialize from '../../serializers/drive-file';
/**
* Get drive files
*
* @param {Object} params
* @param {Object} user
* @param {Object} app
* @return {Promise<object>}
* @param {any} params
* @param {any} user
* @param {any} app
* @return {Promise<any>}
*/
module.exports = (params, user, app) =>
new Promise(async (res, rej) =>

View file

@ -14,10 +14,10 @@ import create from '../../../common/add-file-to-drive';
/**
* Create a file
*
* @param {Object} file
* @param {Object} params
* @param {Object} user
* @return {Promise<object>}
* @param {any} file
* @param {any} params
* @param {any} user
* @return {Promise<any>}
*/
module.exports = (file, params, user) =>
new Promise(async (res, rej) =>

View file

@ -10,9 +10,9 @@ import serialize from '../../../serializers/drive-file';
/**
* Find a file(s)
*
* @param {Object} params
* @param {Object} user
* @return {Promise<object>}
* @param {any} params
* @param {any} user
* @return {Promise<any>}
*/
module.exports = (params, user) =>
new Promise(async (res, rej) =>

View file

@ -10,9 +10,9 @@ import serialize from '../../../serializers/drive-file';
/**
* Show a file
*
* @param {Object} params
* @param {Object} user
* @return {Promise<object>}
* @param {any} params
* @param {any} user
* @return {Promise<any>}
*/
module.exports = (params, user) =>
new Promise(async (res, rej) =>

View file

@ -13,9 +13,9 @@ import event from '../../../event';
/**
* Update a file
*
* @param {Object} params
* @param {Object} user
* @return {Promise<object>}
* @param {any} params
* @param {any} user
* @return {Promise<any>}
*/
module.exports = (params, user) =>
new Promise(async (res, rej) =>

View file

@ -15,9 +15,9 @@ import create from '../../../common/add-file-to-drive';
/**
* Create a file from a URL
*
* @param {Object} params
* @param {Object} user
* @return {Promise<object>}
* @param {any} params
* @param {any} user
* @return {Promise<any>}
*/
module.exports = (params, user) =>
new Promise(async (res, rej) =>

View file

@ -10,10 +10,10 @@ import serialize from '../../serializers/drive-folder';
/**
* Get drive folders
*
* @param {Object} params
* @param {Object} user
* @param {Object} app
* @return {Promise<object>}
* @param {any} params
* @param {any} user
* @param {any} app
* @return {Promise<any>}
*/
module.exports = (params, user, app) =>
new Promise(async (res, rej) =>

View file

@ -12,9 +12,9 @@ import event from '../../../event';
/**
* Create drive folder
*
* @param {Object} params
* @param {Object} user
* @return {Promise<object>}
* @param {any} params
* @param {any} user
* @return {Promise<any>}
*/
module.exports = (params, user) =>
new Promise(async (res, rej) =>

View file

@ -10,9 +10,9 @@ import serialize from '../../../serializers/drive-folder';
/**
* Find a folder(s)
*
* @param {Object} params
* @param {Object} user
* @return {Promise<object>}
* @param {any} params
* @param {any} user
* @return {Promise<any>}
*/
module.exports = (params, user) =>
new Promise(async (res, rej) =>

View file

@ -10,9 +10,9 @@ import serialize from '../../../serializers/drive-folder';
/**
* Show a folder
*
* @param {Object} params
* @param {Object} user
* @return {Promise<object>}
* @param {any} params
* @param {any} user
* @return {Promise<any>}
*/
module.exports = (params, user) =>
new Promise(async (res, rej) =>

View file

@ -12,9 +12,9 @@ import event from '../../../event';
/**
* Update a folder
*
* @param {Object} params
* @param {Object} user
* @return {Promise<object>}
* @param {any} params
* @param {any} user
* @return {Promise<any>}
*/
module.exports = (params, user) =>
new Promise(async (res, rej) =>

View file

@ -10,9 +10,9 @@ import serialize from '../../serializers/drive-file';
/**
* Get drive stream
*
* @param {Object} params
* @param {Object} user
* @return {Promise<object>}
* @param {any} params
* @param {any} user
* @return {Promise<any>}
*/
module.exports = (params, user) =>
new Promise(async (res, rej) =>

View file

@ -13,9 +13,9 @@ import serializeUser from '../../serializers/user';
/**
* Follow a user
*
* @param {Object} params
* @param {Object} user
* @return {Promise<object>}
* @param {any} params
* @param {any} user
* @return {Promise<any>}
*/
module.exports = (params, user) =>
new Promise(async (res, rej) =>

View file

@ -12,9 +12,9 @@ import serializeUser from '../../serializers/user';
/**
* Unfollow a user
*
* @param {Object} params
* @param {Object} user
* @return {Promise<object>}
* @param {any} params
* @param {any} user
* @return {Promise<any>}
*/
module.exports = (params, user) =>
new Promise(async (res, rej) =>

View file

@ -8,11 +8,11 @@ import serialize from '../serializers/user';
/**
* Show myself
*
* @param {Object} params
* @param {Object} user
* @param {Object} app
* @param {any} params
* @param {any} user
* @param {any} app
* @param {Boolean} isSecure
* @return {Promise<object>}
* @return {Promise<any>}
*/
module.exports = (params, user, _, isSecure) =>
new Promise(async (res, rej) =>

View file

@ -8,11 +8,11 @@ import Appdata from '../../../models/appdata';
/**
* Get app data
*
* @param {Object} params
* @param {Object} user
* @param {Object} app
* @param {any} params
* @param {any} user
* @param {any} app
* @param {Boolean} isSecure
* @return {Promise<object>}
* @return {Promise<any>}
*/
module.exports = (params, user, app, isSecure) =>
new Promise(async (res, rej) =>

View file

@ -11,11 +11,11 @@ import event from '../../../event';
/**
* Set app data
*
* @param {Object} params
* @param {Object} user
* @param {Object} app
* @param {any} params
* @param {any} user
* @param {any} app
* @param {Boolean} isSecure
* @return {Promise<object>}
* @return {Promise<any>}
*/
module.exports = (params, user, app, isSecure) =>
new Promise(async (res, rej) =>

View file

@ -10,9 +10,9 @@ import serialize from '../../serializers/app';
/**
* Get authorized apps of my account
*
* @param {Object} params
* @param {Object} user
* @return {Promise<object>}
* @param {any} params
* @param {any} user
* @return {Promise<any>}
*/
module.exports = (params, user) =>
new Promise(async (res, rej) =>

View file

@ -10,8 +10,8 @@ import serialize from '../../serializers/post';
/**
* Get followers of a user
*
* @param {Object} params
* @return {Promise<object>}
* @param {any} params
* @return {Promise<any>}
*/
module.exports = (params) =>
new Promise(async (res, rej) =>

View file

@ -11,9 +11,9 @@ import getFriends from '../../common/get-friends';
/**
* Get notifications
*
* @param {Object} params
* @param {Object} user
* @return {Promise<object>}
* @param {any} params
* @param {any} user
* @return {Promise<any>}
*/
module.exports = (params, user) =>
new Promise(async (res, rej) =>

View file

@ -10,9 +10,9 @@ import serialize from '../../serializers/signin';
/**
* Get signin history of my account
*
* @param {Object} params
* @param {Object} user
* @return {Promise<object>}
* @param {any} params
* @param {any} user
* @return {Promise<any>}
*/
module.exports = (params, user) =>
new Promise(async (res, rej) =>

View file

@ -13,11 +13,11 @@ import config from '../../../conf';
/**
* Update myself
*
* @param {Object} params
* @param {Object} user
* @param {Object} _
* @param {any} params
* @param {any} user
* @param {any} _
* @param {boolean} isSecure
* @return {Promise<object>}
* @return {Promise<any>}
*/
module.exports = async (params, user, _, isSecure) =>
new Promise(async (res, rej) =>

View file

@ -10,9 +10,9 @@ import serialize from '../../serializers/messaging-message';
/**
* Show messaging history
*
* @param {Object} params
* @param {Object} user
* @return {Promise<object>}
* @param {any} params
* @param {any} user
* @return {Promise<any>}
*/
module.exports = (params, user) =>
new Promise(async (res, rej) =>

View file

@ -13,9 +13,9 @@ import { publishMessagingStream } from '../../event';
/**
* Get messages
*
* @param {Object} params
* @param {Object} user
* @return {Promise<object>}
* @param {any} params
* @param {any} user
* @return {Promise<any>}
*/
module.exports = (params, user) =>
new Promise(async (res, rej) =>

View file

@ -21,9 +21,9 @@ const maxTextLength = 500;
/**
* Create a message
*
* @param {Object} params
* @param {Object} user
* @return {Promise<object>}
* @param {any} params
* @param {any} user
* @return {Promise<any>}
*/
module.exports = (params, user) =>
new Promise(async (res, rej) =>

View file

@ -8,9 +8,9 @@ import Message from '../../models/messaging-message';
/**
* Get count of unread messages
*
* @param {Object} params
* @param {Object} user
* @return {Promise<object>}
* @param {any} params
* @param {any} user
* @return {Promise<any>}
*/
module.exports = (params, user) =>
new Promise(async (res, rej) =>

View file

@ -36,8 +36,8 @@ import git from 'git-last-commit';
/**
* Show core info
*
* @param {Object} params
* @return {Promise<object>}
* @param {any} params
* @return {Promise<any>}
*/
module.exports = (params) =>
new Promise(async (res, rej) => {

View file

@ -10,9 +10,9 @@ import serialize from '../../serializers/app';
/**
* Get my apps
*
* @param {Object} params
* @param {Object} user
* @return {Promise<object>}
* @param {any} params
* @param {any} user
* @return {Promise<any>}
*/
module.exports = (params, user) =>
new Promise(async (res, rej) =>

View file

@ -11,9 +11,9 @@ import event from '../../../event';
/**
* Mark as read a notification
*
* @param {Object} params
* @param {Object} user
* @return {Promise<object>}
* @param {any} params
* @param {any} user
* @return {Promise<any>}
*/
module.exports = (params, user) =>
new Promise(async (res, rej) => {

View file

@ -9,80 +9,79 @@ import serialize from '../serializers/post';
/**
* Lists all posts
*
* @param {Object} params
* @return {Promise<object>}
* @param {any} params
* @return {Promise<any>}
*/
module.exports = (params) =>
new Promise(async (res, rej) =>
{
// Get 'include_replies' parameter
let includeReplies = params.include_replies;
if (includeReplies === true) {
includeReplies = true;
} else {
includeReplies = false;
}
// Get 'include_reposts' parameter
let includeReposts = params.include_reposts;
if (includeReposts === true) {
includeReposts = true;
} else {
includeReposts = false;
}
// Get 'limit' parameter
let limit = params.limit;
if (limit !== undefined && limit !== null) {
limit = parseInt(limit, 10);
// From 1 to 100
if (!(1 <= limit && limit <= 100)) {
return rej('invalid limit range');
new Promise(async (res, rej) => {
// Get 'include_replies' parameter
let includeReplies = params.include_replies;
if (includeReplies === true) {
includeReplies = true;
} else {
includeReplies = false;
}
} else {
limit = 10;
}
const since = params.since_id || null;
const max = params.max_id || null;
// Get 'include_reposts' parameter
let includeReposts = params.include_reposts;
if (includeReposts === true) {
includeReposts = true;
} else {
includeReposts = false;
}
// Check if both of since_id and max_id is specified
if (since !== null && max !== null) {
return rej('cannot set since_id and max_id');
}
// Get 'limit' parameter
let limit = params.limit;
if (limit !== undefined && limit !== null) {
limit = parseInt(limit, 10);
// Construct query
const sort = {
_id: -1
};
const query = {};
if (since !== null) {
sort._id = 1;
query._id = {
$gt: new mongo.ObjectID(since)
// From 1 to 100
if (!(1 <= limit && limit <= 100)) {
return rej('invalid limit range');
}
} else {
limit = 10;
}
const since = params.since_id || null;
const max = params.max_id || null;
// Check if both of since_id and max_id is specified
if (since !== null && max !== null) {
return rej('cannot set since_id and max_id');
}
// Construct query
const sort = {
_id: -1
};
} else if (max !== null) {
query._id = {
$lt: new mongo.ObjectID(max)
};
}
const query = {};
if (since !== null) {
sort._id = 1;
query._id = {
$gt: new mongo.ObjectID(since)
};
} else if (max !== null) {
query._id = {
$lt: new mongo.ObjectID(max)
};
}
if (!includeReplies) {
query.reply_to_id = null;
}
if (!includeReplies) {
query.reply_to_id = null;
}
if (!includeReposts) {
query.repost_id = null;
}
if (!includeReposts) {
query.repost_id = null;
}
// Issue query
const posts = await Post
.find(query, {
limit: limit,
sort: sort
});
// Issue query
const posts = await Post
.find(query, {
limit: limit,
sort: sort
});
// Serialize
res(await Promise.all(posts.map(async post => await serialize(post))));
});
// Serialize
res(await Promise.all(posts.map(async post => await serialize(post))));
});

View file

@ -10,9 +10,9 @@ import serialize from '../../serializers/post';
/**
* Show a context of a post
*
* @param {Object} params
* @param {Object} user
* @return {Promise<object>}
* @param {any} params
* @param {any} user
* @return {Promise<any>}
*/
module.exports = (params, user) =>
new Promise(async (res, rej) =>

View file

@ -28,10 +28,10 @@ const maxMediaCount = 4;
/**
* Create a post
*
* @param {Object} params
* @param {Object} user
* @param {Object} app
* @return {Promise<object>}
* @param {any} params
* @param {any} user
* @param {any} app
* @return {Promise<any>}
*/
module.exports = (params, user, app) =>
new Promise(async (res, rej) =>

View file

@ -10,9 +10,9 @@ import Post from '../../models/post';
/**
* Favorite a post
*
* @param {Object} params
* @param {Object} user
* @return {Promise<object>}
* @param {any} params
* @param {any} user
* @return {Promise<any>}
*/
module.exports = (params, user) =>
new Promise(async (res, rej) => {

View file

@ -10,9 +10,9 @@ import Post from '../../models/post';
/**
* Unfavorite a post
*
* @param {Object} params
* @param {Object} user
* @return {Promise<object>}
* @param {any} params
* @param {any} user
* @return {Promise<any>}
*/
module.exports = (params, user) =>
new Promise(async (res, rej) => {

View file

@ -11,9 +11,9 @@ import serialize from '../../serializers/user';
/**
* Show a likes of a post
*
* @param {Object} params
* @param {Object} user
* @return {Promise<object>}
* @param {any} params
* @param {any} user
* @return {Promise<any>}
*/
module.exports = (params, user) =>
new Promise(async (res, rej) =>

View file

@ -12,9 +12,9 @@ import notify from '../../../common/notify';
/**
* Like a post
*
* @param {Object} params
* @param {Object} user
* @return {Promise<object>}
* @param {any} params
* @param {any} user
* @return {Promise<any>}
*/
module.exports = (params, user) =>
new Promise(async (res, rej) => {

View file

@ -12,9 +12,9 @@ import User from '../../../models/user';
/**
* Unlike a post
*
* @param {Object} params
* @param {Object} user
* @return {Promise<object>}
* @param {any} params
* @param {any} user
* @return {Promise<any>}
*/
module.exports = (params, user) =>
new Promise(async (res, rej) => {

View file

@ -11,9 +11,9 @@ import serialize from '../../serializers/post';
/**
* Get mentions of myself
*
* @param {Object} params
* @param {Object} user
* @return {Promise<object>}
* @param {any} params
* @param {any} user
* @return {Promise<any>}
*/
module.exports = (params, user) =>
new Promise(async (res, rej) =>

View file

@ -11,9 +11,9 @@ import notify from '../../../common/notify';
/**
* Vote poll of a post
*
* @param {Object} params
* @param {Object} user
* @return {Promise<object>}
* @param {any} params
* @param {any} user
* @return {Promise<any>}
*/
module.exports = (params, user) =>
new Promise(async (res, rej) => {

View file

@ -10,9 +10,9 @@ import serialize from '../../serializers/post';
/**
* Show a replies of a post
*
* @param {Object} params
* @param {Object} user
* @return {Promise<object>}
* @param {any} params
* @param {any} user
* @return {Promise<any>}
*/
module.exports = (params, user) =>
new Promise(async (res, rej) =>

View file

@ -10,9 +10,9 @@ import serialize from '../../serializers/post';
/**
* Show a reposts of a post
*
* @param {Object} params
* @param {Object} user
* @return {Promise<object>}
* @param {any} params
* @param {any} user
* @return {Promise<any>}
*/
module.exports = (params, user) =>
new Promise(async (res, rej) =>

View file

@ -12,9 +12,9 @@ import config from '../../../conf';
/**
* Search a post
*
* @param {Object} params
* @param {Object} me
* @return {Promise<object>}
* @param {any} params
* @param {any} me
* @return {Promise<any>}
*/
module.exports = (params, me) =>
new Promise(async (res, rej) =>

View file

@ -10,9 +10,9 @@ import serialize from '../../serializers/post';
/**
* Show a post
*
* @param {Object} params
* @param {Object} user
* @return {Promise<object>}
* @param {any} params
* @param {any} user
* @return {Promise<any>}
*/
module.exports = (params, user) =>
new Promise(async (res, rej) =>

View file

@ -11,10 +11,10 @@ import serialize from '../../serializers/post';
/**
* Get timeline of myself
*
* @param {Object} params
* @param {Object} user
* @param {Object} app
* @return {Promise<object>}
* @param {any} params
* @param {any} user
* @param {any} app
* @return {Promise<any>}
*/
module.exports = (params, user, app) =>
new Promise(async (res, rej) =>

View file

@ -9,8 +9,8 @@ import { validateUsername } from '../../models/user';
/**
* Check available username
*
* @param {Object} params
* @return {Promise<object>}
* @param {any} params
* @return {Promise<any>}
*/
module.exports = async (params) =>
new Promise(async (res, rej) =>

View file

@ -9,58 +9,57 @@ import serialize from '../serializers/user';
/**
* Lists all users
*
* @param {Object} params
* @param {Object} me
* @return {Promise<object>}
* @param {any} params
* @param {any} me
* @return {Promise<any>}
*/
module.exports = (params, me) =>
new Promise(async (res, rej) =>
{
// Get 'limit' parameter
let limit = params.limit;
if (limit !== undefined && limit !== null) {
limit = parseInt(limit, 10);
new Promise(async (res, rej) => {
// Get 'limit' parameter
let limit = params.limit;
if (limit !== undefined && limit !== null) {
limit = parseInt(limit, 10);
// From 1 to 100
if (!(1 <= limit && limit <= 100)) {
return rej('invalid limit range');
// From 1 to 100
if (!(1 <= limit && limit <= 100)) {
return rej('invalid limit range');
}
} else {
limit = 10;
}
} else {
limit = 10;
}
const since = params.since_id || null;
const max = params.max_id || null;
const since = params.since_id || null;
const max = params.max_id || null;
// Check if both of since_id and max_id is specified
if (since !== null && max !== null) {
return rej('cannot set since_id and max_id');
}
// Check if both of since_id and max_id is specified
if (since !== null && max !== null) {
return rej('cannot set since_id and max_id');
}
// Construct query
const sort = {
_id: -1
};
const query = {};
if (since !== null) {
sort._id = 1;
query._id = {
$gt: new mongo.ObjectID(since)
// Construct query
const sort = {
_id: -1
};
} else if (max !== null) {
query._id = {
$lt: new mongo.ObjectID(max)
};
}
const query = {};
if (since !== null) {
sort._id = 1;
query._id = {
$gt: new mongo.ObjectID(since)
};
} else if (max !== null) {
query._id = {
$lt: new mongo.ObjectID(max)
};
}
// Issue query
const users = await User
.find(query, {
limit: limit,
sort: sort
});
// Issue query
const users = await User
.find(query, {
limit: limit,
sort: sort
});
// Serialize
res(await Promise.all(users.map(async user =>
await serialize(user, me))));
});
// Serialize
res(await Promise.all(users.map(async user =>
await serialize(user, me))));
});

View file

@ -12,9 +12,9 @@ import getFriends from '../../common/get-friends';
/**
* Get followers of a user
*
* @param {Object} params
* @param {Object} me
* @return {Promise<object>}
* @param {any} params
* @param {any} me
* @return {Promise<any>}
*/
module.exports = (params, me) =>
new Promise(async (res, rej) =>

View file

@ -12,9 +12,9 @@ import getFriends from '../../common/get-friends';
/**
* Get following users of a user
*
* @param {Object} params
* @param {Object} me
* @return {Promise<object>}
* @param {any} params
* @param {any} me
* @return {Promise<any>}
*/
module.exports = (params, me) =>
new Promise(async (res, rej) =>

View file

@ -11,9 +11,9 @@ import serialize from '../../serializers/post';
/**
* Get posts of a user
*
* @param {Object} params
* @param {Object} me
* @return {Promise<object>}
* @param {any} params
* @param {any} me
* @return {Promise<any>}
*/
module.exports = (params, me) =>
new Promise(async (res, rej) =>

View file

@ -10,9 +10,9 @@ import getFriends from '../../common/get-friends';
/**
* Get recommended users
*
* @param {Object} params
* @param {Object} me
* @return {Promise<object>}
* @param {any} params
* @param {any} me
* @return {Promise<any>}
*/
module.exports = (params, me) =>
new Promise(async (res, rej) =>

View file

@ -12,9 +12,9 @@ const escapeRegexp = require('escape-regexp');
/**
* Search a user
*
* @param {Object} params
* @param {Object} me
* @return {Promise<object>}
* @param {any} params
* @param {any} me
* @return {Promise<any>}
*/
module.exports = (params, me) =>
new Promise(async (res, rej) =>

View file

@ -10,9 +10,9 @@ import serialize from '../../serializers/user';
/**
* Search a user by username
*
* @param {Object} params
* @param {Object} me
* @return {Promise<object>}
* @param {any} params
* @param {any} me
* @return {Promise<any>}
*/
module.exports = (params, me) =>
new Promise(async (res, rej) =>

View file

@ -10,9 +10,9 @@ import serialize from '../../serializers/user';
/**
* Show a user
*
* @param {Object} params
* @param {Object} me
* @return {Promise<object>}
* @param {any} params
* @param {any} me
* @return {Promise<any>}
*/
module.exports = (params, me) =>
new Promise(async (res, rej) =>

View file

@ -13,7 +13,7 @@ class MisskeyEvent {
config.redis.port, config.redis.host);
}
private publish(channel: string, type: string, value?: Object): void {
private publish(channel: string, type: string, value?: any): void {
const message = value == null ?
{ type: type } :
{ type: type, body: value };
@ -21,11 +21,11 @@ class MisskeyEvent {
this.redisClient.publish(`misskey:${channel}`, JSON.stringify(message));
}
public publishUserStream(userId: ID, type: string, value?: Object): void {
public publishUserStream(userId: ID, type: string, value?: any): void {
this.publish(`user-stream:${userId}`, type, typeof value === 'undefined' ? null : value);
}
public publishMessagingStream(userId: ID, otherpartyId: ID, type: string, value?: Object): void {
public publishMessagingStream(userId: ID, otherpartyId: ID, type: string, value?: any): void {
this.publish(`messaging-stream:${userId}-${otherpartyId}`, type, typeof value === 'undefined' ? null : value);
}
}

View file

@ -12,10 +12,10 @@ import config from '../../conf';
/**
* Serialize an app
*
* @param {Object} app
* @param {Object} me?
* @param {Object} options?
* @return {Promise<Object>}
* @param {any} app
* @param {any} me?
* @param {any} options?
* @return {Promise<any>}
*/
export default (
app: any,
@ -75,8 +75,8 @@ export default (
app_id: _app.id,
user_id: me,
}, {
limit: 1
});
limit: 1
});
_app.is_authorized = exist === 1;
}

View file

@ -10,9 +10,9 @@ import serializeApp from './app';
/**
* Serialize an auth session
*
* @param {Object} session
* @param {Object} me?
* @return {Promise<Object>}
* @param {any} session
* @param {any} me?
* @return {Promise<any>}
*/
export default (
session: any,

View file

@ -13,16 +13,16 @@ import config from '../../conf';
/**
* Serialize a drive file
*
* @param {Object} file
* @param {Object} options?
* @return {Promise<Object>}
* @param {any} file
* @param {any} options?
* @return {Promise<any>}
*/
export default (
file: any,
options?: {
detail: boolean
}
) => new Promise<Object>(async (resolve, reject) => {
) => new Promise<any>(async (resolve, reject) => {
const opts = Object.assign({
detail: false
}, options);
@ -34,18 +34,18 @@ export default (
_file = await DriveFile.findOne({
_id: file
}, {
fields: {
data: false
}
});
fields: {
data: false
}
});
} else if (typeof file === 'string') {
_file = await DriveFile.findOne({
_id: new mongo.ObjectID(file)
}, {
fields: {
data: false
}
});
fields: {
data: false
}
});
} else {
_file = deepcopy(file);
}

View file

@ -10,16 +10,16 @@ import deepcopy = require('deepcopy');
/**
* Serialize a drive folder
*
* @param {Object} folder
* @param {Object} options?
* @return {Promise<Object>}
* @param {any} folder
* @param {any} options?
* @return {Promise<any>}
*/
const self = (
folder: any,
options?: {
detail: boolean
}
) => new Promise<Object>(async (resolve, reject) => {
) => new Promise<any>(async (resolve, reject) => {
const opts = Object.assign({
detail: false
}, options);
@ -28,9 +28,9 @@ const self = (
// Populate the folder if 'folder' is ID
if (mongo.ObjectID.prototype.isPrototypeOf(folder)) {
_folder = await DriveFolder.findOne({_id: folder});
_folder = await DriveFolder.findOne({ _id: folder });
} else if (typeof folder === 'string') {
_folder = await DriveFolder.findOne({_id: new mongo.ObjectID(folder)});
_folder = await DriveFolder.findOne({ _id: new mongo.ObjectID(folder) });
} else {
_folder = deepcopy(folder);
}

View file

@ -10,19 +10,19 @@ import deepcopy = require('deepcopy');
/**
* Serialize a drive tag
*
* @param {Object} tag
* @return {Promise<Object>}
* @param {any} tag
* @return {Promise<any>}
*/
const self = (
tag: any
) => new Promise<Object>(async (resolve, reject) => {
) => new Promise<any>(async (resolve, reject) => {
let _tag: any;
// Populate the tag if 'tag' is ID
if (mongo.ObjectID.prototype.isPrototypeOf(tag)) {
_tag = await DriveTag.findOne({_id: tag});
_tag = await DriveTag.findOne({ _id: tag });
} else if (typeof tag === 'string') {
_tag = await DriveTag.findOne({_id: new mongo.ObjectID(tag)});
_tag = await DriveTag.findOne({ _id: new mongo.ObjectID(tag) });
} else {
_tag = deepcopy(tag);
}

View file

@ -12,10 +12,10 @@ import deepcopy = require('deepcopy');
/**
* Serialize a message
*
* @param {Object} message
* @param {Object} me?
* @param {Object} options?
* @return {Promise<Object>}
* @param {any} message
* @param {any} me?
* @param {any} options?
* @return {Promise<any>}
*/
export default (
message: any,
@ -23,7 +23,7 @@ export default (
options?: {
populateRecipient: boolean
}
) => new Promise<Object>(async (resolve, reject) => {
) => new Promise<any>(async (resolve, reject) => {
const opts = options || {
populateRecipient: true
};

View file

@ -12,10 +12,10 @@ import deepcopy = require('deepcopy');
/**
* Serialize a notification
*
* @param {Object} notification
* @return {Promise<Object>}
* @param {any} notification
* @return {Promise<any>}
*/
export default (notification: any) => new Promise<Object>(async (resolve, reject) => {
export default (notification: any) => new Promise<any>(async (resolve, reject) => {
let _notification: any;
// Populate the notification if 'notification' is ID

View file

@ -15,10 +15,10 @@ import deepcopy = require('deepcopy');
/**
* Serialize a post
*
* @param {Object} post
* @param {Object} me?
* @param {Object} options?
* @return {Promise<Object>}
* @param {any} post
* @param {any} me?
* @param {any} options?
* @return {Promise<any>}
*/
const self = (
post: any,
@ -26,7 +26,7 @@ const self = (
options?: {
detail: boolean
}
) => new Promise<Object>(async (resolve, reject) => {
) => new Promise<any>(async (resolve, reject) => {
const opts = options || {
detail: true,
};

View file

@ -8,12 +8,12 @@ import deepcopy = require('deepcopy');
/**
* Serialize a signin record
*
* @param {Object} record
* @return {Promise<Object>}
* @param {any} record
* @return {Promise<any>}
*/
export default (
record: any
) => new Promise<Object>(async (resolve, reject) => {
) => new Promise<any>(async (resolve, reject) => {
const _record = deepcopy(record);

View file

@ -13,10 +13,10 @@ import config from '../../conf';
/**
* Serialize a user
*
* @param {Object} user
* @param {Object} me?
* @param {Object} options?
* @return {Promise<Object>}
* @param {any} user
* @param {any} me?
* @param {any} options?
* @return {Promise<any>}
*/
export default (
user: any,

View file

@ -11,8 +11,8 @@ let pending = 0;
* Send a request to API
* @param {string|Object} i Credential
* @param {string} endpoint Endpoint
* @param {Object} [data={}] Data
* @return {Promise<Object>} Response
* @param {any} [data={}] Data
* @return {Promise<any>} Response
*/
module.exports = (i, endpoint, data = {}) => {
if (++pending === 1) {