Add poster image support to Matrix download listings
Some checks failed
Test action / kaas (push) Failing after 2s
Some checks failed
Test action / kaas (push) Failing after 2s
- Fetch and display poster images for tracked items in Matrix - Show monitored/unmonitored icons in listings - Limit displayed items to 12, with count and overflow message - Add tests for image fetching and formatting - Enable Grafana datasources - Fix Sonarr/Radarr URL config bug
This commit is contained in:
parent
e07257e137
commit
100a218aed
9 changed files with 432 additions and 59 deletions
|
|
@ -18,6 +18,7 @@ import (
|
|||
"maunium.net/go/mautrix/format"
|
||||
"maunium.net/go/mautrix/id"
|
||||
|
||||
"sneeuwvlok/packages/arrtrix/pkg/arrclient"
|
||||
"sneeuwvlok/packages/arrtrix/pkg/observability"
|
||||
)
|
||||
|
||||
|
|
@ -221,7 +222,49 @@ func (c *Context) Reply(message string, args ...any) {
|
|||
|
||||
content := format.RenderMarkdown(message, true, false)
|
||||
content.MsgType = event.MsgNotice
|
||||
if _, err := c.Bot.SendMessage(c.Ctx, c.OrigRoomID, event.EventMessage, &event.Content{Parsed: &content}, nil); err != nil {
|
||||
if err := c.sendNotice(&content); err != nil {
|
||||
c.Log.Err(err).Msg("Failed to reply to Matrix room command")
|
||||
}
|
||||
}
|
||||
|
||||
func (c *Context) ReplyFormatted(body, formattedBody string) {
|
||||
content := &event.MessageEventContent{
|
||||
MsgType: event.MsgNotice,
|
||||
Body: body,
|
||||
Format: event.FormatHTML,
|
||||
FormattedBody: formattedBody,
|
||||
}
|
||||
if err := c.sendNotice(content); err != nil {
|
||||
c.Log.Err(err).Msg("Failed to reply to Matrix room command")
|
||||
}
|
||||
}
|
||||
|
||||
func (c *Context) SendImage(asset *arrclient.MediaAsset, body string) error {
|
||||
if asset == nil || len(asset.Data) == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
mxcURL, file, err := c.Bot.UploadMedia(c.Ctx, c.OrigRoomID, asset.Data, asset.FileName, asset.MimeType)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
content := &event.MessageEventContent{
|
||||
MsgType: event.MsgImage,
|
||||
Body: body,
|
||||
FileName: asset.FileName,
|
||||
URL: mxcURL,
|
||||
File: file,
|
||||
Info: &event.FileInfo{
|
||||
MimeType: asset.MimeType,
|
||||
Size: len(asset.Data),
|
||||
},
|
||||
}
|
||||
_, err = c.Bot.SendMessage(c.Ctx, c.OrigRoomID, event.EventMessage, &event.Content{Parsed: content}, nil)
|
||||
return err
|
||||
}
|
||||
|
||||
func (c *Context) sendNotice(content *event.MessageEventContent) error {
|
||||
_, err := c.Bot.SendMessage(c.Ctx, c.OrigRoomID, event.EventMessage, &event.Content{Parsed: content}, nil)
|
||||
return err
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue