summaryrefslogtreecommitdiff
path: root/src/api/endpoints
diff options
context:
space:
mode:
authorsyuilo <syuilotan@yahoo.co.jp>2017-03-20 13:54:59 +0900
committersyuilo <syuilotan@yahoo.co.jp>2017-03-20 13:55:04 +0900
commit0610acbf6eef11a9a85cc35851150cb3cc072785 (patch)
tree8d53c24c38ba7de3c64c4ff780c7f35d828ef554 /src/api/endpoints
parentMerge pull request #301 from syuilo/greenkeeper/gulp-uglify-2.1.1 (diff)
downloadsharkey-0610acbf6eef11a9a85cc35851150cb3cc072785.tar.gz
sharkey-0610acbf6eef11a9a85cc35851150cb3cc072785.tar.bz2
sharkey-0610acbf6eef11a9a85cc35851150cb3cc072785.zip
#302
Diffstat (limited to 'src/api/endpoints')
-rw-r--r--src/api/endpoints/posts/polls/vote.ts7
-rw-r--r--src/api/endpoints/posts/reactions/create.ts5
2 files changed, 9 insertions, 3 deletions
diff --git a/src/api/endpoints/posts/polls/vote.ts b/src/api/endpoints/posts/polls/vote.ts
index 6e71d1816f..d359d7d2c3 100644
--- a/src/api/endpoints/posts/polls/vote.ts
+++ b/src/api/endpoints/posts/polls/vote.ts
@@ -5,6 +5,7 @@ import $ from 'cafy';
import Vote from '../../../models/poll-vote';
import Post from '../../../models/post';
import notify from '../../../common/notify';
+import { publishPostStream } from '../../../event';
/**
* Vote poll of a post
@@ -62,11 +63,13 @@ module.exports = (params, user) => new Promise(async (res, rej) => {
const inc = {};
inc[`poll.choices.${findWithAttr(post.poll.choices, 'id', choice)}.votes`] = 1;
- // Increment likes count
- Post.update({ _id: post._id }, {
+ // Increment votes count
+ await Post.update({ _id: post._id }, {
$inc: inc
});
+ publishPostStream(post._id, 'poll_voted');
+
// Notify
notify(post.user_id, user._id, 'poll_vote', {
post_id: post._id,
diff --git a/src/api/endpoints/posts/reactions/create.ts b/src/api/endpoints/posts/reactions/create.ts
index de4df5fbe1..5425eaea02 100644
--- a/src/api/endpoints/posts/reactions/create.ts
+++ b/src/api/endpoints/posts/reactions/create.ts
@@ -5,6 +5,7 @@ import $ from 'cafy';
import Reaction from '../../../models/post-reaction';
import Post from '../../../models/post';
import notify from '../../../common/notify';
+import { publishPostStream } from '../../../event';
/**
* React to a post
@@ -69,10 +70,12 @@ module.exports = (params, user) => new Promise(async (res, rej) => {
inc['reaction_counts.' + reaction] = 1;
// Increment reactions count
- Post.update({ _id: post._id }, {
+ await Post.update({ _id: post._id }, {
$inc: inc
});
+ publishPostStream(post._id, 'reacted');
+
// Notify
notify(post.user_id, user._id, 'reaction', {
post_id: post._id,