-
-
Notifications
You must be signed in to change notification settings - Fork 743
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add shoutrrr for supporting emails as push channel (#263)
- Loading branch information
Showing
8 changed files
with
101 additions
and
12 deletions.
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
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,46 @@ | ||
package push | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/containrrr/shoutrrr" | ||
"github.com/containrrr/shoutrrr/pkg/router" | ||
"github.com/containrrr/shoutrrr/pkg/types" | ||
) | ||
|
||
// Shoutrrr implements the shoutrrr messenging aggregator | ||
type Shoutrrr struct { | ||
app *router.ServiceRouter | ||
} | ||
|
||
type shoutrrrConfig struct { | ||
URI string | ||
} | ||
|
||
// NewShoutrrrMessenger creates new Shoutrrr messenger | ||
func NewShoutrrrMessenger(uri string) (*Shoutrrr, error) { | ||
app, err := shoutrrr.CreateSender(uri) | ||
if err != nil { | ||
return nil, fmt.Errorf("shoutrrr: %v", err) | ||
} | ||
|
||
m := &Shoutrrr{ | ||
app: app, | ||
} | ||
|
||
return m, nil | ||
} | ||
|
||
// Send sends to all receivers | ||
func (m *Shoutrrr) Send(title, msg string) { | ||
params := &types.Params{ | ||
"title": title, | ||
"subject": title, | ||
} | ||
|
||
for _, err := range m.app.Send(msg, params) { | ||
if err != nil { | ||
log.ERROR.Printf("shoutrrr: %v", err) | ||
} | ||
} | ||
} |
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