From 39edc11ad8b51a012155f086473b42be66fe2fad Mon Sep 17 00:00:00 2001 From: syuilo Date: Wed, 24 May 2017 16:29:00 +0900 Subject: [PATCH] Fix iroiro --- src/api/common/text/elements/hashtag.ts | 2 +- src/api/endpoints.ts | 9 +++++++++ .../aggregation/posts/{like.ts => reaction.ts} | 6 +++--- .../aggregation/posts/{likes.ts => reactions.ts} | 10 +++++----- .../aggregation/users/{like.ts => reaction.ts} | 6 +++--- src/api/endpoints/meta.ts | 1 - src/server.ts | 3 +-- 7 files changed, 22 insertions(+), 15 deletions(-) rename src/api/endpoints/aggregation/posts/{like.ts => reaction.ts} (92%) rename src/api/endpoints/aggregation/posts/{likes.ts => reactions.ts} (85%) rename src/api/endpoints/aggregation/users/{like.ts => reaction.ts} (92%) diff --git a/src/api/common/text/elements/hashtag.ts b/src/api/common/text/elements/hashtag.ts index 048dbd8929..ee57b140b8 100644 --- a/src/api/common/text/elements/hashtag.ts +++ b/src/api/common/text/elements/hashtag.ts @@ -6,7 +6,7 @@ module.exports = (text, i) => { if (!(/^\s#[^\s]+/.test(text) || (i == 0 && /^#[^\s]+/.test(text)))) return null; const isHead = text[0] == '#'; const hashtag = text.match(/^\s?#[^\s]+/)[0]; - const res = !isHead ? [{ + const res: any[] = !isHead ? [{ type: 'text', content: text[0] }] : []; diff --git a/src/api/endpoints.ts b/src/api/endpoints.ts index b72392db64..bb2501c982 100644 --- a/src/api/endpoints.ts +++ b/src/api/endpoints.ts @@ -121,12 +121,21 @@ const endpoints: Endpoint[] = [ { name: 'aggregation/users/following' }, + { + name: 'aggregation/users/reaction' + }, { name: 'aggregation/posts/repost' }, { name: 'aggregation/posts/reply' }, + { + name: 'aggregation/posts/reaction' + }, + { + name: 'aggregation/posts/reactions' + }, { name: 'i', diff --git a/src/api/endpoints/aggregation/posts/like.ts b/src/api/endpoints/aggregation/posts/reaction.ts similarity index 92% rename from src/api/endpoints/aggregation/posts/like.ts rename to src/api/endpoints/aggregation/posts/reaction.ts index 3f44413fe8..e4ca680c33 100644 --- a/src/api/endpoints/aggregation/posts/like.ts +++ b/src/api/endpoints/aggregation/posts/reaction.ts @@ -3,10 +3,10 @@ */ import $ from 'cafy'; import Post from '../../../models/post'; -import Like from '../../../models/like'; +import Reaction from '../../../models/post-reaction'; /** - * Aggregate like of a post + * Aggregate reaction of a post * * @param {any} params * @return {Promise} @@ -25,7 +25,7 @@ module.exports = (params) => new Promise(async (res, rej) => { return rej('post not found'); } - const datas = await Like + const datas = await Reaction .aggregate([ { $match: { post_id: post._id } }, { $project: { diff --git a/src/api/endpoints/aggregation/posts/likes.ts b/src/api/endpoints/aggregation/posts/reactions.ts similarity index 85% rename from src/api/endpoints/aggregation/posts/likes.ts rename to src/api/endpoints/aggregation/posts/reactions.ts index 5031edbffb..2cd4588ae1 100644 --- a/src/api/endpoints/aggregation/posts/likes.ts +++ b/src/api/endpoints/aggregation/posts/reactions.ts @@ -3,10 +3,10 @@ */ import $ from 'cafy'; import Post from '../../../models/post'; -import Like from '../../../models/like'; +import Reaction from '../../../models/post-reaction'; /** - * Aggregate likes of a post + * Aggregate reactions of a post * * @param {any} params * @return {Promise} @@ -27,7 +27,7 @@ module.exports = (params) => new Promise(async (res, rej) => { const startTime = new Date(new Date().setMonth(new Date().getMonth() - 1)); - const likes = await Like + const reactions = await Reaction .find({ post_id: post._id, $or: [ @@ -51,8 +51,8 @@ module.exports = (params) => new Promise(async (res, rej) => { day = new Date(day.setHours(23)); // day = day.getTime(); - const count = likes.filter(l => - l.created_at < day && (l.deleted_at == null || l.deleted_at > day) + const count = reactions.filter(r => + r.created_at < day && (r.deleted_at == null || r.deleted_at > day) ).length; graph.push({ diff --git a/src/api/endpoints/aggregation/users/like.ts b/src/api/endpoints/aggregation/users/reaction.ts similarity index 92% rename from src/api/endpoints/aggregation/users/like.ts rename to src/api/endpoints/aggregation/users/reaction.ts index 239acd2931..8f1919fa69 100644 --- a/src/api/endpoints/aggregation/users/like.ts +++ b/src/api/endpoints/aggregation/users/reaction.ts @@ -3,10 +3,10 @@ */ import $ from 'cafy'; import User from '../../../models/user'; -import Like from '../../../models/like'; +import Reaction from '../../../models/post-reaction'; /** - * Aggregate like of a user + * Aggregate reaction of a user * * @param {any} params * @return {Promise} @@ -29,7 +29,7 @@ module.exports = (params) => new Promise(async (res, rej) => { return rej('user not found'); } - const datas = await Like + const datas = await Reaction .aggregate([ { $match: { user_id: user._id } }, { $project: { diff --git a/src/api/endpoints/meta.ts b/src/api/endpoints/meta.ts index 11c4dcbe5f..98f812abd5 100644 --- a/src/api/endpoints/meta.ts +++ b/src/api/endpoints/meta.ts @@ -1,7 +1,6 @@ /** * Module dependencies */ -import prominence from 'prominence'; import version from '../../version'; import config from '../../conf'; diff --git a/src/server.ts b/src/server.ts index 97a1dd93dd..240800c1e2 100644 --- a/src/server.ts +++ b/src/server.ts @@ -24,8 +24,7 @@ app.set('trust proxy', 'loopback'); if (config.accesses && config.accesses.enable) { const accesses = new Accesses({ appName: 'Misskey', - port: config.accesses.port, - hashIp: true + port: config.accesses.port }); app.use(accesses.express);