Skip to content

Commit 0944aa3

Browse files
committed
Support passing discord webhook url as file
1 parent eb0857e commit 0944aa3

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ Miniflux already supports Discord as an integration, however the "rich" embeds i
1111
- `LISTEN_PORT` - defaults to `8080`
1212
- `LISTEN_ADDR` - defaults to `0.0.0.0`
1313
- `DISCORD_WEBHOOK_URL` - required
14+
- alternatively `DISCORD_WEBHOOK_URL_FILE` to better work with secrets
1415
- `LOG_LEVEL` - defaults to `INFO`
1516
3. Use this as a Webhook integration (Settings > Integrations > Webhook)
1617
- e.g. `http://localhost:8080/`

cmd/miniflux-discord/main.go

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"net/http"
77
"os"
88
"strconv"
9+
"strings"
910
)
1011

1112
var (
@@ -34,7 +35,17 @@ func parseEnv() error {
3435
LISTEN_ADDR = envAddr
3536
}
3637

37-
DISCORD_WEBHOOK_URL = os.Getenv("DISCORD_WEBHOOK_URL")
38+
if discordFile := os.Getenv("DISCORD_WEBHOOK_URL_FILE"); discordFile != "" {
39+
fileData, err := os.ReadFile(discordFile)
40+
if err != nil {
41+
return err
42+
}
43+
44+
DISCORD_WEBHOOK_URL = strings.TrimSpace(string(fileData))
45+
} else {
46+
DISCORD_WEBHOOK_URL = os.Getenv("DISCORD_WEBHOOK_URL")
47+
}
48+
3849
if DISCORD_WEBHOOK_URL == "" {
3950
return fmt.Errorf("missing DISCORD_WEBHOOK_URL")
4051
}

0 commit comments

Comments
 (0)