laravel-friendships icon indicating copy to clipboard operation
laravel-friendships copied to clipboard

Accept friend requests only pending

Open fabio0 opened this issue 8 years ago • 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

fabio0 avatar Mar 21 '17 13:03 fabio0

Hey, thanks for letting me know.

Can you please submit a pr with the failing test? Feel free to include the fix you mention.

hootlex avatar Mar 21 '17 14:03 hootlex