-
Notifications
You must be signed in to change notification settings - Fork 2
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
Add handler to check ownership of repo or org #13
Conversation
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 you could just change the response type to boolean I think we're good here for now.
endpoints/check-ownership.js
Outdated
const ownerType = nodeType == "Repository" ? response.data.node.owner.__typename : null | ||
|
||
if (nodeType == "Repository" && ownerType == "User") { | ||
const result = response.data.node.owner.id == githubUserId ? "true" : "false" |
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 think this should be an actual boolean. Makes it more easy on the contract side as well.
endpoints/check-ownership.js
Outdated
if (response.data.node.__typename != "User") { | ||
callback(500, Requester.errored(jobRunID, { checkOwnershipError: `Node (${githubUserId}) is not a User.` })) | ||
} else { | ||
const result = response.data.node.organization ? "true" : "false" |
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.
same here then
jobs/check-ownership.json
Outdated
], | ||
"tasks": [ | ||
{ "type": "check-ownership" }, | ||
{ "type": "ethbytes32" }, |
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.
and here
Head branch was pushed to by a user without write access
@mktcode - fixed |
This PR covers: #10
Given a Github user ID and an ID for a Repository or Organization, the new handler checks whether the user is either:
The result is simply a "true" or "false" string for now, but we can obviously add more info in the response object if needed.
NOTE: We're only checking membership in the Organization for now as you need to be a member of an Organization to see what everyone's roles are. Hoping to fix this later.
Also, the version on the
@octobay/adapters
lib was old and things were sort of breaking, so this was updated.