-
-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support "attach" keyword (alias of "attachment") (#173)
- Loading branch information
Showing
6 changed files
with
150 additions
and
8 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -168,6 +168,13 @@ curl -X POST -d 'urls=mailto://user:[email protected]' \ | |
curl -X POST -d '{"urls": "mailto://user:[email protected]", "body":"test message"}' \ | ||
-H "Content-Type: application/json" \ | ||
http://localhost:8000/notify | ||
|
||
# attach= is an alias of attachment= | ||
# Send a notification with a URL based attachment | ||
curl -X POST \ | ||
-F 'urls=mailto://user:[email protected]' \ | ||
-F attach=attach=https://raw.githubusercontent.com/caronc/apprise/master/apprise/assets/themes/default/apprise-logo.png \ | ||
http://localhost:8000/notify | ||
``` | ||
|
||
You can also send notifications that are URLs. Apprise will download the item so that it can send it along to all end points that should be notified about it. | ||
|
@@ -252,6 +259,13 @@ curl -X POST \ | |
-F [email protected] \ | ||
-F attach2=@/my/path/to/Apprise.doc \ | ||
http://localhost:8000/notify/abc123 | ||
|
||
# attach= is an alias of attachment= | ||
# Send a notification with a URL based attachment | ||
curl -X POST \ | ||
-F 'urls=mailto://user:[email protected]' \ | ||
-F attach=attach=https://raw.githubusercontent.com/caronc/apprise/master/apprise/assets/themes/default/apprise-logo.png \ | ||
http://localhost:8000/notify/abc123 | ||
``` | ||
|
||
🏷️ You can also leverage *tagging* which allows you to associate one or more tags with your Apprise URLs. By doing this, notifications only need to be referred to by their easy to remember notify tag name such as `devops`, `admin`, `family`, etc. You can very easily group more than one notification service under the same *tag* allowing you to notify a group of services at once. This is accomplished through configuration files ([documented here](https://github.com/caronc/apprise/wiki/config)) that can be saved to the persistent storage previously associated with a `{KEY}`. | ||
|
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 |
---|---|---|
|
@@ -115,6 +115,12 @@ <h6>{% trans "Using CURL" %}</h6> | |
-F [email protected] \<br/> | ||
-F attach2=@/my/path/to/Apprise.doc \<br/> | ||
http{% if request.is_secure %}s{% endif %}://{{request.META.HTTP_HOST}}{{BASE_URL}}/notify/<em>{{key}}</em></code></pre> | ||
{% blocktrans %}Sends a notification to our endpoints with an attachment{% endblocktrans %} | ||
<pre><code class="bash"> | ||
curl -X POST \<br/> | ||
-F "tag=all" \ <br/> | ||
-F "attach=https://raw.githubusercontent.com/caronc/apprise/master/apprise/assets/themes/default/apprise-logo.png" \ <br/> | ||
"{{request.scheme}}://{{request.META.HTTP_HOST}}{{BASE_URL}}/notify/<em>{{key}}</em>"</code></pre> | ||
</p> | ||
</div> | ||
<div class="section"> | ||
|
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 |
---|---|---|
|
@@ -99,6 +99,11 @@ <h4>{% trans "Stateless Endpoints" %}</h4> | |
-F [email protected] \ <br/> | ||
"{{request.scheme}}://{{request.META.HTTP_HOST}}{{BASE_URL}}/notify/" | ||
</code></pre> | ||
<pre><code class="bash"> | ||
# {% blocktrans %}Send an web based file attachment to a <a href="https://github.com/caronc/apprise/wiki/Notify_discord" target="_blank">Discord</a> server:{% endblocktrans %}<br/> | ||
curl -X POST -F 'urls=discord://credentials' \<br/> | ||
-F "attach=https://raw.githubusercontent.com/caronc/apprise/master/apprise/assets/themes/default/apprise-logo.png" \ <br/> | ||
"{{request.scheme}}://{{request.META.HTTP_HOST}}{{BASE_URL}}/notify/"</code></pre> | ||
</div> | ||
</li> | ||
<li> | ||
|
@@ -492,6 +497,12 @@ <h4>{% trans "Persistent Store Endpoints" %}</h4> | |
-F "tag=all" \ <br/> | ||
-F "body=test body" \ <br/> | ||
-F "title=test title" \ <br/> | ||
"{{request.scheme}}://{{request.META.HTTP_HOST}}{{BASE_URL}}/notify/<em>{{key}}</em>"</code></pre> | ||
<pre><code class="bash"> | ||
# {% blocktrans %}Sends a notification to our endpoints with an attachment{% endblocktrans %}<br/> | ||
curl -X POST \<br/> | ||
-F "tag=all" \ <br/> | ||
-F "attach=https://raw.githubusercontent.com/caronc/apprise/master/apprise/assets/themes/default/apprise-logo.png" \ <br/> | ||
"{{request.scheme}}://{{request.META.HTTP_HOST}}{{BASE_URL}}/notify/<em>{{key}}</em>"</code></pre> | ||
<pre><code class="bash"> | ||
# {% blocktrans %}Notifies all URLs assigned the <em>devops</em> tag{% endblocktrans %}<br/> | ||
|
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 |
---|---|---|
|
@@ -250,6 +250,49 @@ def test_partial_notify(self, mock_notify): | |
assert response.status_code == 400 | ||
assert mock_notify.call_count == 0 | ||
|
||
# Reset our mock object | ||
mock_notify.reset_mock() | ||
|
||
# Preare our form data (support attach keyword) | ||
form_data = { | ||
'body': 'test notifiction', | ||
'urls': ', '.join([ | ||
'mailto://user:[email protected]', | ||
'mailto://user:[email protected]', | ||
]), | ||
'attach': 'https://localhost/invalid/path/to/image.png', | ||
} | ||
|
||
# Send our notification | ||
response = self.client.post('/notify', form_data) | ||
# We fail because we couldn't retrieve our attachment | ||
assert response.status_code == 400 | ||
assert mock_notify.call_count == 0 | ||
|
||
# Reset our mock object | ||
mock_notify.reset_mock() | ||
|
||
# Preare our json data (and support attach keyword as alias) | ||
json_data = { | ||
'body': 'test notifiction', | ||
'urls': ', '.join([ | ||
'mailto://user:[email protected]', | ||
'mailto://user:[email protected]', | ||
]), | ||
'attach': 'https://localhost/invalid/path/to/image.png', | ||
} | ||
|
||
# Same results | ||
response = self.client.post( | ||
'/notify/', | ||
data=json.dumps(json_data), | ||
content_type='application/json', | ||
) | ||
|
||
# We fail because we couldn't retrieve our attachment | ||
assert response.status_code == 400 | ||
assert mock_notify.call_count == 0 | ||
|
||
@override_settings(APPRISE_RECURSION_MAX=1) | ||
@mock.patch('apprise.Apprise.notify') | ||
def test_stateless_notify_recursion(self, mock_notify): | ||
|
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