-
Notifications
You must be signed in to change notification settings - Fork 84
Add Notification: Apprise #2151
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,46 @@ | ||||||||||||||||||||||||||||||||||||||
| <?xml version="1.0" encoding="utf-8"?> | ||||||||||||||||||||||||||||||||||||||
| <Agent> | ||||||||||||||||||||||||||||||||||||||
| <Name>Apprise</Name> | ||||||||||||||||||||||||||||||||||||||
| <Variables> | ||||||||||||||||||||||||||||||||||||||
| <Variable Help="The server URL including protocol and port - /notify will be automatically appended" Desc="Server URL" Default="http://localhost:8000">SERVER_URL</Variable> | ||||||||||||||||||||||||||||||||||||||
| <Variable Help="Optional Stateful Key (if configured in Apprise). NOTE: This will override any Stateless URLs provided. Set this field to 'none' if not being used." Desc="Stateful Key" Default="none">STATEFUL_KEY</Variable> | ||||||||||||||||||||||||||||||||||||||
| <Variable Help="Optional Tags (if configured in Apprise). Set to 'none' if not being used." Desc="Tags" Default="none">TAGS</Variable> | ||||||||||||||||||||||||||||||||||||||
| <Variable Help="Optional Comma or Space Separated List of Stateless Urls - mailto://user:pass@gmail.com, gotify://host/token. NOTE: This value is ignored if a Stateful Key is provided. Set this field to 'none' if not being used." Desc="Stateless Urls" Default="">STATELESS_URLS</Variable> | ||||||||||||||||||||||||||||||||||||||
| <Variable Help="Specify the fields which are included in the title of the notification." Desc="Notification Title" Default="$SUBJECT">TITLE</Variable> | ||||||||||||||||||||||||||||||||||||||
| <Variable Help="Specify the fields which are included in the message body of the notification." Desc="Notification Message" Default="$DESCRIPTION">MESSAGE</Variable> | ||||||||||||||||||||||||||||||||||||||
| </Variables> | ||||||||||||||||||||||||||||||||||||||
| <Script> | ||||||||||||||||||||||||||||||||||||||
| <![CDATA[ | ||||||||||||||||||||||||||||||||||||||
| #!/bin/bash | ||||||||||||||||||||||||||||||||||||||
| ############ | ||||||||||||||||||||||||||||||||||||||
| {0} | ||||||||||||||||||||||||||||||||||||||
| ############ | ||||||||||||||||||||||||||||||||||||||
| MESSAGE=$(echo -e "$MESSAGE") | ||||||||||||||||||||||||||||||||||||||
| case "$IMPORTANCE" in | ||||||||||||||||||||||||||||||||||||||
| 'normal' ) | ||||||||||||||||||||||||||||||||||||||
| PRIORITY="info" | ||||||||||||||||||||||||||||||||||||||
| ;; | ||||||||||||||||||||||||||||||||||||||
| 'warning' ) | ||||||||||||||||||||||||||||||||||||||
| PRIORITY="warning" | ||||||||||||||||||||||||||||||||||||||
| ;; | ||||||||||||||||||||||||||||||||||||||
| 'alert' ) | ||||||||||||||||||||||||||||||||||||||
| PRIORITY="failure" | ||||||||||||||||||||||||||||||||||||||
| ;; | ||||||||||||||||||||||||||||||||||||||
| esac | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| if [ $STATEFUL_KEY == 'none' ]; then STATEFUL_KEY=; fi | ||||||||||||||||||||||||||||||||||||||
| if [ $STATELESS_URLS == 'none' ]; then STATELESS_URLS=; fi | ||||||||||||||||||||||||||||||||||||||
| if [ $TAGS == 'none' ]; then TAGS=; fi | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| # Remove any trailing slash | ||||||||||||||||||||||||||||||||||||||
| SERVER_URL=${SERVER_URL%/} | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| JSON="{\"urls\":\"$STATELESS_URLS\",\"tag\":\"$TAGS\",\"type\":\"$PRIORITY\",\"title\":\"$TITLE\",\"body\":\"$MESSAGE\"}" | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| curl -X POST \ | ||||||||||||||||||||||||||||||||||||||
| -H "Content-Type: application/json" \ | ||||||||||||||||||||||||||||||||||||||
| -d "$JSON" \ | ||||||||||||||||||||||||||||||||||||||
| $SERVER_URL/notify${STATEFUL_KEY:+/$STATEFUL_KEY} 2>&1 | ||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+38
to
+43
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Potential JSON injection and quoting issues in payload construction.
Example fix using -JSON="{\"urls\":\"$STATELESS_URLS\",\"tag\":\"$TAGS\",\"type\":\"$PRIORITY\",\"title\":\"$TITLE\",\"body\":\"$MESSAGE\"}"
+JSON=$(jq -n \
+ --arg urls "$STATELESS_URLS" \
+ --arg tag "$TAGS" \
+ --arg type "$PRIORITY" \
+ --arg title "$TITLE" \
+ --arg body "$MESSAGE" \
+ '{urls: $urls, tag: $tag, type: $type, title: $title, body: $body}')If
Would you like a ready-to-use Bash snippet for safe JSON construction without 📝 Committable suggestion
Suggested change
|
||||||||||||||||||||||||||||||||||||||
| ]]> | ||||||||||||||||||||||||||||||||||||||
| </Script> | ||||||||||||||||||||||||||||||||||||||
| </Agent> | ||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Bash script logic is clear, but input handling and quoting could be improved.
$STATEFUL_KEY,$STATELESS_URLS,$TAGS) in theifstatements, which can cause errors if variables contain spaces or are empty.Example fix: