mirror of
https://github.com/hoernschen/dendrite.git
synced 2025-07-29 12:42:46 +00:00
Implement server notices (#2180)
* Add server_notices config * Disallow rejecting "server notice" invites * Update config * Slightly refactor sendEvent and CreateRoom so it can be reused * Implement unspecced server notices * Validate the request * Set the user api when starting * Rename function/variables * Update comments * Update config * Set the avatar on account creation * Update test * Only create the account when starting Only add routes if sever notices are enabled * Use reserver username Check that we actually got roomData * Add check for admin account Enable server notices for CI Return same values as Synapse * Add custom error for rejecting server notice invite * Move building an invite to it's own function, for reusability * Don't create new rooms, use the existing one (follow Synapse behavior) Co-authored-by: kegsay <kegan@matrix.org>
This commit is contained in:
parent
dbded87525
commit
002429c9e2
18 changed files with 689 additions and 82 deletions
|
@ -57,6 +57,9 @@ type Global struct {
|
|||
|
||||
// DNS caching options for all outbound HTTP requests
|
||||
DNSCache DNSCacheOptions `yaml:"dns_cache"`
|
||||
|
||||
// ServerNotices configuration used for sending server notices
|
||||
ServerNotices ServerNotices `yaml:"server_notices"`
|
||||
}
|
||||
|
||||
func (c *Global) Defaults(generate bool) {
|
||||
|
@ -72,6 +75,7 @@ func (c *Global) Defaults(generate bool) {
|
|||
c.Metrics.Defaults(generate)
|
||||
c.DNSCache.Defaults()
|
||||
c.Sentry.Defaults()
|
||||
c.ServerNotices.Defaults(generate)
|
||||
}
|
||||
|
||||
func (c *Global) Verify(configErrs *ConfigErrors, isMonolith bool) {
|
||||
|
@ -82,6 +86,7 @@ func (c *Global) Verify(configErrs *ConfigErrors, isMonolith bool) {
|
|||
c.Metrics.Verify(configErrs, isMonolith)
|
||||
c.Sentry.Verify(configErrs, isMonolith)
|
||||
c.DNSCache.Verify(configErrs, isMonolith)
|
||||
c.ServerNotices.Verify(configErrs, isMonolith)
|
||||
}
|
||||
|
||||
type OldVerifyKeys struct {
|
||||
|
@ -123,6 +128,31 @@ func (c *Metrics) Defaults(generate bool) {
|
|||
func (c *Metrics) Verify(configErrs *ConfigErrors, isMonolith bool) {
|
||||
}
|
||||
|
||||
// ServerNotices defines the configuration used for sending server notices
|
||||
type ServerNotices struct {
|
||||
Enabled bool `yaml:"enabled"`
|
||||
// The localpart to be used when sending notices
|
||||
LocalPart string `yaml:"local_part"`
|
||||
// The displayname to be used when sending notices
|
||||
DisplayName string `yaml:"display_name"`
|
||||
// The avatar of this user
|
||||
AvatarURL string `yaml:"avatar"`
|
||||
// The roomname to be used when creating messages
|
||||
RoomName string `yaml:"room_name"`
|
||||
}
|
||||
|
||||
func (c *ServerNotices) Defaults(generate bool) {
|
||||
if generate {
|
||||
c.Enabled = true
|
||||
c.LocalPart = "_server"
|
||||
c.DisplayName = "Server Alert"
|
||||
c.RoomName = "Server Alert"
|
||||
c.AvatarURL = ""
|
||||
}
|
||||
}
|
||||
|
||||
func (c *ServerNotices) Verify(errors *ConfigErrors, isMonolith bool) {}
|
||||
|
||||
// The configuration to use for Sentry error reporting
|
||||
type Sentry struct {
|
||||
Enabled bool `yaml:"enabled"`
|
||||
|
|
|
@ -58,6 +58,11 @@ global:
|
|||
basic_auth:
|
||||
username: metrics
|
||||
password: metrics
|
||||
server_notices:
|
||||
local_part: "_server"
|
||||
display_name: "Server alerts"
|
||||
avatar: ""
|
||||
room_name: "Server Alerts"
|
||||
app_service_api:
|
||||
internal_api:
|
||||
listen: http://localhost:7777
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue