Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
Invites update #197
I had to do some updates to make the REST API not throw errors with the new BP_Invitations changes I'm proposing. In doing so, I realized that the endpoints could use some expansion to cover the typical use cases:
Group admins want to view/approve/reject pending membership requests (for a specific group).
Add tests cases to cover each of these scenarios.
The commits do accomplish those changes. I changed the endpoints pretty significantly, though, so I hope the changes will meet with your approval.
One format thing that appears to be normal across REST endpoints, but seemed odd to me is that you can fetch a single invitation at
Please let me know what you think of my changes and also what you think of my suggestion. I'd be happy to make the changes.
Note that these changes require a BP installation that has my latest changeset from #6210 applied.
Thanks @dcavins I've tried to test your PR but it seems you haven't rebased it regularly to latest version of master during your work. You missed these 26 commits:
Could you rebase it to latest master and force the push of the PR ?
I've done it locally so I'll be able to test, but if we want to merge I think it would be better.
imath left a comment
Thanks a lot for your hard work on the PR @dcavins
I've added some questions into the code you're suggesting. And I advise you to run the full test suite because there are 3 failing tests:
There were 3 failures: 1) BP_Test_REST_Group_Invites_Endpoint::test_create_item Failed asserting that false is true. /pathto/bp-rest/tests/groups/test-group-invites-controller.php:347 2) BP_Test_REST_Group_Invites_Endpoint::test_create_item_as_group_admin Failed asserting that false is true. /pathto/bp-rest/tests/groups/test-group-invites-controller.php:372 3) BP_Test_REST_Group_Invites_Endpoint::test_create_item_invalid_group_id Failed asserting that two strings are equal. --- Expected +++ Actual @@ @@ -'bp_rest_group_invalid_id' +'bp_rest_authorization_required' /pathto/tests/phpunit/includes/testcase-rest-api.php:11 /pathto/bp-rest/tests/groups/test-group-invites-controller.php:459
About your suggestion, when you say:
Do you think it can be done before our next dev-chat (August 7th) ?
Thanks very much for your code review.
I'm not having any failing tests (in BP or in this REST repo), so I'm guessing the failures you're seeing are due to my not providing up-to-date patches for both sides. I'm updating the BP patch now and will post. Thanks again!
I've updated the group invites and memberships endpoints to behave more like the WP posts endpoint. Examples:
Fetch invitations where the current user is the invitee:
Fetch invitations to a specific group (must be group admin or site admin):
Fetch invitations to a specific user (must be the user or site admin):
Fetch invitations from a specific user (must be the user or site admin):
Find an invitation by a mix of its parameters (must be the inviter, invitee, group admin or site admin):
Send an invitation to a user from a group, setting the current user as the inviter:
Fetch an invitation by ID:
Accept an invitation (must be invitee or site admin):
Delete an invitation (must be invitee, inviter, group admin or site admin ):
Fetch requests where the current user is the requestor:
Other requests endpoints: same patterns as the invites endpoint, just no inviter_id parameter.
And it looks like it needs a rebase! Ha ha. Anyway, thanks for looking.
Reformatting it to a posts-style endpoint was much simpler than the previous approach. However, the new style wasn't possible with the way invites and requests worked before the changes in 6210. So it was a catch 22! :)
renatonascalves left a comment
Gave a quick peek and here are some of changes that could be made:
Overall, the changes are good!
@dcavins for your info, I've just rebased your branch :) There were twice the same commits so I've cherry picked only one of them.
I've run the phpunit tests using latest patch on BP6210 and I confirm the tests are all ok. I'm going to explore it a little more.
@renatonascalves Thanks a lot for your review