refactor(alerting): Clean up Matrix code

This commit is contained in:
TwiN 2022-09-19 22:08:18 -04:00
parent 38054f57e5
commit f44d4055e6

View File

@ -159,31 +159,21 @@ func (provider *AlertProvider) getConfigForGroup(group string) MatrixProviderCon
if provider.Overrides != nil { if provider.Overrides != nil {
for _, override := range provider.Overrides { for _, override := range provider.Overrides {
if group == override.Group { if group == override.Group {
return MatrixProviderConfig{ return override.MatrixProviderConfig
ServerURL: override.ServerURL,
AccessToken: override.AccessToken,
InternalRoomID: override.InternalRoomID,
}
} }
} }
} }
return MatrixProviderConfig{ return provider.MatrixProviderConfig
ServerURL: provider.ServerURL,
AccessToken: provider.AccessToken,
InternalRoomID: provider.InternalRoomID,
}
} }
func randStringBytes(n int) string { func randStringBytes(n int) string {
// All the compatible characters to use in a transaction ID // All the compatible characters to use in a transaction ID
const availableCharacterBytes = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" const availableCharacterBytes = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
b := make([]byte, n) b := make([]byte, n)
rand.Seed(time.Now().UnixNano()) rand.Seed(time.Now().UnixNano())
for i := range b { for i := range b {
b[i] = availableCharacterBytes[rand.Intn(len(availableCharacterBytes))] b[i] = availableCharacterBytes[rand.Intn(len(availableCharacterBytes))]
} }
return string(b) return string(b)
} }