quarkiverse / quarkus-github-app

Develop your GitHub Apps in Java with Quarkus.
https://docs.quarkiverse.io/quarkus-github-app/dev/index.html
Apache License 2.0
62 stars 29 forks source link

GitHub Team event is missing #580

Closed kacamific closed 6 months ago

kacamific commented 6 months ago

Hi,

Currently it is possible to listen to GitHub Team events only using @RawEvent.

Would it be possible to add support for it?

Thank you in advance!

gsmet commented 6 months ago

Thanks for opening an issue.

It will need to be added to https://github.com/hub4j/github-api/ first. I will have a look.

Which event do you need exactly? Only team or you need some others like membership?

I let you have a look at https://docs.github.com/en/webhooks/webhook-events-and-payloads and let me know.

Thanks!

kacamific commented 6 months ago

@gsmet thanks for your support.

Actually I need the following:

gsmet commented 6 months ago

Yeah, that's what I thought. I created a PR in the GitHub API project: https://github.com/hub4j/github-api/pull/1818 .

I'll implement the annotations here when it gets merged and released.

gsmet commented 6 months ago

Until it's implemented, you can update to 2.3.3 where I exposed GitHubEvent#getParsedPayload(), which returns a JsonObject that allows to manipulate things a bit more easily.

Obviously, things will be a lot better once properly implemented but if you want to make progress, that could be a workable alternative until then.

gsmet commented 6 months ago

I prepared the integration of the new payloads here: https://github.com/quarkiverse/quarkus-github-app/pull/584 .

gsmet commented 6 months ago

Added in https://github.com/quarkiverse/quarkus-github-app/pull/584 .

gsmet commented 6 months ago

@kacamific 2.4.0 is available with support for team, team_add, member and membership events.

Let me know how it goes for you.

kacamific commented 6 months ago

@gsmet Thanks a lot for providing the events. I checked and I confirm that I was able to use all of them.

During some investigation, I see that the membership GHMemberChanges has only permission and not roleName. Also the mapping of the permission is usually returning Unknown as the payload when adding new user is as following

"changes": { "permission": { "to": "write" }, "role_name": { "to": "maintain" } },

I hope you can support by adding the rolename and maybe to do a mapping to the permission as well.

Again, thanks a lot, you were super fast!

gsmet commented 6 months ago

Ah I was unable to reproduce the role_name thing myself. I will have a look.

As for permission, I wonder if it uses the same thing when using roles.

I will have a closer look.

gsmet commented 6 months ago

I pushed https://github.com/hub4j/github-api/pull/1821 .

Basically, this particular event is a mess and GitHub is using inconsistent values depending on the event.

I'm not sure when we will get a new GitHub API release that fixes it, I'll upgrade when we do.

kacamific commented 6 months ago

@gsmet thanks a lot!

gsmet commented 6 months ago

@bitwiseman was kind enough to release 1.321 so I updated to it and released 2.4.2 that is now available on Maven Central.

I changed the types to String as this thing is currently a big mess: added and edited events are not handling changes the same way and are not using the same permission names. Also the role name is only present for added (and not always... as I didn't get the role name set during my tests).

This has nothing to do with our implementation but with the payload structure sent by GitHub. You might have to actually get the permissions from the repository when you receive an edited event to get all the information you need.

Let us know how it goes for you as it might be something we could document.