mirror of
https://github.com/caronc/apprise-api.git
synced 2024-11-07 08:44:26 +01:00
Support for Apprise v1.7.1
This commit is contained in:
parent
4ad2bb1c03
commit
06275bedd1
@ -2,7 +2,7 @@
|
||||
|
||||
Take advantage of [Apprise](https://github.com/caronc/apprise) through your network with a user-friendly API.
|
||||
|
||||
- Send notifications to more than 95+ services.
|
||||
- Send notifications to more than 100+ services.
|
||||
- An incredibly lightweight gateway to Apprise.
|
||||
- A production ready micro-service at your disposal.
|
||||
|
||||
@ -112,7 +112,7 @@ The following architectures are supported: `amd64`, `arm/v7`, and `arm64`. The f
|
||||
|
||||
## Apprise URLs
|
||||
|
||||
📣 In order to trigger a notification, you first need to define one or more [Apprise URLs](https://github.com/caronc/apprise/wiki) to support the services you wish to leverage. Apprise supports over 95+ notification services today and is always expanding to add support for more! Visit <https://github.com/caronc/apprise/wiki> to see the ever-growing list of the services supported today.
|
||||
📣 In order to trigger a notification, you first need to define one or more [Apprise URLs](https://github.com/caronc/apprise/wiki) to support the services you wish to leverage. Visit <https://github.com/caronc/apprise/wiki> to see the ever-growing list of the services supported today.
|
||||
|
||||
## API Details
|
||||
|
||||
@ -437,4 +437,3 @@ a.add(config)
|
||||
# Send a test message
|
||||
a.notify('test message')
|
||||
```
|
||||
|
||||
|
@ -31,6 +31,9 @@ import json
|
||||
import apprise
|
||||
from inspect import cleandoc
|
||||
|
||||
# Grant access to our Notification Manager Singleton
|
||||
N_MGR = apprise.NotificationManager.NotificationManager()
|
||||
|
||||
|
||||
class NotifyTests(SimpleTestCase):
|
||||
"""
|
||||
@ -247,7 +250,7 @@ class NotifyTests(SimpleTestCase):
|
||||
# Disable Throttling to speed testing
|
||||
apprise.plugins.NotifyBase.request_rate_per_sec = 0
|
||||
# Ensure we're enabled for the purpose of our testing
|
||||
apprise.common.NOTIFY_SCHEMA_MAP['json'].enabled = True
|
||||
N_MGR['json'].enabled = True
|
||||
|
||||
# Prepare our response
|
||||
response = requests.Request()
|
||||
@ -339,7 +342,7 @@ class NotifyTests(SimpleTestCase):
|
||||
# Disable Throttling to speed testing
|
||||
apprise.plugins.NotifyBase.request_rate_per_sec = 0
|
||||
# Ensure we're enabled for the purpose of our testing
|
||||
apprise.common.NOTIFY_SCHEMA_MAP['json'].enabled = True
|
||||
N_MGR['json'].enabled = True
|
||||
|
||||
# Prepare our response
|
||||
response = requests.Request()
|
||||
@ -441,7 +444,7 @@ class NotifyTests(SimpleTestCase):
|
||||
# Disable Throttling to speed testing
|
||||
apprise.plugins.NotifyBase.request_rate_per_sec = 0
|
||||
# Ensure we're enabled for the purpose of our testing
|
||||
apprise.common.NOTIFY_SCHEMA_MAP['json'].enabled = True
|
||||
N_MGR['json'].enabled = True
|
||||
|
||||
# Prepare our response
|
||||
response = requests.Request()
|
||||
@ -931,7 +934,7 @@ class NotifyTests(SimpleTestCase):
|
||||
}
|
||||
|
||||
# Verify by default email is enabled
|
||||
assert apprise.common.NOTIFY_SCHEMA_MAP['mailto'].enabled is True
|
||||
assert N_MGR['mailto'].enabled is True
|
||||
|
||||
# Send our service with the `mailto://` denied
|
||||
with override_settings(APPRISE_ALLOW_SERVICES=""):
|
||||
@ -948,11 +951,10 @@ class NotifyTests(SimpleTestCase):
|
||||
assert mock_send.call_count == 0
|
||||
|
||||
# What actually took place behind close doors:
|
||||
assert \
|
||||
apprise.common.NOTIFY_SCHEMA_MAP['mailto'].enabled is False
|
||||
assert N_MGR['mailto'].enabled is False
|
||||
|
||||
# Reset our flag (for next test)
|
||||
apprise.common.NOTIFY_SCHEMA_MAP['mailto'].enabled = True
|
||||
N_MGR['mailto'].enabled = True
|
||||
|
||||
# Reset Mock
|
||||
mock_send.reset_mock()
|
||||
@ -972,8 +974,7 @@ class NotifyTests(SimpleTestCase):
|
||||
assert mock_send.call_count == 1
|
||||
|
||||
# Verify that mailto was never turned off
|
||||
assert \
|
||||
apprise.common.NOTIFY_SCHEMA_MAP['mailto'].enabled is True
|
||||
assert N_MGR['mailto'].enabled is True
|
||||
|
||||
# Reset Mock
|
||||
mock_send.reset_mock()
|
||||
@ -993,8 +994,7 @@ class NotifyTests(SimpleTestCase):
|
||||
assert mock_send.call_count == 1
|
||||
|
||||
# Verify email was never turned off
|
||||
assert \
|
||||
apprise.common.NOTIFY_SCHEMA_MAP['mailto'].enabled is True
|
||||
assert N_MGR['mailto'].enabled is True
|
||||
|
||||
# Reset Mock
|
||||
mock_send.reset_mock()
|
||||
@ -1014,8 +1014,7 @@ class NotifyTests(SimpleTestCase):
|
||||
assert mock_send.call_count == 1
|
||||
|
||||
# Verify email was never turned off
|
||||
assert \
|
||||
apprise.common.NOTIFY_SCHEMA_MAP['mailto'].enabled is True
|
||||
assert N_MGR['mailto'].enabled is True
|
||||
|
||||
# Reset Mock
|
||||
mock_send.reset_mock()
|
||||
@ -1035,12 +1034,10 @@ class NotifyTests(SimpleTestCase):
|
||||
assert mock_send.call_count == 0
|
||||
|
||||
# What actually took place behind close doors:
|
||||
assert \
|
||||
apprise.common.NOTIFY_SCHEMA_MAP['mailto']\
|
||||
.enabled is False
|
||||
assert N_MGR['mailto'].enabled is False
|
||||
|
||||
# Reset our flag (for next test)
|
||||
apprise.common.NOTIFY_SCHEMA_MAP['mailto'].enabled = True
|
||||
N_MGR['mailto'].enabled = True
|
||||
|
||||
# Reset Mock
|
||||
mock_send.reset_mock()
|
||||
@ -1060,8 +1057,7 @@ class NotifyTests(SimpleTestCase):
|
||||
assert mock_send.call_count == 1
|
||||
|
||||
# nothing was changed
|
||||
assert \
|
||||
apprise.common.NOTIFY_SCHEMA_MAP['mailto'].enabled is True
|
||||
assert N_MGR['mailto'].enabled is True
|
||||
|
||||
@override_settings(APPRISE_RECURSION_MAX=1)
|
||||
@mock.patch('apprise.Apprise.notify')
|
||||
|
@ -31,6 +31,9 @@ import requests
|
||||
import json
|
||||
import apprise
|
||||
|
||||
# Grant access to our Notification Manager Singleton
|
||||
N_MGR = apprise.NotificationManager.NotificationManager()
|
||||
|
||||
|
||||
class StatelessNotifyTests(SimpleTestCase):
|
||||
"""
|
||||
@ -202,7 +205,7 @@ class StatelessNotifyTests(SimpleTestCase):
|
||||
"""
|
||||
|
||||
# Ensure we're enabled for the purpose of our testing
|
||||
apprise.common.NOTIFY_SCHEMA_MAP['mailto'].enabled = True
|
||||
N_MGR['mailto'].enabled = True
|
||||
|
||||
# Set our return value; first we return a true, then we fail
|
||||
# on the second call
|
||||
@ -488,7 +491,7 @@ class StatelessNotifyTests(SimpleTestCase):
|
||||
)
|
||||
|
||||
# Ensure we're enabled for the purpose of our testing
|
||||
apprise.common.NOTIFY_SCHEMA_MAP['json'].enabled = True
|
||||
N_MGR['json'].enabled = True
|
||||
|
||||
# Reset Mock
|
||||
mock_send.reset_mock()
|
||||
@ -508,11 +511,10 @@ class StatelessNotifyTests(SimpleTestCase):
|
||||
assert mock_send.call_count == 0
|
||||
|
||||
# What actually took place behind close doors:
|
||||
assert \
|
||||
apprise.common.NOTIFY_SCHEMA_MAP['json'].enabled is False
|
||||
assert N_MGR['json'].enabled is False
|
||||
|
||||
# Reset our flag (for next test)
|
||||
apprise.common.NOTIFY_SCHEMA_MAP['json'].enabled = True
|
||||
N_MGR['json'].enabled = True
|
||||
|
||||
# Reset Mock
|
||||
mock_send.reset_mock()
|
||||
@ -532,7 +534,7 @@ class StatelessNotifyTests(SimpleTestCase):
|
||||
assert mock_send.call_count == 1
|
||||
|
||||
# Verify that json was never turned off
|
||||
assert apprise.common.NOTIFY_SCHEMA_MAP['json'].enabled is True
|
||||
assert N_MGR['json'].enabled is True
|
||||
|
||||
# Reset Mock
|
||||
mock_send.reset_mock()
|
||||
@ -552,7 +554,7 @@ class StatelessNotifyTests(SimpleTestCase):
|
||||
assert mock_send.call_count == 1
|
||||
|
||||
# Verify email was never turned off
|
||||
assert apprise.common.NOTIFY_SCHEMA_MAP['json'].enabled is True
|
||||
assert N_MGR['json'].enabled is True
|
||||
|
||||
# Reset Mock
|
||||
mock_send.reset_mock()
|
||||
@ -572,7 +574,7 @@ class StatelessNotifyTests(SimpleTestCase):
|
||||
assert mock_send.call_count == 1
|
||||
|
||||
# Verify email was never turned off
|
||||
assert apprise.common.NOTIFY_SCHEMA_MAP['json'].enabled is True
|
||||
assert N_MGR['json'].enabled is True
|
||||
|
||||
# Reset Mock
|
||||
mock_send.reset_mock()
|
||||
@ -592,11 +594,10 @@ class StatelessNotifyTests(SimpleTestCase):
|
||||
assert mock_send.call_count == 0
|
||||
|
||||
# What actually took place behind close doors:
|
||||
assert \
|
||||
apprise.common.NOTIFY_SCHEMA_MAP['json'].enabled is False
|
||||
assert N_MGR['json'].enabled is False
|
||||
|
||||
# Reset our flag (for next test)
|
||||
apprise.common.NOTIFY_SCHEMA_MAP['json'].enabled = True
|
||||
N_MGR['json'].enabled = True
|
||||
|
||||
# Reset Mock
|
||||
mock_send.reset_mock()
|
||||
@ -616,4 +617,4 @@ class StatelessNotifyTests(SimpleTestCase):
|
||||
assert mock_send.call_count == 1
|
||||
|
||||
# nothing was changed
|
||||
assert apprise.common.NOTIFY_SCHEMA_MAP['json'].enabled is True
|
||||
assert N_MGR['json'].enabled is True
|
||||
|
@ -66,8 +66,14 @@ STORE_MODES = (
|
||||
AppriseStoreMode.DISABLED,
|
||||
)
|
||||
|
||||
# Access our Attachment Manager Singleton
|
||||
A_MGR = apprise.AttachmentManager.AttachmentManager()
|
||||
|
||||
class Attachment(apprise.attachment.AttachFile):
|
||||
# Access our Notification Manager Singleton
|
||||
N_MGR = apprise.NotificationManager.NotificationManager()
|
||||
|
||||
|
||||
class Attachment(A_MGR['file']):
|
||||
"""
|
||||
A Light Weight Attachment Object for Auto-cleanup that wraps the Apprise
|
||||
Attachments
|
||||
@ -79,6 +85,7 @@ class Attachment(apprise.attachment.AttachFile):
|
||||
"""
|
||||
self._filename = filename
|
||||
self.delete = delete
|
||||
self._path = None
|
||||
try:
|
||||
os.makedirs(settings.APPRISE_ATTACH_DIR, exist_ok=True)
|
||||
|
||||
@ -121,7 +128,7 @@ class Attachment(apprise.attachment.AttachFile):
|
||||
"""
|
||||
De-Construtor is used to tidy up files during garbage collection
|
||||
"""
|
||||
if self.delete:
|
||||
if self.delete and self._path:
|
||||
try:
|
||||
os.remove(self._path)
|
||||
except FileNotFoundError:
|
||||
@ -542,33 +549,7 @@ def apply_global_filters():
|
||||
for x in re.split(r'[ ,]+', settings.APPRISE_ALLOW_SERVICES)
|
||||
if alphanum_re.match(x)]
|
||||
|
||||
for plugin in set(apprise.common.NOTIFY_SCHEMA_MAP.values()):
|
||||
if entries:
|
||||
# Get a list of the current schema's associated with
|
||||
# a given plugin
|
||||
schemas = set(apprise.plugins.details(plugin)
|
||||
['tokens']['schema']['values'])
|
||||
|
||||
# Check what was defined and see if there is a hit
|
||||
for entry in entries:
|
||||
if entry in schemas:
|
||||
# We had a hit; we're done
|
||||
break
|
||||
|
||||
if entry in schemas:
|
||||
entries.remove(entry)
|
||||
# We can keep this plugin enabled and move along to the
|
||||
# next one...
|
||||
continue
|
||||
|
||||
# if we reach here, we have to block our plugin
|
||||
plugin.enabled = False
|
||||
|
||||
for entry in entries:
|
||||
# Generate some noise for those who have bad configurations
|
||||
logger.warning(
|
||||
'APPRISE_ALLOW_SERVICES plugin %s:// was not found - '
|
||||
'ignoring.', entry)
|
||||
N_MGR.enable_only(*entries)
|
||||
|
||||
elif settings.APPRISE_DENY_SERVICES:
|
||||
alphanum_re = re.compile(
|
||||
@ -578,15 +559,7 @@ def apply_global_filters():
|
||||
for x in re.split(r'[ ,]+', settings.APPRISE_DENY_SERVICES)
|
||||
if alphanum_re.match(x)]
|
||||
|
||||
for name in entries:
|
||||
try:
|
||||
# Force plugin to be disabled
|
||||
apprise.common.NOTIFY_SCHEMA_MAP[name].enabled = False
|
||||
|
||||
except KeyError:
|
||||
logger.warning(
|
||||
'APPRISE_DENY_SERVICES plugin %s:// was not found -'
|
||||
' ignoring.', name)
|
||||
N_MGR.disable(*entries)
|
||||
|
||||
|
||||
def gen_unique_config_id():
|
||||
|
@ -10,7 +10,7 @@
|
||||
# apprise @ git+https://github.com/caronc/apprise@custom-tag-or-version
|
||||
|
||||
## 3. The below grabs our stable version (generally the best choice):
|
||||
apprise == 1.6.0
|
||||
apprise == 1.7.1
|
||||
|
||||
## Apprise API Minimum Requirements
|
||||
django
|
||||
|
Loading…
Reference in New Issue
Block a user