Implementing webhooks for the Calendar plugin

AI-generated summary

manut proposes implementing webhooks for the Calendar plugin, focusing on events like create/update/delete, event sign up/out, and integration with external event management platforms. tvavrda asks for specific use cases and event types. manut confirms the scope and notes potential future work for receiving hooks from external platforms, possibly via a separate plugin. manut references the discourse-solved plugin as a reference and seeks approval to proceed. manut highlights challenges in extending webhooks, noting that webhook groups and events are hardcoded in Discourse’s WebHookEventType model, making it difficult to add new events without modifying core code.

Hello !

I wanted to know if you’re interested by the implementation of a few webhooks for the Calendar plugin.

I can work on it if the community feels like it would be a good addition to the plugin…

That being said, it will take time as I cannot find a proper documentation on how to implement webhooks in a plugin, and will have to do some research :slight_smile:

5 Likes

Do you have some interesting use cases? What operations would you implement? Create/update/delete/event sign up/event sign out?

Yes, these are the events I want to create for now; the use case being to trigger an external event management platform.

The next question will be to be able to accept hooks from the remote platform, but I may create a separate plugin for it as it can’t be generic (my first guess) unless we implement support for iCal format (but still, I already can see a lot of limitations to this).

1 Like

I found an official plugin with webhook extensions : GitHub - discourse/discourse-solved: Allow accepted answers on topics · GitHub.

So I can start working on the implementation if there is no objection :slight_smile:

I dug into the code and I found that’s not as easy as it should to add new webhooks.

  • Webhooks are part of a group of webhooks (I guess it’s for the admin and/or to namespace events)
  • For the Solved plugin, there are 2 webhooks: solved_accepted_solution and solved_unaccepted_solution, in the solved group

Where it goes wrong is:

  • the solved group is hardcoded in the WebHookEventType model of Discourse
  • the two events are also hardcoded in the WebHookEventType model of Discourse

I’ll see if and how I can manage to still declare new events without to have to touch to the Discourse code…

1 Like