Skip to content

Conversation

@eternal-flame-AD
Copy link
Member

@eternal-flame-AD eternal-flame-AD commented Jan 12, 2019

TODO:

  • Plugin base interface
  • Webhooker
  • Configor
  • Storager
  • Messenger
  • README
  • CI

@eternal-flame-AD
Copy link
Member Author

@jmattheis Would you please leave your review on the plugin interfaces before we moving on to the plugin loader. Thanks.

By the way I am not sure if travis can build PR even when there is no .travis.yml present in the master branch. If so, would you please enable travis build on this repo for me?

@jmattheis
Copy link
Member

@eternal-flame-AD Thanks for this PR (:. I've enabled travis-ci on this repo so on your next push it should trigger.

config.go Outdated
package plugin

// Configor is the interface plugins should implement in order to provide configuration interface to the user
type Configor interface {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Configurer needs a Schema() string method, to provide the schema of the configuration

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible to just use the default config as the schema?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can generate a schema from the struct see https://github.com/alecthomas/jsonschema but I would prefer to use EmptyConfig if #1 (comment) will be done.

@jmattheis
Copy link
Member

If I wanted to send messages in webhook, would I create a plugin like this? If yes, I would rename RegisterMessageHandler to SetMessageHandler and RegisterStorageHandler to SetStorageHandler.

import (
	"github.com/gin-gonic/gin"
	"github.com/gotify/plugin-api"
)

type NetlifyWebhooker struct {
	msg plugin.MessageHandler
}

var _ plugin.Webhooker = new(NetlifyWebhooker)
var _ plugin.Messenger = new(NetlifyWebhooker)

func (n *NetlifyWebhooker) Enable() error {
	return nil
}

func (n *NetlifyWebhooker) Disable() error {
	return nil
}

func (n *NetlifyWebhooker) RegisterWebhook(r plugin.WebhookRegisterRequest) {
	r.Mux.POST("/netlify", func(context *gin.Context) {
		n.msg.SendMessage(plugin.MessageSendRequest{
			Message: "hurray",
			Title: "something",
		})
	})
}

func (n *NetlifyWebhooker) RegisterMessageHandler(msg plugin.MessageHandler)  {
	n.msg = msg
}

@jmattheis
Copy link
Member

Okay, after #1 (comment), #1 (comment) and #1 (comment) are done I'd see this PR as mergable.

@eternal-flame-AD eternal-flame-AD changed the title [WIP] v1 API v1 API Jan 13, 2019
@eternal-flame-AD
Copy link
Member Author

Okay I think this is ready to merge and we can move on to the main PR then.

@jmattheis jmattheis merged commit 2e6c45a into gotify:master Jan 13, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants