Description
I've been playing around with CW's Webhook recently, and I've noticed these things that needs to be corrected on the official API docs and probably also on the API itself (I don't believe any people actually played with it a lot in the past, so breaking changes are probably okay?):
Undocumented requests
- I see this request coming whenever I update my webhook in my profile:
// Example of an webhook update
{"action":"updated","webhook":{"id":"5ab4829aedbcfc30000000bf"}}
Which is not documented anywhere. Also, what is this id
? It certainly isn't user id or kata id.
Code Challenges (Kata)
- Action
approve_successful
: it is actuallyapproved
// Example of an code challenge approved event
{"action":"approved","code_challenge":{"id":"5ab84aa4206a29ce21000047","created_by_id":"56434db1abfb0e0df800005f"}}
Also it's probably good to include approved_by_id
as well, similar to code challenge API response.
- Action
voted
: Both code challenge vote and solution vote belongs to inside this action type, with the only distinction being the field values insidecode_challenge
key:
// Example of a code challenge vote
{"action":"voted","code_challenge":{"id":"546e2562b03326a88e000020","created_by_id":"543afbcbdef634a70d0002e5"}}
// Example of a solution vote
{"action":"voted","code_challenge":{"id":"5672a98bdbdd995fad00000f","created_by_user_id":"55c39f483a3aa94550000038","label_vote":{"id":"5ab86ada1aaf06bf0c000098","user_id":"58bc46c402edff199f0005eb","labels":["clever"]},"solution_group":{"id":"567332e343b1d6537200004c","total_best_practice_votes":49,"total_clever_votes":76}}}
Which is a very bad idea IMO. There is also no mentions about the existence of solution vote events at all. And why are the type of solution votes visible if the code challenge votes are not visible? That seems incoherent to me.
- Action
created
: this event is triggered whenever someone saves a new kata and an id is generated, which is pretty weird and makes no sense IMO. I'd expect it to be triggered whenever a draft kata is published or something. Anyways:
// Example of a newly saved code challenge
{"action":"created","code_challenge":{"id":"5ab87134206a29814a00008e","created_by_id":"588da1945e86e6660d00004e"}}
- Action
solution_finalized
: It's not fired if solution is not added to the solution page for some reasons (e.g CW ate my solution as in Codewars keeps eating my solutions in the solution page #1114, already submitted the same code before, ...). Also it doesn't fire if someone doesn't submit final, which kind of defeats its purpose (I'm more curious about people who solved the kata but didn't submit final more than people who did, I can already see the latter in the solution page anyway). Anyways:
// Example of a solution finalized
{"action":"solution_finalized","solution":{"id":"5ab870c01aaf06d75e000097","user_id":"58193e9781bcd0cb780008ff"},"code_challenge":{"id":"57ab2d6072292dbf7c000039","created_by_user_id":"55a8b2d86900a43e8c0000c5"}}
Also, I'd really want to see the two id
s of the solution (the two that are on the url to any solution group) and the language the solution is finalized in. I don't want to dig into the kata's solution page or the user's profile just to get this trivial data.
User
- Action
rank_upgraded
: it is actuallyrank_earned
// Example of a overall rank increase
{"action":"rank_earned","user":{"id":"5ab86547e7093be9ed000051","rank":-7},"language":null}
// Example of a language rank increase
{"action":"rank_earned","user":{"id":"5ab86547e7093be9ed000051","rank":-7},"language":"javascript"}
- Action
honor_changed
: looks good
// Example of an honor change (positive)
{"action":"honor_changed","user":{"id":"588da1945e86e6660d00004e","honor":86131,"honor_delta":3}}
// Example of an honor change (negative)
{"action":"honor_changed","user":{"id":"588da1945e86e6660d00004e","honor":86128,"honor_delta":-3}}
Others
- I see a
Remove
button next to the webhook setting but noAdd another webhook
button anywhere, so that seems to be useless. Also it's very limiting to have only 1 webhook available (at least I'd want two webhooks, one for global and one for my events only, right?) - Also, I'm not sure if sending site-wide notifications as webhooks is a good idea. If someone's actually collecting all these data there could be a privacy concern.