From 182612d5401f2b91b6bda1bb85fda44605ef51d1 Mon Sep 17 00:00:00 2001 From: syuilo Date: Thu, 23 Nov 2017 06:03:54 +0900 Subject: リアクションもServiceWorkerで通知するように MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/endpoints/posts/reactions/create.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'src/api/endpoints/posts') diff --git a/src/api/endpoints/posts/reactions/create.ts b/src/api/endpoints/posts/reactions/create.ts index eecb928123..d537463dfe 100644 --- a/src/api/endpoints/posts/reactions/create.ts +++ b/src/api/endpoints/posts/reactions/create.ts @@ -7,7 +7,9 @@ import Post from '../../../models/post'; import Watching from '../../../models/post-watching'; import notify from '../../../common/notify'; import watch from '../../../common/watch-post'; -import { publishPostStream } from '../../../event'; +import { publishPostStream, pushSw } from '../../../event'; +import serializePost from '../../../serializers/post'; +import serializeUser from '../../../serializers/user'; /** * React to a post @@ -87,6 +89,12 @@ module.exports = (params, user) => new Promise(async (res, rej) => { reaction: reaction }); + pushSw(post.user_id, 'reaction', { + user: await serializeUser(user, post.user_id), + post: await serializePost(post, post.user_id), + reaction: reaction + }); + // Fetch watchers Watching .find({ -- cgit v1.2.3-freya