Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

If the first friendship request is denied, then unlimited duplicate entries can appear in the friendship table #84

Open
spinalwiz opened this issue Mar 23, 2022 · 3 comments

Comments

@spinalwiz
Copy link

spinalwiz commented Mar 23, 2022

To recreate:
Add a friend and then deny that friend request.

Re-add that friend multiple times and you will see multiple entries in the friendship table like this:

image

Cause:
This is because \Multicaret\Acquaintances\Traits\Friendable::getFriendship() returns the first() match which will always be the entry with status == 'denied' which means \Multicaret\Acquaintances\Traits\Friendable::canBefriend() will always return true

Potential Fix:
In \Multicaret\Acquaintances\Traits\Friendable::getFriendship() add an ->orderBy('created_at' , 'desc') (or updated_at) to get the most recent entry

Or if the intention is to have no duplicate entries in the friendship table then will need to change \Multicaret\Acquaintances\Traits\Friendable::befriend() to an upsert

@younus93
Copy link

younus93 commented Jul 27, 2022

This was my initial observation while using this package. I am overcoming this by deleting the friend request when the request is denied.

@francoism90
Copy link
Contributor

@spinalwiz Could you please send a PR? If this is a bug, someone else will probably have it else well.

@Chlemdel
Copy link

Chlemdel commented May 1, 2023

This was my initial observation while using this package. I am overcoming this by deleting the friend request when the request is denied.

What method are you using to delete the requests?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants