From 4185c4dc160d57f60091ad4f911bb51b02cb07a2 Mon Sep 17 00:00:00 2001 From: Jan Dvorak Date: Tue, 6 Sep 2022 20:08:17 +0200 Subject: [PATCH] Remove unnecessary trip to DB --- server/publications.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/server/publications.js b/server/publications.js index 185e82e..6172354 100644 --- a/server/publications.js +++ b/server/publications.js @@ -84,12 +84,10 @@ publishComposite('socialize.pendingFriendRequests', function publishFriends(opti Meteor.publish('socialize.hasFriendRequest', function(requestedUser) { check(requestedUser, String); - const userToPublish = Meteor.users.findOne({ _id: requestedUser }); - return RequestsCollection.find({ $or: [ - { linkedObjectId: this.userId, requesterId: userToPublish._id }, - { linkedObjectId: userToPublish._id, requesterId: this.userId } + { linkedObjectId: this.userId, requesterId: requestedUser }, + { linkedObjectId: requestedUser, requesterId: this.userId } ], type: 'friend' });