This commit is contained in:
@ -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,
|
||||
|
@ -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,
|
||||
|
Reference in New Issue
Block a user