-
Notifications
You must be signed in to change notification settings - Fork 406
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add notifications with Shoutrr (#3215)
Co-authored-by: Jeffrey Cafferata <[email protected]> Co-authored-by: Tom Limoncelli <[email protected]>
- Loading branch information
1 parent
25652e0
commit e774e2d
Showing
4 changed files
with
45 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package notifications | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/containrrr/shoutrrr" | ||
) | ||
|
||
func init() { | ||
initers = append(initers, func(cfg map[string]string) Notifier { | ||
if url, ok := cfg["shoutrrr_url"]; ok { | ||
return shoutrrrNotifier(url) | ||
} | ||
return nil | ||
}) | ||
} | ||
|
||
type shoutrrrNotifier string | ||
|
||
func (b shoutrrrNotifier) Notify(domain, provider, msg string, err error, preview bool) { | ||
var payload string | ||
if preview { | ||
payload = fmt.Sprintf("DNSControl preview: %s[%s]:\n%s", domain, provider, msg) | ||
} else if err != nil { | ||
payload = fmt.Sprintf("DNSControl ERROR running correction on %s[%s]:\n%s\nError: %s", domain, provider, msg, err) | ||
} else { | ||
payload = fmt.Sprintf("DNSControl successfully ran correction for %s[%s]:\n%s", domain, provider, msg) | ||
} | ||
shoutrrr.Send(string(b), payload) | ||
} | ||
|
||
func (b shoutrrrNotifier) Done() {} |