summaryrefslogtreecommitdiff
path: root/src/api/endpoints/posts
diff options
context:
space:
mode:
authorsyuilo <syuilotan@yahoo.co.jp>2017-11-23 06:03:54 +0900
committersyuilo <syuilotan@yahoo.co.jp>2017-11-23 06:03:54 +0900
commit182612d5401f2b91b6bda1bb85fda44605ef51d1 (patch)
tree35f7ee05fea02100b7a71e2911fd6ed6b6fe172d /src/api/endpoints/posts
parentoops (diff)
downloadsharkey-182612d5401f2b91b6bda1bb85fda44605ef51d1.tar.gz
sharkey-182612d5401f2b91b6bda1bb85fda44605ef51d1.tar.bz2
sharkey-182612d5401f2b91b6bda1bb85fda44605ef51d1.zip
リアクションもServiceWorkerで通知するように
Diffstat (limited to 'src/api/endpoints/posts')
-rw-r--r--src/api/endpoints/posts/reactions/create.ts10
1 files changed, 9 insertions, 1 deletions
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({