Today I reworked the hook system in Mirage. I knew from previous attempts that after creating a posts I needed to do certain things, like sending webmentions or syndicating the note to other platforms. That’s what I created the hooks module for. It will be called when a note is created or updated and will execute a list of actions.
At some point, I had lost track of what how it was supposed to work. I started executing the hook actions when publishing a note 1. I also added a hook action which published the note.
So the flow would be like this
- Create a new note, add some text (Hooks get executed)
- Update the note, add some tags (Hooks get executed)
- Publish the note (Hooks get executed)
- Publish hook action gets executed, publishes the note again?
- Goto 3.?
It’s still not really clear to me how this worked and did not blow up in my face 2, but I decided to have two separate hooks with different actions:
- Create/Update Hook
- Update note tags
- Create Syndication objects
- Publish Hook
- Send webmentions
- Syndicate note
This way, I can cleanly separate the actions which need to happen only at publishing from the actions that are only an extension of creating or updating a note.
There is still a few tests that need to be written, but this new hook module makes the whole process at least more easy to understand.