Accept friend requests only pending
fabio0 opened this issue · 1 comments
Hi, using in some tests I found that if I ask a friend request, then that request is denied, if I ask another request (between same users) when the second one is accepted then all requests from that user are accepted, even if they were denied, so I have 2 friends count but with the same user.
In the trait I think could be changed
/** * @param Model $recipient * * @return bool|int */ public function acceptFriendRequest(Model $recipient) { return $this->findFriendship($recipient)->whereRecipient($this)->update([ 'status' => Status::ACCEPTED, ]); }
with
/** * @param Model $recipient * * @return bool|int */ public function acceptFriendRequest(Model $recipient) { return $this->findFriendship($recipient)->where('status', Status::PENDING)->whereRecipient($this)->update([ 'status' => Status::ACCEPTED, ]); }
on line 86
Hey, thanks for letting me know.
Can you please submit a pr with the failing test? Feel free to include the fix you mention.