How to extend Umbraco Webhooks V13
# news
w
How to extend Umbraco Webhooks V13 feature to listen against different notifications https://blog.hackmakedo.com/2023/11/01/adding-a-custom-webhook-type-to-umbraco-v13/
k
I'm right behind you πŸ™‚
w
Great minds think alike πŸ˜„
@Kevin Jump does this work without the base class problem I was running into?
Also not sure just a me thing?! But is the first event you trigger in my case save and publish take longer to say it’s published.. ie in its processing/loading state whilst it waits for a response back.
k
im not using the base class here, because its limited to IEntity types (or as you have seen IContentBase types) and i am actually sending things that are neither of those πŸ™‚ I think 'base' is a misname for it really, its BaseContentWebHook πŸ˜‰
i do think the webhooks slow things down, i am going to experiment today with farming the request off to a background process (see if that makes it fire and forget) in the notification handler of the webhook
w
You at hackathon today?
Be good to swap notes πŸ™‚
k
no 😦 at home - can't make it this year
w
Ah shame
Well remote collab it is then πŸ€ͺ
Do you have an example for just a normal INotitication
I can update the blog post and mention you as a source πŸ™‚
k
yeah - i am just tiding up what i did last night, and then i will have a public repo with it in. i'll pop over the link when its live.
w
Okey doke
Well seems like I won’t bother looking into this today then… 🀣
From my tiny phone screen reading code off GitHub just need to implement IWebHookEvent but I assume you already know this Kevin.
k
yes , although you end up making your own base class for it quite quickly πŸ™‚ -
i think really there is probibly a proper base class missing in the core, so you don't have to do your own, "Is this server running the right role" check on everything
ohh - Putting the webhook firing calls into a background task makes Umbraco way quicker (so might fix your slow to save and publish problem)
w
Ah ok nice I am gonna take a look
Gonna do a clone and take a look then perhaps we can log more issues on CMS repo as like you say implementing your own base class to repeat a lot of common logic is probably not ideal workflow
Private and not public ?!
k
indeed - public now.
w
Thx
k
dev/webhooks branch has a receving controller, so in theory i can webhook to another Umbraco πŸ™‚
w
Yeh your doing a lot of repetitive work that we should not have to do - but kudos appreciate the example mate πŸ˜„
Will update blog later on to your example
k
yeah, i think a proper base class, and maybe an attribute (so a lot like migrations or healthchecks). would make it a lot cleaner.
w
Yeh not sure I have enough time here today to help do a PR for that πŸ˜›
Like your implementation for the receving WebHook πŸ’ͺ
k
yeah - i am not sure if i do either, got to do some 'proper' work this afternoon 😦
w
hahah what I thought this is your proper work πŸ˜›
Updated blog post with a link back to your repo at the bottom of the post https://blog.hackmakedo.com/2023/11/01/adding-a-custom-webhook-type-to-umbraco-v13/
k
Hi warren, do you have your custom example still working for rc4 - I am probibly doing something stupid, but when i go to append. so now :
Copy code
cs
builder.WebhookEvents()
      .Append<uSyncItemImportedWebhookEvent>();
causes and error at boot 😦
Copy code
System.TypeLoadException: 'GenericArguments[0], 'Umbraco.Cms.Core.Webhooks.WebhookEventCollectionBuilder', on 'Umbraco.Cms.Core.Composing.OrderedCollectionBuilderBase`3[TBuilder,TCollection,TItem]' violates the constraint of type parameter 'TBuilder'.'
(this is a fresh project, started the notifications again with attributes, and base classes)
I'll pop it in one of the issues if you don't think its obvious !
indeed - stupid, referenced where wrong in the sub project. πŸ€¦β€β™‚οΈ
w
Oh well. Least it was an easy fix πŸ™‚
17 Views