I have a system where when the current user accepts a request my app adds a relation between the user that sent the request to the current user.
However I want to also have the current user added to the other user's relation so that it is not just the current user that has a relation.
My code for the current user works, but not for the other user.
//i use this pattern to add the requester to a friends relation to the current user
var relation = PFUser.currentUser()!.relationForKey("Friends")
relation.addObject(passenger as PFObject)
PFUser.currentUser()!.saveInBackground()
When I try the same pattern for the passenger it does not add the relation
var relation = passenger.relationForKey("Friends")
relation.addObject(PFUser.currentUser()!.self as PFObject)
passenger.saveInBackground()
Edit 1:
After a lot of research I found this answer that says I need cloud code. https://stackoverflow.com/a/23305056/3822504 Is this the only way or is there an alternative? Could someone provide a cloud code solution?
Edit 2:
I answered my own question. You will need to edit the cloud code based on your needs. The biggest thing that helped me was knowing how to query user class in cloud code and getting the current user in cloud code.