summaryrefslogtreecommitdiff
path: root/src/server/api/endpoints/users
diff options
context:
space:
mode:
authorsyuilo <syuilotan@yahoo.co.jp>2018-04-08 02:30:37 +0900
committersyuilo <syuilotan@yahoo.co.jp>2018-04-08 02:30:37 +0900
commita1b490afa756a71b9cef4afa424575bc223bc612 (patch)
tree06de4d839e17b1e08e0891542af7360c701a154a /src/server/api/endpoints/users
parentMerge pull request #1392 from syuilo/greenkeeper/element-ui-2.3.3 (diff)
downloadsharkey-a1b490afa756a71b9cef4afa424575bc223bc612.tar.gz
sharkey-a1b490afa756a71b9cef4afa424575bc223bc612.tar.bz2
sharkey-a1b490afa756a71b9cef4afa424575bc223bc612.zip
Post --> Note
Closes #1411
Diffstat (limited to 'src/server/api/endpoints/users')
-rw-r--r--src/server/api/endpoints/users/get_frequently_replied_users.ts18
-rw-r--r--src/server/api/endpoints/users/posts.ts10
2 files changed, 14 insertions, 14 deletions
diff --git a/src/server/api/endpoints/users/get_frequently_replied_users.ts b/src/server/api/endpoints/users/get_frequently_replied_users.ts
index 3a116c8e26..7a98f44e98 100644
--- a/src/server/api/endpoints/users/get_frequently_replied_users.ts
+++ b/src/server/api/endpoints/users/get_frequently_replied_users.ts
@@ -2,7 +2,7 @@
* Module dependencies
*/
import $ from 'cafy';
-import Post from '../../../../models/post';
+import Note from '../../../../models/note';
import User, { pack } from '../../../../models/user';
module.exports = (params, me) => new Promise(async (res, rej) => {
@@ -27,8 +27,8 @@ module.exports = (params, me) => new Promise(async (res, rej) => {
return rej('user not found');
}
- // Fetch recent posts
- const recentPosts = await Post.find({
+ // Fetch recent notes
+ const recentNotes = await Note.find({
userId: user._id,
replyId: {
$exists: true,
@@ -46,13 +46,13 @@ module.exports = (params, me) => new Promise(async (res, rej) => {
});
// 投稿が少なかったら中断
- if (recentPosts.length === 0) {
+ if (recentNotes.length === 0) {
return res([]);
}
- const replyTargetPosts = await Post.find({
+ const replyTargetNotes = await Note.find({
_id: {
- $in: recentPosts.map(p => p.replyId)
+ $in: recentNotes.map(p => p.replyId)
},
userId: {
$ne: user._id
@@ -66,9 +66,9 @@ module.exports = (params, me) => new Promise(async (res, rej) => {
const repliedUsers = {};
- // Extract replies from recent posts
- replyTargetPosts.forEach(post => {
- const userId = post.userId.toString();
+ // Extract replies from recent notes
+ replyTargetNotes.forEach(note => {
+ const userId = note.userId.toString();
if (repliedUsers[userId]) {
repliedUsers[userId]++;
} else {
diff --git a/src/server/api/endpoints/users/posts.ts b/src/server/api/endpoints/users/posts.ts
index b6c533fb5b..f9f6345e34 100644
--- a/src/server/api/endpoints/users/posts.ts
+++ b/src/server/api/endpoints/users/posts.ts
@@ -3,11 +3,11 @@
*/
import $ from 'cafy';
import getHostLower from '../../common/get-host-lower';
-import Post, { pack } from '../../../../models/post';
+import Note, { pack } from '../../../../models/note';
import User from '../../../../models/user';
/**
- * Get posts of a user
+ * Get notes of a user
*
* @param {any} params
* @param {any} me
@@ -124,14 +124,14 @@ module.exports = (params, me) => new Promise(async (res, rej) => {
//#endregion
// Issue query
- const posts = await Post
+ const notes = await Note
.find(query, {
limit: limit,
sort: sort
});
// Serialize
- res(await Promise.all(posts.map(async (post) =>
- await pack(post, me)
+ res(await Promise.all(notes.map(async (note) =>
+ await pack(note, me)
)));
});