Open thomas-maurice opened 1 month ago
This is a bug, currently gotify doesn't handle when a plugin gets the plugin.Messenger interface after it has been initialized for the user.
You can locally fix this by deleting the plugin config in the database in the plugin_confs
table and then restart gotify.
Ooooooh, so this happens because I added the Messenger interface after I loaded the plugin for the first time ?
Thanks for the explanation :)
Actually probably good to leave it open to track the bug
Ooooooh, so this happens because I added the Messenger interface after I loaded the plugin for the first time ?
Yes, and yeah let's keep this ticket.
Can the issue be reproduced with the latest available release? (y/n) Yes
Which one is the environment gotify server is running in?
Docker startup command or config file here (please mask sensitive information)
Do you have an reverse proxy installed in front of gotify server? (Please select None if the problem can be reproduced without the presense of a reverse proxy)
On which client do you experience problems? (Select as many as you can see)
What did you do?
Yesterday I was trying to write a simple plugin for Gotify and I noticed a weird behaviour. Take the following plugin code:
The code
```go package main import ( "time" "github.com/gin-gonic/gin" "github.com/gotify/plugin-api" ) // GetGotifyPluginInfo returns gotify plugin info. func GetGotifyPluginInfo() plugin.Info { return plugin.Info{ ModulePath: "github.com/thomas-maurice/plugin", Version: "0.0.1", Author: "Thomas Maurice", Website: "https://gotify.net/docs/plugin", Description: "Plugin", License: "MIT", Name: "thomas-maurice/plugin", } } // Plugin is the gotify plugin instance. type Plugin struct { msgHandler plugin.MessageHandler } // SetMessageHandler implements plugin.Messenger // Invoked during initialization func (c *Plugin) SetMessageHandler(h plugin.MessageHandler) { c.msgHandler = h } func (c *Plugin) Enable() error { go func() { time.Sleep(5 * time.Second) c.msgHandler.SendMessage(plugin.Message{ Message: "The plugin has been enabled for 5 seconds.", }) }() return nil } // Disable disables the plugin. func (c *Plugin) Disable() error { return nil } // RegisterWebhook implements plugin.Webhooker. func (c *Plugin) RegisterWebhook(basePath string, g *gin.RouterGroup) { } // NewGotifyPluginInstance creates a plugin instance for a user context. func NewGotifyPluginInstance(ctx plugin.UserContext) plugin.Plugin { return &Plugin{} } func main() { panic("this should be built as go plugin") } ```I compiled it and ran it as per the instructions of the plugin template repo, it compiles and loads properly, so far so good. However when it starts to send messages the messages show up on the web ui, but for instance if I try to delete them it fails, and I see this error in the logs:
Reloading the messages page also shows none of the messages sent by the plugin.
I tested with a standard app, and the messages sent via apps do survive a refresh and behave as i would expect.
This is very odd because if I inspect the database itself the messages are there:
What did you expect to see?
I expect to see the plugin messages show up on the message page even after a refresh
What did you see instead? (Include screenshots, android logcat/request dumps if possible)
The messages disappeared after a page restart, and I cannot seem to delete them from the UI when they show up (immediately after a publish)