This commit is contained in:
syuilo 2017-11-01 13:20:55 +09:00
parent c3174e9768
commit c5b6dabd07
1 changed files with 16 additions and 13 deletions

View File

@ -264,20 +264,23 @@ module.exports = (params, user: IUser, app) => new Promise(async (res, rej) => {
publishChannelStream(channel._id, 'post', postObj); publishChannelStream(channel._id, 'post', postObj);
} }
// Fetch all followers // TODO
const followers = await Following if (!channel) {
.find({ // Fetch all followers
followee_id: user._id, const followers = await Following
// 削除されたドキュメントは除く .find({
deleted_at: { $exists: false } followee_id: user._id,
}, { // 削除されたドキュメントは除く
follower_id: true, deleted_at: { $exists: false }
_id: false }, {
}); follower_id: true,
_id: false
});
// Publish event to followers stream // Publish event to followers stream
followers.forEach(following => followers.forEach(following =>
event(following.follower_id, 'post', postObj)); event(following.follower_id, 'post', postObj));
}
// Increment my posts count // Increment my posts count
User.update({ _id: user._id }, { User.update({ _id: user._id }, {