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

Callback function for new friend request / accepted request #9

Closed
jordansinger opened this issue Oct 15, 2015 · 7 comments
Closed

Callback function for new friend request / accepted request #9

jordansinger opened this issue Oct 15, 2015 · 7 comments

Comments

@jordansinger
Copy link

How might I go about doing something to the likes of "after_create :notify_user" for the friendships model? Something in general in order to notify users of a new request and the requesting user of an accepted request.

@sungwoncho
Copy link
Collaborator

You could fork the gem and write the custom code in HasFreindship::Friendship model.

Adding callbacks sounds like a good idea. Any suggestions on how to implement it? I am taking PR.

@t2
Copy link

t2 commented Jan 16, 2017

@sungwoncho @jordansinger I am hitting this now. Is there no proper way to notify someone/see a list of people that have requested to be friends?

For instance, is this not possible?

@bob.friend_request(@sally)
@sally.friend_requests #=> [@bob]

@sungwoncho
Copy link
Collaborator

sungwoncho commented Jan 19, 2017

@t2 Sorry for the late reply. I am currently using neither this gem nor much Ruby in general, so I can't promise that I will implement this feature soon. But I will try to find some time on the weekend to look it over.

@Pensarfeo any thoughts on this feature?

@Pensarfeo
Copy link
Collaborator

@sungwoncho I am in your same situation ;) I have not been working on rails for the last year...
@t2 it seems like a very useful feature, either an after create or what about using blocks? It would not be hard to put a yield in these methods. If any good soul wants to help...

@t2
Copy link

t2 commented Jan 19, 2017

For now I have solved this with a simple query but performance could be a factor. I may look into this.

def friend_requests
  HasFriendship::Friendship.where(status: 'requested', friendable_id: id).map(&:friend)
end

@sbadura
Copy link
Contributor

sbadura commented May 2, 2017

#41

@sungwoncho
Copy link
Collaborator

@sbadura has implemented a solution in #41 and it has been released in v1.1.0.

Closing this issue.

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

5 participants