-
Notifications
You must be signed in to change notification settings - Fork 2.1k
#569:Partial Fix: Fix for Users Blocking #600
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
Conversation
github/orgs_members_test.go
Outdated
invitations, _, err := client.Organizations.ListPendingOrgInvitations(context.Background(), 1, opt) | ||
======= | ||
invitations, _, err := client.Organizations.ListPendingOrgInvitations(1, opt) | ||
>>>>>>> 1bd4328a520dfc6d58f92e0f441f3f56718b725d |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This unresolved merge conflict shouldn't be here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@shurcooL this was part of messed up fork of mine. I have corrected it and now the latest check in has the right changes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some initial comments based on what I'm seeing so far. It looks good at a high level, but there are small things to improve.
github/users_blocking.go
Outdated
"fmt" | ||
) | ||
|
||
// ListBlockedUsers lists all the blocked users by the authenticated user |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sentences end with a period.
github/users_blocking.go
Outdated
// CheckIfUserIsBlocked allows the authenticated user to check if the other user is blocked | ||
// | ||
// GitHub API docs: https://developer.github.com/v3/users/blocking/#check-whether-youve-blocked-a-user | ||
func (s *UsersService) CheckIfUserIsBlocked(ctx context.Context, user string) (bool, *Response, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm thinking we can shorten/simplify the method name to something like IsBlocked
. @gmlewis, what do you think about the naming here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if err != nil { | ||
return nil, nil, err | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@shurcooL Thank you, I missed the preview header, now it is added. Can you please review?
github/users_blocking.go
Outdated
// CheckIfUserIsBlocked allows the authenticated user to check if the other user is blocked. | ||
// | ||
// GitHub API docs: https://developer.github.com/v3/users/blocking/#check-whether-youve-blocked-a-user | ||
func (s *UsersService) CheckIfUserIsBlocked(ctx context.Context, user string) (bool, *Response, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@varadarajana, did you see my comment at #600 (comment)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fair enough. Let's go with IsBlocked
for now, I feel pretty good about it. If there are concerns or improvement suggestions, we can still change it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@shurcooL I have corrected it to IsBlocked.
Not seeing any high level issues. Just need to review it at a lower level. |
github/users_blocking.go
Outdated
@@ -0,0 +1,91 @@ | |||
// Copyright 2013 The go-github AUTHORS. All rights reserved. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2017
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gmlewis this is fixed.
github/users_blocking.go
Outdated
// | ||
// GitHub API docs: https://developer.github.com/v3/users/blocking/#check-whether-youve-blocked-a-user | ||
func (s *UsersService) IsBlocked(ctx context.Context, user string) (bool, *Response, error) { | ||
u := fmt.Sprintf("users/blocks/%v", user) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to the docs, this URL is: "user/blocks/%v"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gmlewis This is fixed.
github/users_blocking.go
Outdated
// | ||
// GitHub API docs: https://developer.github.com/v3/users/blocking/#block-a-user | ||
func (s *UsersService) BlockUser(ctx context.Context, user string) (*Response, error) { | ||
u := fmt.Sprintf("users/blocks/%v", user) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"user/blocks/%v"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gmlewis this is fixed
github/users_blocking.go
Outdated
// | ||
// GitHub API docs: https://developer.github.com/v3/users/blocking/#unblock-a-user | ||
func (s *UsersService) UnblockUser(ctx context.Context, user string) (*Response, error) { | ||
u := fmt.Sprintf("users/blocks/%v", user) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"user/blocks/%v"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gmlewis this is fixed
github/users_blocking_test.go
Outdated
@@ -0,0 +1,90 @@ | |||
// Copyright 2014 The go-github AUTHORS. All rights reserved. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2017
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gmlewis this is fixed
github/users_blocking_test.go
Outdated
setup() | ||
defer teardown() | ||
|
||
mux.HandleFunc("/users/blocks/u", func(w http.ResponseWriter, r *http.Request) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"user/blocks/u"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gmlewis this is fixed
github/users_blocking_test.go
Outdated
setup() | ||
defer teardown() | ||
|
||
mux.HandleFunc("/users/blocks/u", func(w http.ResponseWriter, r *http.Request) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"user/blocks/u"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gmlewis this is fixed
@gmlewis can you please review these changes? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, but I will be unable to merge until Monday.
If @shurcooL has time to review, he is welcome to merge at his discretion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor documentation improvement suggestions. I can apply them before merging.
Reviewed at a lower level and did not spot any other issues.
LGTM.
github/users_blocking.go
Outdated
return blockedUsers, resp, nil | ||
} | ||
|
||
// IsBlocked allows the authenticated user to check if the other user is blocked. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of saying "MethodName allows the authenticated user to do something", we can be more direct and say "MethodName does something for authenticated user."
I would rephrase this as:
// IsBlocked reports whether specified user is blocked by the authenticated user.
github/users_blocking.go
Outdated
return isBlocked, resp, err | ||
} | ||
|
||
// BlockUser allows authenticated User to block another User. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// BlockUser blocks specified user for the authenticated user.
github/users_blocking.go
Outdated
return s.client.Do(ctx, req, nil) | ||
} | ||
|
||
// UnblockUser allows authenticated User to unblock BlockedUser. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// UnblockUser unblocks specified user for the authenticated user.
Say what the methods do more explicitly. This should be simpler and more readable.
So there's good news and bad news. 👍 The good news is that everyone that needs to sign a CLA (the pull request submitter and all commit authors) have done so. Everything is all good there. 😕 The bad news is that it appears that one or more commits were authored by someone other than the pull request submitter. We need to confirm that they're okay with their commits being contributed to this project. Please have them confirm that here in the pull request. Note to project maintainer: This is a terminal state, meaning the |
Thanks @varadarajana! |
…ersService. (google#600) This change adds support for user blocking preview API to UsersService. This preview API was announced at https://developer.github.com/changes/2017-02-28-user-blocking-apis-and-webhook/. The endpoints are documented at https://developer.github.com/v3/users/blocking/. Helps google#569.
Please find the 2 files containing the partial fixes for blocking users. I will create one more for organization.