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

  1. Create a new note, add some text (Hooks get executed)
  2. Update the note, add some tags (Hooks get executed)
  3. 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:

  1. Create/Update Hook
  • Update note tags
  • Create Syndication objects
  1. 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.


  1. Which is a fancy way of saying “Set to published_at date to now”, so technically it’s an update of the note.

  2. And I didn’t bother going down that rabbit hole.