From 0610acbf6eef11a9a85cc35851150cb3cc072785 Mon Sep 17 00:00:00 2001 From: syuilo Date: Mon, 20 Mar 2017 13:54:59 +0900 Subject: #302 --- src/api/endpoints/posts/polls/vote.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src/api/endpoints/posts/polls') 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, -- cgit v1.2.3-freya