Skip to content

Commit

Permalink
fix(notify): handle #s in matrix params.rooms (#197)
Browse files Browse the repository at this point in the history
  • Loading branch information
JosephKav authored Jan 12, 2023
1 parent 74282d1 commit 81a2a72
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
5 changes: 5 additions & 0 deletions notifiers/shoutrrr/verify.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,11 @@ func (s *Shoutrrr) correctSelf() {
}

switch s.Type {
case "matrix":
// Remove #'s in channel aliases
if rooms := strings.ReplaceAll(s.GetSelfParam("rooms"), "#", ""); rooms != "" {
s.SetParam("rooms", rooms)
}
case "mattermost":
// Channel, strip leading /
if channel := strings.TrimPrefix(s.GetSelfURLField("channel"), "/"); channel != "" {
Expand Down
3 changes: 3 additions & 0 deletions notifiers/shoutrrr/verify_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,9 @@ func TestCorrectSelf(t *testing.T) {
"port - valid": {mapTarget: "url_fields", key: "port", startAs: "8080", want: "8080"},
"path - leading slash": {mapTarget: "url_fields", key: "path", startAs: "/argus", want: "argus"},
"path - valid": {mapTarget: "url_fields", key: "path", startAs: "argus", want: "argus"},
"matrix - rooms, leading #": {sType: "matrix", mapTarget: "params", key: "rooms", startAs: "#alias:server", want: "alias:server"},
"matrix - rooms, leading encoded #": {sType: "matrix", mapTarget: "params", key: "rooms", startAs: "%23alias:server", want: "%23alias:server"},
"matrix - rooms, valid": {sType: "matrix", mapTarget: "params", key: "rooms", startAs: "alias:server", want: "alias:server"},
"mattermost - channel, leading slash": {sType: "mattermost", mapTarget: "url_fields", key: "channel", startAs: "/argus", want: "argus"},
"mattermost - channel, valid": {sType: "mattermost", mapTarget: "url_fields", key: "channel", startAs: "argus", want: "argus"},
"slack - color, # instead of %23": {sType: "slack", mapTarget: "params", key: "color", startAs: "#ffffff", want: "%23ffffff"},
Expand Down

0 comments on commit 81a2a72

Please sign in to comment.