Deserialize installation_* webhook events #420
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #415
This Pull Request adds support for deserializing GitHub-sent webhook events related to GitHub Apps installations.
This is another breaking change because I could not figure out a cleaner way to deal with the
WrappedEventPayload::installation
field duality:installation
event, theinstallation
field contains a full copy ofcrate::models::Installation
, butinstallation
field only contains anid
and anode_id
(Note:node_id
is not present in the first case.)If there's a better solution than breaking the API again, I'll be happy to apply that.
It might also be nice to try to have a proper
WebhookEvent
type I guess? But I don't know where it would fit. The main things I would like to have forsupporting webhooks is a failible constructor that takes a string as parameter. Since webhook have their "Event::type" stored in a HTTP header (
X-GitHub-Event
), Ithink it would be nice to have a
WebhookEvent::try_from(r#type: String, payload: &[u8]) -> Result<Self>
that would automatically try to parse the payload to thecorrect enum variant if
type
is known, and falls back to theUnknown(serde_json::Value)
variant iftype
isn't known/handled by Octocrab.I can provide payloads from my test app if that helps, it just takes time to anonymize them so I'll only do it on demand.
Cheers,
Gerry