gotify / contrib

A list of community contributions.
MIT License
95 stars 38 forks source link

Simple "plugin" framework using templates *feature* #3

Open furyfire opened 5 years ago

furyfire commented 5 years ago

Since the Go language natively support a fairly advanced template engine why not allow for "plugins" to be created using templates alone?

https://push.example.de/message?token=&template=github-webhook

Gotify would then parse the incomming JSON and apply the "github-webhook" template.

This would allow for an easy way of using webhooks and quickly parsing out one or two fields. Just my two cents # #

eternal-flame-AD commented 5 years ago

I think instead of having built-in support for that, we can actually write a plugin to do that:)

We can accept text/template to parse HTTP header/body and translate it into a formatted message. Golang text/template has a relatively lightweight syntax and is easy to get on:)

furyfire commented 5 years ago

Glad you agree It feels like overkill having to write a separate plugin for every webhook there is. And currently there is no way of making gotify accept a randomly formatted json object

eternal-flame-AD commented 5 years ago

@jmattheis Do you think we should have a built-in template engine, or it should exist as a plugin is?

eternal-flame-AD commented 5 years ago

@furyfire Actually we don't need to do so. We can write a single plugin that listens on different URLs for messages, and use different predefined or custom templates to format messages from arbitrary json/plain object.

jmattheis commented 5 years ago

It feels like overkill having to write a separate plugin for every webhook there is. And currently there is no way of making gotify accept a randomly formatted json object

Yes and no, some webhooks require validation of the message this would add additional calls which cannot easily be generalized.

I agree with @eternal-flame-AD here, lets add a single plugin which supports multiple webhooks / webhook templating.