Skip to content

#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

Merged
merged 21 commits into from
Apr 8, 2017
Merged

Conversation

varadarajana
Copy link
Contributor

Please find the 2 files containing the partial fixes for blocking users. I will create one more for organization.

invitations, _, err := client.Organizations.ListPendingOrgInvitations(context.Background(), 1, opt)
=======
invitations, _, err := client.Organizations.ListPendingOrgInvitations(1, opt)
>>>>>>> 1bd4328a520dfc6d58f92e0f441f3f56718b725d
Copy link
Member

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.

Copy link
Contributor Author

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.

Copy link
Member

@dmitshur dmitshur left a 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.

"fmt"
)

// ListBlockedUsers lists all the blocked users by the authenticated user
Copy link
Member

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.

// 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) {
Copy link
Member

@dmitshur dmitshur Mar 25, 2017

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?

Copy link
Member

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
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to the the GitHub API docs:

image

I think you're missing that preview header.

Copy link
Contributor Author

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?

// 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) {
Copy link
Member

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)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@shurcooL I will change the method name and submit, I was waiting since you had asked this question to @gmlewis

Copy link
Member

@dmitshur dmitshur Mar 28, 2017

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.

Copy link
Contributor Author

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.

@dmitshur dmitshur requested a review from gmlewis March 29, 2017 23:46
@dmitshur
Copy link
Member

Not seeing any high level issues. Just need to review it at a lower level.

@@ -0,0 +1,91 @@
// Copyright 2013 The go-github AUTHORS. All rights reserved.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2017

Copy link
Contributor Author

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 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)
Copy link
Collaborator

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"

Copy link
Contributor Author

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 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)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"user/blocks/%v"

Copy link
Contributor Author

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 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)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"user/blocks/%v"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gmlewis this is fixed

@@ -0,0 +1,90 @@
// Copyright 2014 The go-github AUTHORS. All rights reserved.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2017

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gmlewis this is fixed

setup()
defer teardown()

mux.HandleFunc("/users/blocks/u", func(w http.ResponseWriter, r *http.Request) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"user/blocks/u"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gmlewis this is fixed

setup()
defer teardown()

mux.HandleFunc("/users/blocks/u", func(w http.ResponseWriter, r *http.Request) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"user/blocks/u"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gmlewis this is fixed

@varadarajana
Copy link
Contributor Author

@gmlewis can you please review these changes?

Copy link
Collaborator

@gmlewis gmlewis left a 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.

Copy link
Member

@dmitshur dmitshur left a 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.

return blockedUsers, resp, nil
}

// IsBlocked allows the authenticated user to check if the other user is blocked.
Copy link
Member

@dmitshur dmitshur Apr 8, 2017

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.

return isBlocked, resp, err
}

// BlockUser allows authenticated User to block another User.
Copy link
Member

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.

return s.client.Do(ctx, req, nil)
}

// UnblockUser allows authenticated User to unblock BlockedUser.
Copy link
Member

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.
@googlebot
Copy link

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 cla/google commit status will not change from this state. It's up to you to confirm consent of the commit author(s) and merge this pull request when appropriate.

@dmitshur dmitshur merged commit d23570d into google:master Apr 8, 2017
@dmitshur
Copy link
Member

dmitshur commented Apr 8, 2017

Thanks @varadarajana!

bubg-dev pushed a commit to bubg-dev/go-github that referenced this pull request Jun 16, 2017
…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.
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

Successfully merging this pull request may close these issues.

4 participants