wip
This commit is contained in:
@@ -53,7 +53,6 @@ module.exports = (params) => new Promise(async (res, rej) => {
|
||||
model: os.cpus()[0].model,
|
||||
cores: os.cpus().length
|
||||
},
|
||||
top_image: meta.top_image,
|
||||
broadcasts: meta.broadcasts
|
||||
});
|
||||
});
|
||||
|
||||
@@ -3,9 +3,9 @@ import OthelloGame, { pack } from '../../../models/othello-game';
|
||||
import Othello from '../../../../common/othello/core';
|
||||
|
||||
module.exports = (params, user) => new Promise(async (res, rej) => {
|
||||
// Get 'game_id' parameter
|
||||
const [gameId, gameIdErr] = $(params.game_id).id().$;
|
||||
if (gameIdErr) return rej('invalid game_id param');
|
||||
// Get 'gameId' parameter
|
||||
const [gameId, gameIdErr] = $(params.gameId).id().$;
|
||||
if (gameIdErr) return rej('invalid gameId param');
|
||||
|
||||
const game = await OthelloGame.findOne({ _id: gameId });
|
||||
|
||||
|
||||
@@ -211,12 +211,12 @@ module.exports = (params, user: IUser, app) => new Promise(async (res, rej) => {
|
||||
|
||||
// 直近の投稿と重複してたらエラー
|
||||
// TODO: 直近の投稿が一日前くらいなら重複とは見なさない
|
||||
if (user.latest_post) {
|
||||
if (user.latestPost) {
|
||||
if (deepEqual({
|
||||
text: user.latest_post.text,
|
||||
reply: user.latest_post.replyId ? user.latest_post.replyId.toString() : null,
|
||||
repost: user.latest_post.repostId ? user.latest_post.repostId.toString() : null,
|
||||
mediaIds: (user.latest_post.mediaIds || []).map(id => id.toString())
|
||||
text: user.latestPost.text,
|
||||
reply: user.latestPost.replyId ? user.latestPost.replyId.toString() : null,
|
||||
repost: user.latestPost.repostId ? user.latestPost.repostId.toString() : null,
|
||||
mediaIds: (user.latestPost.mediaIds || []).map(id => id.toString())
|
||||
}, {
|
||||
text: text,
|
||||
reply: reply ? reply._id.toString() : null,
|
||||
@@ -277,7 +277,7 @@ module.exports = (params, user: IUser, app) => new Promise(async (res, rej) => {
|
||||
|
||||
User.update({ _id: user._id }, {
|
||||
$set: {
|
||||
latest_post: post
|
||||
latestPost: post
|
||||
}
|
||||
});
|
||||
|
||||
@@ -362,7 +362,7 @@ module.exports = (params, user: IUser, app) => new Promise(async (res, rej) => {
|
||||
// Increment replies count
|
||||
Post.update({ _id: reply._id }, {
|
||||
$inc: {
|
||||
replies_count: 1
|
||||
repliesCount: 1
|
||||
}
|
||||
});
|
||||
|
||||
@@ -457,7 +457,7 @@ module.exports = (params, user: IUser, app) => new Promise(async (res, rej) => {
|
||||
// Update repostee status
|
||||
Post.update({ _id: repost._id }, {
|
||||
$inc: {
|
||||
repost_count: 1
|
||||
repostCount: 1
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -73,7 +73,7 @@ module.exports = (params, user) => new Promise(async (res, rej) => {
|
||||
res();
|
||||
|
||||
const inc = {};
|
||||
inc[`reaction_counts.${reaction}`] = 1;
|
||||
inc[`reactionCounts.${reaction}`] = 1;
|
||||
|
||||
// Increment reactions count
|
||||
await Post.update({ _id: post._id }, {
|
||||
|
||||
@@ -51,7 +51,7 @@ module.exports = (params, user) => new Promise(async (res, rej) => {
|
||||
res();
|
||||
|
||||
const dec = {};
|
||||
dec[`reaction_counts.${exist.reaction}`] = -1;
|
||||
dec[`reactionCounts.${exist.reaction}`] = -1;
|
||||
|
||||
// Decrement reactions count
|
||||
Post.update({ _id: post._id }, {
|
||||
|
||||
@@ -21,21 +21,21 @@ module.exports = (params, me) => new Promise(async (res, rej) => {
|
||||
const [text, textError] = $(params.text).optional.string().$;
|
||||
if (textError) return rej('invalid text param');
|
||||
|
||||
// Get 'include_userIds' parameter
|
||||
const [includeUserIds = [], includeUserIdsErr] = $(params.include_userIds).optional.array('id').$;
|
||||
if (includeUserIdsErr) return rej('invalid include_userIds param');
|
||||
// Get 'includeUserIds' parameter
|
||||
const [includeUserIds = [], includeUserIdsErr] = $(params.includeUserIds).optional.array('id').$;
|
||||
if (includeUserIdsErr) return rej('invalid includeUserIds param');
|
||||
|
||||
// Get 'exclude_userIds' parameter
|
||||
const [excludeUserIds = [], excludeUserIdsErr] = $(params.exclude_userIds).optional.array('id').$;
|
||||
if (excludeUserIdsErr) return rej('invalid exclude_userIds param');
|
||||
|
||||
// Get 'include_user_usernames' parameter
|
||||
const [includeUserUsernames = [], includeUserUsernamesErr] = $(params.include_user_usernames).optional.array('string').$;
|
||||
if (includeUserUsernamesErr) return rej('invalid include_user_usernames param');
|
||||
// Get 'includeUserUsernames' parameter
|
||||
const [includeUserUsernames = [], includeUserUsernamesErr] = $(params.includeUserUsernames).optional.array('string').$;
|
||||
if (includeUserUsernamesErr) return rej('invalid includeUserUsernames param');
|
||||
|
||||
// Get 'exclude_user_usernames' parameter
|
||||
const [excludeUserUsernames = [], excludeUserUsernamesErr] = $(params.exclude_user_usernames).optional.array('string').$;
|
||||
if (excludeUserUsernamesErr) return rej('invalid exclude_user_usernames param');
|
||||
// Get 'exclude_userUsernames' parameter
|
||||
const [excludeUserUsernames = [], excludeUserUsernamesErr] = $(params.exclude_userUsernames).optional.array('string').$;
|
||||
if (excludeUserUsernamesErr) return rej('invalid exclude_userUsernames param');
|
||||
|
||||
// Get 'following' parameter
|
||||
const [following = null, followingErr] = $(params.following).optional.nullable.boolean().$;
|
||||
|
||||
@@ -41,7 +41,7 @@ module.exports = (params, user) => new Promise(async (res, rej) => {
|
||||
createdAt: {
|
||||
$gte: new Date(Date.now() - ms('1days'))
|
||||
},
|
||||
repost_count: {
|
||||
repostCount: {
|
||||
$gt: 0
|
||||
}
|
||||
} as any;
|
||||
@@ -68,7 +68,7 @@ module.exports = (params, user) => new Promise(async (res, rej) => {
|
||||
limit: limit,
|
||||
skip: offset,
|
||||
sort: {
|
||||
repost_count: -1,
|
||||
repostCount: -1,
|
||||
_id: -1
|
||||
}
|
||||
});
|
||||
|
||||
@@ -18,7 +18,7 @@ import User from '../models/user';
|
||||
* postsCount:
|
||||
* description: count of all posts of misskey
|
||||
* type: number
|
||||
* users_count:
|
||||
* usersCount:
|
||||
* description: count of all users of misskey
|
||||
* type: number
|
||||
*
|
||||
@@ -43,6 +43,6 @@ module.exports = params => new Promise(async (res, rej) => {
|
||||
|
||||
res({
|
||||
postsCount: postsCount,
|
||||
users_count: usersCount
|
||||
usersCount: usersCount
|
||||
});
|
||||
});
|
||||
|
||||
@@ -34,13 +34,13 @@ module.exports = (params, me) => new Promise(async (res, rej) => {
|
||||
return rej('userId or pair of username and host is required');
|
||||
}
|
||||
|
||||
// Get 'include_replies' parameter
|
||||
const [includeReplies = true, includeRepliesErr] = $(params.include_replies).optional.boolean().$;
|
||||
if (includeRepliesErr) return rej('invalid include_replies param');
|
||||
// Get 'includeReplies' parameter
|
||||
const [includeReplies = true, includeRepliesErr] = $(params.includeReplies).optional.boolean().$;
|
||||
if (includeRepliesErr) return rej('invalid includeReplies param');
|
||||
|
||||
// Get 'with_media' parameter
|
||||
const [withMedia = false, withMediaErr] = $(params.with_media).optional.boolean().$;
|
||||
if (withMediaErr) return rej('invalid with_media param');
|
||||
// Get 'withMedia' parameter
|
||||
const [withMedia = false, withMediaErr] = $(params.withMedia).optional.boolean().$;
|
||||
if (withMediaErr) return rej('invalid withMedia param');
|
||||
|
||||
// Get 'limit' parameter
|
||||
const [limit = 10, limitErr] = $(params.limit).optional.number().range(1, 100).$;
|
||||
|
||||
@@ -96,7 +96,7 @@ export const pack = (
|
||||
limit: 1
|
||||
});
|
||||
|
||||
_app.is_authorized = exist === 1;
|
||||
_app.isAuthorized = exist === 1;
|
||||
}
|
||||
|
||||
resolve(_app);
|
||||
|
||||
@@ -67,7 +67,7 @@ export const pack = (
|
||||
deletedAt: { $exists: false }
|
||||
});
|
||||
|
||||
_channel.is_watching = watch !== null;
|
||||
_channel.isWatching = watch !== null;
|
||||
//#endregion
|
||||
}
|
||||
|
||||
|
||||
@@ -62,8 +62,8 @@ export const pack = (
|
||||
'metadata.folderId': _folder.id
|
||||
});
|
||||
|
||||
_folder.folders_count = childFoldersCount;
|
||||
_folder.files_count = childFilesCount;
|
||||
_folder.foldersCount = childFoldersCount;
|
||||
_folder.filesCount = childFilesCount;
|
||||
}
|
||||
|
||||
if (opts.detail && _folder.parentId) {
|
||||
|
||||
@@ -30,6 +30,10 @@ export type IPost = {
|
||||
userId: mongo.ObjectID;
|
||||
appId: mongo.ObjectID;
|
||||
viaMobile: boolean;
|
||||
repostCount: number;
|
||||
repliesCount: number;
|
||||
reactionCounts: any;
|
||||
mentions: mongo.ObjectID[];
|
||||
geo: {
|
||||
latitude: number;
|
||||
longitude: number;
|
||||
@@ -184,7 +188,7 @@ export const pack = async (
|
||||
const myChoice = poll.choices
|
||||
.filter(c => c.id == vote.choice)[0];
|
||||
|
||||
myChoice.is_voted = true;
|
||||
myChoice.isVoted = true;
|
||||
}
|
||||
|
||||
return poll;
|
||||
|
||||
@@ -88,7 +88,7 @@ export type IUser = {
|
||||
bannerId: mongo.ObjectID;
|
||||
data: any;
|
||||
description: string;
|
||||
latest_post: IPost;
|
||||
latestPost: IPost;
|
||||
pinnedPostId: mongo.ObjectID;
|
||||
isSuspended: boolean;
|
||||
keywords: string[];
|
||||
@@ -167,7 +167,7 @@ export const pack = (
|
||||
delete _user._id;
|
||||
|
||||
// Remove needless properties
|
||||
delete _user.latest_post;
|
||||
delete _user.latestPost;
|
||||
|
||||
if (!_user.host) {
|
||||
// Remove private properties
|
||||
@@ -212,7 +212,7 @@ export const pack = (
|
||||
|
||||
if (meId && !meId.equals(_user.id)) {
|
||||
// Whether the user is following
|
||||
_user.is_following = (async () => {
|
||||
_user.isFollowing = (async () => {
|
||||
const follow = await Following.findOne({
|
||||
followerId: meId,
|
||||
followeeId: _user.id,
|
||||
@@ -222,7 +222,7 @@ export const pack = (
|
||||
})();
|
||||
|
||||
// Whether the user is followed
|
||||
_user.is_followed = (async () => {
|
||||
_user.isFollowed = (async () => {
|
||||
const follow2 = await Following.findOne({
|
||||
followerId: _user.id,
|
||||
followeeId: meId,
|
||||
@@ -232,7 +232,7 @@ export const pack = (
|
||||
})();
|
||||
|
||||
// Whether the user is muted
|
||||
_user.is_muted = (async () => {
|
||||
_user.isMuted = (async () => {
|
||||
const mute = await Mute.findOne({
|
||||
muterId: meId,
|
||||
muteeId: _user.id,
|
||||
@@ -254,14 +254,14 @@ export const pack = (
|
||||
const myFollowingIds = await getFriends(meId);
|
||||
|
||||
// Get following you know count
|
||||
_user.following_you_know_count = Following.count({
|
||||
_user.followingYouKnowCount = Following.count({
|
||||
followeeId: { $in: myFollowingIds },
|
||||
followerId: _user.id,
|
||||
deletedAt: { $exists: false }
|
||||
});
|
||||
|
||||
// Get followers you know count
|
||||
_user.followers_you_know_count = Following.count({
|
||||
_user.followersYouKnowCount = Following.count({
|
||||
followeeId: _user.id,
|
||||
followerId: { $in: myFollowingIds },
|
||||
deletedAt: { $exists: false }
|
||||
|
||||
Reference in New Issue
Block a user