gotify / gotify/plugin-api

Add GetMessages and DeleteMessage to MessageHandler

オープン
#11 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る
主要言語
Go
スター
16
フォーク
4
PR マージ指標
30日以内にマージされた PR はありません

説明

Currently, the `MessageHandler` has an API gap in that it cannot list, get, or delete messages. This would be valuable for plugins who want to display a persistent notification while some event is ongoing.

I think the `MessageHandler` interface could just be extended with a few extra functions

```go
// MessageHandler consists of message callbacks to be used by plugins.
type MessageHandler interface {
// SendMessage sends a message with the given information in the request.
SendMessage(msg Message) error

// GetMessages returns all active messages sent by this plugin.
GetMessages() ([]Message, error)

// GetMessage returns a specific message by ID.
GetMessage(id uint) (*Message, error)

// DeleteMessages deletes all messages created by this plugin.
DeleteMessages() error

// DeleteMessage deletes a specific message by ID.
DeleteMessage(id uint) error
}
```

I think the `Message` struct might also need to be extended or a new struct would need to be defined that includes an ID.

As background, I want to make a plugin for Alertmanager where alerts will be persistently created as notifications in Gotify so that I only get one notification for the alert and it gets deleted automatically when it resolves. Additionally, I want to add special handling for the [watchdog alert](https://runbooks.prometheus-operator.dev/runbooks/general/watchdog/) so if Alertmanager stops sending it, I get a notification. With the current plugin API, I am only able to send messages when I get them from alertmanager.

If this is a desirable inclusion, I would love to implement it.

Relates to #7

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。