Add Arrtrix runtime, config, onboarding, and webhook support
- Implement runtime package for bridge startup, config loading, and env overrides - Add onboarding package for management room welcome messages - Add matrixcmd package for command processing and help - Add webhook package with Radarr webhook support and validation - Extend connector config for webhooks and validation - Update default config and example config for new options - Add tests for new packages and config validation - Change database type default to sqlite3-fk-wal
This commit is contained in:
parent
eeedb5268a
commit
fe627f3aab
19 changed files with 1855 additions and 35 deletions
|
|
@ -2,17 +2,52 @@ package connector
|
|||
|
||||
import (
|
||||
_ "embed"
|
||||
"fmt"
|
||||
"net/http"
|
||||
|
||||
up "go.mau.fi/util/configupgrade"
|
||||
"maunium.net/go/mautrix/bridgev2"
|
||||
|
||||
"sneeuwvlok/packages/arrtrix/pkg/webhook"
|
||||
)
|
||||
|
||||
//go:embed example-config.yaml
|
||||
var ExampleConfig string
|
||||
|
||||
type Config struct{}
|
||||
type Config struct {
|
||||
Webhooks WebhooksConfig `yaml:"webhooks"`
|
||||
}
|
||||
|
||||
type WebhooksConfig struct {
|
||||
Radarr webhook.RadarrConfig `yaml:"radarr"`
|
||||
}
|
||||
|
||||
func (c *Config) applyDefaults() {
|
||||
c.Webhooks.Radarr.ApplyDefaults()
|
||||
}
|
||||
|
||||
func (c *Config) Validate() error {
|
||||
return c.Webhooks.Radarr.Validate()
|
||||
}
|
||||
|
||||
func upgradeConfig(helper up.Helper) {}
|
||||
|
||||
func (s *ArrtrixConnector) GetConfig() (string, any, up.Upgrader) {
|
||||
s.Config.applyDefaults()
|
||||
return ExampleConfig, &s.Config, up.SimpleUpgrader(upgradeConfig)
|
||||
}
|
||||
|
||||
func (s *ArrtrixConnector) ValidateConfig() error {
|
||||
s.Config.applyDefaults()
|
||||
return s.Config.Validate()
|
||||
}
|
||||
|
||||
func (s *ArrtrixConnector) MountRoutes(router *http.ServeMux) error {
|
||||
s.Config.applyDefaults()
|
||||
if s.Bridge == nil {
|
||||
return fmt.Errorf("bridge is not initialized")
|
||||
}
|
||||
return webhook.MountRadarr(router, s.Bridge, s.Config.Webhooks.Radarr)
|
||||
}
|
||||
|
||||
var _ bridgev2.ConfigValidatingNetwork = (*ArrtrixConnector)(nil)
|
||||
|
|
|
|||
23
packages/arrtrix/pkg/connector/config_test.go
Normal file
23
packages/arrtrix/pkg/connector/config_test.go
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
package connector
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestConfigDefaultsApplyRadarrWebhookPath(t *testing.T) {
|
||||
var cfg Config
|
||||
|
||||
cfg.applyDefaults()
|
||||
|
||||
if cfg.Webhooks.Radarr.Path == "" {
|
||||
t.Fatal("expected radarr webhook path default to be set")
|
||||
}
|
||||
}
|
||||
|
||||
func TestConfigValidateRejectsEnabledWebhookWithoutSecret(t *testing.T) {
|
||||
cfg := Config{}
|
||||
cfg.Webhooks.Radarr.Enabled = true
|
||||
cfg.applyDefaults()
|
||||
|
||||
if err := cfg.Validate(); err == nil {
|
||||
t.Fatal("expected missing secret to fail validation")
|
||||
}
|
||||
}
|
||||
|
|
@ -3,6 +3,7 @@ package connector
|
|||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"net/http"
|
||||
|
||||
"maunium.net/go/mautrix/bridgev2"
|
||||
"maunium.net/go/mautrix/bridgev2/database"
|
||||
|
|
@ -17,6 +18,7 @@ type ArrtrixConnector struct {
|
|||
}
|
||||
|
||||
var _ bridgev2.NetworkConnector = (*ArrtrixConnector)(nil)
|
||||
var _ interface{ MountRoutes(*http.ServeMux) error } = (*ArrtrixConnector)(nil)
|
||||
|
||||
func (s *ArrtrixConnector) GetName() bridgev2.BridgeName {
|
||||
return bridgev2.BridgeName{
|
||||
|
|
|
|||
|
|
@ -1,7 +1,10 @@
|
|||
# No network-specific config is required yet.
|
||||
# Arrtrix-specific runtime options.
|
||||
#
|
||||
# Future Arr-specific runtime options, such as webhook handling, can be added
|
||||
# here without changing the shared mautrix bridge CLI/runtime shape.
|
||||
#
|
||||
# The CLI-provided config file is still fully used by the bridge runtime for
|
||||
# all shared sections like bridge, database, homeserver, and appservice.
|
||||
webhooks:
|
||||
radarr:
|
||||
enabled: false
|
||||
path: /_arrtrix/webhooks/radarr
|
||||
secret: ""
|
||||
# The first implementation delivers notifications to the only configured
|
||||
# management room. If more than one management room exists, the webhook is
|
||||
# rejected until routing is configured more explicitly.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue