-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Add support for parsing post-receive webhooks #1
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
Comments
There is an issue with this because GitHub is inconsistent with it's timestamp formatting. The timestamps contained under the repository field in post-receive webhooks are formatted Unix style (see https://gist.github.com/gjtorikian/5171861#file-sample_payload-json-L119). I have already contacted GitHub support about this and was told that it can't be changed without potentially breaking existing projects that are dependent on it, so we are on our own to handle this case. The problem here is that the time.Time unmarshal function expects all dates in RFC3339 format, and will not work for the Unix format. The best way I see to tackle this problem is to define our own TimeStamp type which wraps a time.Time. We can define our own unmarshal function to handle the Unix -> RFC3339 conversion or RFC3339 input and simply use the existing time.Time for marshaling. Feel free to assign this issue to me. |
they did the same thing with the new rate limit reset... it's an int rather than rfc3339 timestamp. You can see how I handled it in 5f92f5d. It's certainly not pretty, but it got the job done, since the Rate struct was so small. As a longer term approach, I suspect creating our own type may be the best approach. Unmarshalling from JSON is pretty straightforward, in terms of handling the two different formats. However, for marshalling back out to JSON, we'll need a way to indicate which format a timstamp should use. Though that being said, I'm not sure that GitHub actually has any methods where you pass in a timestamp, so this may be a moot point. |
Added a timestamp struct to handle different incoming time formats from GitHub. Only modified the repo struct to reflect this new time struct for now since it is currently the only location I am currently aware of where this is an issue. Issue: #1
Even though it's not strictly part of the v3 API, it would be nice to define structs for GitHub's post-receive webooks, so that those messages can be easily parsed and acted on.
The text was updated successfully, but these errors were encountered: