This commit is contained in:
syuilo 2019-02-11 23:37:15 +09:00
parent 59fbc5b054
commit d82c5dff71
No known key found for this signature in database
GPG key ID: BDC4C49D06AB9D69
2 changed files with 9 additions and 7 deletions

View file

@ -46,11 +46,19 @@ export async function insertFollowingDoc(followee: IUser, follower: IUser) {
}
});
await FollowRequest.remove({
const removed = await FollowRequest.remove({
followeeId: followee._id,
followerId: follower._id
});
if (removed.deletedCount === 1) {
await User.update({ _id: followee._id }, {
$inc: {
pendingReceivedFollowRequestsCount: -1
}
});
}
if (alreadyFollowed) return;
//#region Increment counts

View file

@ -20,12 +20,6 @@ export default async function(followee: IUser, follower: IUser) {
deliver(followee as ILocalUser, content, follower.inbox);
}
await User.update({ _id: followee._id }, {
$inc: {
pendingReceivedFollowRequestsCount: -1
}
});
packUser(followee, followee, {
detail: true
}).then(packed => publishMainStream(followee._id, 'meUpdated', packed));