From 0ba5dc3900b5bc8d86c63e04ab17e2e5652a00d2 Mon Sep 17 00:00:00 2001 From: syuilo Date: Wed, 23 May 2018 15:25:15 +0900 Subject: [PATCH] Only show local posts in the timeline of top page --- .../app/common/views/components/welcome-timeline.vue | 1 + src/server/api/endpoints/notes.ts | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/src/client/app/common/views/components/welcome-timeline.vue b/src/client/app/common/views/components/welcome-timeline.vue index 6fadb030c3..0f1fc05f59 100644 --- a/src/client/app/common/views/components/welcome-timeline.vue +++ b/src/client/app/common/views/components/welcome-timeline.vue @@ -37,6 +37,7 @@ export default Vue.extend({ fetch(cb?) { this.fetching = true; (this as any).api('notes', { + local: true, reply: false, renote: false, media: false, diff --git a/src/server/api/endpoints/notes.ts b/src/server/api/endpoints/notes.ts index 4ce7613d70..2a276a9582 100644 --- a/src/server/api/endpoints/notes.ts +++ b/src/server/api/endpoints/notes.ts @@ -8,6 +8,10 @@ import Note, { pack } from '../../../models/note'; * Get all notes */ module.exports = (params) => new Promise(async (res, rej) => { + // Get 'local' parameter + const [local, localErr] = $.bool.optional().get(params.local); + if (localErr) return rej('invalid local param'); + // Get 'reply' parameter const [reply, replyErr] = $.bool.optional().get(params.reply); if (replyErr) return rej('invalid reply param'); @@ -61,6 +65,10 @@ module.exports = (params) => new Promise(async (res, rej) => { }; } + if (local) { + query._user.host = null; + } + if (reply != undefined) { query.replyId = reply ? { $exists: true, $ne: null } : null; }