From ceda2ca89661d1bd3889453997fe0868a8c31e9d Mon Sep 17 00:00:00 2001 From: syuilo Date: Mon, 28 May 2018 14:39:46 +0900 Subject: Implement delete note --- src/server/api/endpoints.ts | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/server/api/endpoints.ts') diff --git a/src/server/api/endpoints.ts b/src/server/api/endpoints.ts index 892da3540f..908d9574a5 100644 --- a/src/server/api/endpoints.ts +++ b/src/server/api/endpoints.ts @@ -494,6 +494,11 @@ const endpoints: Endpoint[] = [ }, kind: 'note-write' }, + { + name: 'notes/delete', + withCredential: true, + kind: 'note-write' + }, { name: 'notes/renotes' }, -- cgit v1.2.3-freya From 43eb8bd99b09532b76de30b257bf02f47525fe69 Mon Sep 17 00:00:00 2001 From: syuilo Date: Mon, 28 May 2018 21:59:57 +0900 Subject: notes/local-timeline と notes/global-timeline のサインインを不要に MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/server/api/endpoints.ts | 2 -- src/server/api/endpoints/notes/global-timeline.ts | 28 ++++++++++++-------- src/server/api/endpoints/notes/local-timeline.ts | 31 +++++++++++++---------- 3 files changed, 34 insertions(+), 27 deletions(-) (limited to 'src/server/api/endpoints.ts') diff --git a/src/server/api/endpoints.ts b/src/server/api/endpoints.ts index 908d9574a5..c1ac4777b6 100644 --- a/src/server/api/endpoints.ts +++ b/src/server/api/endpoints.ts @@ -515,7 +515,6 @@ const endpoints: Endpoint[] = [ }, { name: 'notes/local-timeline', - withCredential: true, limit: { duration: ms('10minutes'), max: 100 @@ -523,7 +522,6 @@ const endpoints: Endpoint[] = [ }, { name: 'notes/global-timeline', - withCredential: true, limit: { duration: ms('10minutes'), max: 100 diff --git a/src/server/api/endpoints/notes/global-timeline.ts b/src/server/api/endpoints/notes/global-timeline.ts index d22a1763de..7cf06c3af1 100644 --- a/src/server/api/endpoints/notes/global-timeline.ts +++ b/src/server/api/endpoints/notes/global-timeline.ts @@ -9,7 +9,7 @@ import { pack } from '../../../../models/note'; /** * Get timeline of global */ -module.exports = async (params, user, app) => { +module.exports = async (params, user) => { // Get 'limit' parameter const [limit = 10, limitErr] = $.num.optional().range(1, 100).get(params.limit); if (limitErr) throw 'invalid limit param'; @@ -36,9 +36,9 @@ module.exports = async (params, user, app) => { } // ミュートしているユーザーを取得 - const mutedUserIds = (await Mute.find({ + const mutedUserIds = user ? (await Mute.find({ muterId: user._id - })).map(m => m.muteeId); + })).map(m => m.muteeId) : null; //#region Construct query const sort = { @@ -46,17 +46,23 @@ module.exports = async (params, user, app) => { }; const query = { - // mute - userId: { + // public only + visibility: 'public' + } as any; + + if (mutedUserIds && mutedUserIds.length > 0) { + query.userId = { $nin: mutedUserIds - }, - '_reply.userId': { + }; + + query['_reply.userId'] = { $nin: mutedUserIds - }, - '_renote.userId': { + }; + + query['_renote.userId'] = { $nin: mutedUserIds - } - } as any; + }; + } if (sinceId) { sort._id = 1; diff --git a/src/server/api/endpoints/notes/local-timeline.ts b/src/server/api/endpoints/notes/local-timeline.ts index 64118e1f14..7d01de3d43 100644 --- a/src/server/api/endpoints/notes/local-timeline.ts +++ b/src/server/api/endpoints/notes/local-timeline.ts @@ -9,7 +9,7 @@ import { pack } from '../../../../models/note'; /** * Get timeline of local */ -module.exports = async (params, user, app) => { +module.exports = async (params, user) => { // Get 'limit' parameter const [limit = 10, limitErr] = $.num.optional().range(1, 100).get(params.limit); if (limitErr) throw 'invalid limit param'; @@ -36,9 +36,9 @@ module.exports = async (params, user, app) => { } // ミュートしているユーザーを取得 - const mutedUserIds = (await Mute.find({ + const mutedUserIds = user ? (await Mute.find({ muterId: user._id - })).map(m => m.muteeId); + })).map(m => m.muteeId) : null; //#region Construct query const sort = { @@ -46,17 +46,6 @@ module.exports = async (params, user, app) => { }; const query = { - // mute - userId: { - $nin: mutedUserIds - }, - '_reply.userId': { - $nin: mutedUserIds - }, - '_renote.userId': { - $nin: mutedUserIds - }, - // public only visibility: 'public', @@ -64,6 +53,20 @@ module.exports = async (params, user, app) => { '_user.host': null } as any; + if (mutedUserIds && mutedUserIds.length > 0) { + query.userId = { + $nin: mutedUserIds + }; + + query['_reply.userId'] = { + $nin: mutedUserIds + }; + + query['_renote.userId'] = { + $nin: mutedUserIds + }; + } + if (sinceId) { sort._id = 1; query._id = { -- cgit v1.2.3-freya From ab16fb3a3fff96a4fa2bc1fc0e56a87c129a4625 Mon Sep 17 00:00:00 2001 From: syuilo Date: Tue, 29 May 2018 01:22:39 +0900 Subject: #1634 --- src/client/app/common/scripts/streaming/home.ts | 24 ++++++++++ .../views/components/ui.header.notifications.vue | 39 +++------------- .../app/mobile/views/components/ui.header.vue | 52 +++++----------------- src/client/app/mobile/views/components/ui.nav.vue | 52 +++++----------------- src/publishers/notify.ts | 8 ++++ src/server/api/common/read-messaging-message.ts | 8 ++++ src/server/api/common/read-notification.ts | 8 ++++ src/server/api/endpoints.ts | 10 ----- src/server/api/endpoints/messaging/messages.ts | 7 --- .../api/endpoints/messaging/messages/create.ts | 7 +++ src/server/api/endpoints/messaging/unread.ts | 29 ------------ .../endpoints/notifications/get_unread_count.ts | 28 ------------ .../endpoints/notifications/mark_as_read_all.ts | 11 +++-- 13 files changed, 92 insertions(+), 191 deletions(-) delete mode 100644 src/server/api/endpoints/messaging/unread.ts delete mode 100644 src/server/api/endpoints/notifications/get_unread_count.ts (limited to 'src/server/api/endpoints.ts') diff --git a/src/client/app/common/scripts/streaming/home.ts b/src/client/app/common/scripts/streaming/home.ts index 2715b9e0e9..50bbb56896 100644 --- a/src/client/app/common/scripts/streaming/home.ts +++ b/src/client/app/common/scripts/streaming/home.ts @@ -28,6 +28,30 @@ export class HomeStream extends Stream { os.store.dispatch('mergeMe', i); }); + this.on('read_all_notifications', () => { + os.store.dispatch('mergeMe', { + hasUnreadNotification: false + }); + }); + + this.on('unread_notification', () => { + os.store.dispatch('mergeMe', { + hasUnreadNotification: true + }); + }); + + this.on('read_all_messaging_messages', () => { + os.store.dispatch('mergeMe', { + hasUnreadMessagingMessage: false + }); + }); + + this.on('unread_messaging_message', () => { + os.store.dispatch('mergeMe', { + hasUnreadMessagingMessage: true + }); + }); + this.on('clientSettingUpdated', x => { os.store.commit('settings/set', { key: x.key, diff --git a/src/client/app/desktop/views/components/ui.header.notifications.vue b/src/client/app/desktop/views/components/ui.header.notifications.vue index 9eaaa62c61..59a16df9ec 100644 --- a/src/client/app/desktop/views/components/ui.header.notifications.vue +++ b/src/client/app/desktop/views/components/ui.header.notifications.vue @@ -1,7 +1,7 @@