mirror of https://github.com/caronc/apprise
refactored + testing added
parent
88564d4d67
commit
5949e757fa
|
@ -50,6 +50,7 @@ The table below identifies the services this tool supports and some example serv
|
||||||
| [Matrix](https://github.com/caronc/apprise/wiki/Notify_matrix) | matrix:// or matrixs:// | (TCP) 80 or 443 | matrix://hostname<br />matrix://user@hostname<br />matrixs://user:pass@hostname:port/#room_alias<br />matrixs://user:pass@hostname:port/!room_id<br />matrixs://user:pass@hostname:port/#room_alias/!room_id/#room2<br />matrixs://token@hostname:port/?webhook=matrix<br />matrix://user:token@hostname/?webhook=slack&format=markdown
|
| [Matrix](https://github.com/caronc/apprise/wiki/Notify_matrix) | matrix:// or matrixs:// | (TCP) 80 or 443 | matrix://hostname<br />matrix://user@hostname<br />matrixs://user:pass@hostname:port/#room_alias<br />matrixs://user:pass@hostname:port/!room_id<br />matrixs://user:pass@hostname:port/#room_alias/!room_id/#room2<br />matrixs://token@hostname:port/?webhook=matrix<br />matrix://user:token@hostname/?webhook=slack&format=markdown
|
||||||
| [Mattermost](https://github.com/caronc/apprise/wiki/Notify_mattermost) | mmost:// | (TCP) 8065 | mmost://hostname/authkey<br />mmost://hostname:80/authkey<br />mmost://user@hostname:80/authkey<br />mmost://hostname/authkey?channel=channel<br />mmosts://hostname/authkey<br />mmosts://user@hostname/authkey<br />
|
| [Mattermost](https://github.com/caronc/apprise/wiki/Notify_mattermost) | mmost:// | (TCP) 8065 | mmost://hostname/authkey<br />mmost://hostname:80/authkey<br />mmost://user@hostname:80/authkey<br />mmost://hostname/authkey?channel=channel<br />mmosts://hostname/authkey<br />mmosts://user@hostname/authkey<br />
|
||||||
| [Microsoft Teams](https://github.com/caronc/apprise/wiki/Notify_msteams) | msteams:// | (TCP) 443 | msteams://TokenA/TokenB/TokenC/
|
| [Microsoft Teams](https://github.com/caronc/apprise/wiki/Notify_msteams) | msteams:// | (TCP) 443 | msteams://TokenA/TokenB/TokenC/
|
||||||
|
| [NextCloud](https://github.com/caronc/apprise/wiki/Notify_nextcloud) | ncloud:// or nclouds:// | (TCP) 80 or 443 | ncloud://adminuser:pass@host/User<br/>nclouds://adminuser:pass@host/User1/User2/UserN
|
||||||
| [Notica](https://github.com/caronc/apprise/wiki/Notify_notica) | notica:// | (TCP) 443 | notica://Token/
|
| [Notica](https://github.com/caronc/apprise/wiki/Notify_notica) | notica:// | (TCP) 443 | notica://Token/
|
||||||
| [Notifico](https://github.com/caronc/apprise/wiki/Notify_notifico) | notifico:// | (TCP) 443 | notifico://ProjectID/MessageHook/
|
| [Notifico](https://github.com/caronc/apprise/wiki/Notify_notifico) | notifico:// | (TCP) 443 | notifico://ProjectID/MessageHook/
|
||||||
| [Prowl](https://github.com/caronc/apprise/wiki/Notify_prowl) | prowl:// | (TCP) 443 | prowl://apikey<br />prowl://apikey/providerkey
|
| [Prowl](https://github.com/caronc/apprise/wiki/Notify_prowl) | prowl:// | (TCP) 443 | prowl://apikey<br />prowl://apikey/providerkey
|
||||||
|
|
|
@ -43,10 +43,10 @@ class NotifyNextCloud(NotifyBase):
|
||||||
service_url = 'https://github.com/nextcloud/notifications'
|
service_url = 'https://github.com/nextcloud/notifications'
|
||||||
|
|
||||||
# Insecure protocol (for those self hosted requests)
|
# Insecure protocol (for those self hosted requests)
|
||||||
protocol = 'nextcloud'
|
protocol = 'ncloud'
|
||||||
|
|
||||||
# The default protocol (this is secure for notica)
|
# The default protocol (this is secure for notica)
|
||||||
secure_protocol = 'nextclouds'
|
secure_protocol = 'nclouds'
|
||||||
|
|
||||||
# A URL that takes you to the setup/help of the specific protocol
|
# A URL that takes you to the setup/help of the specific protocol
|
||||||
setup_url = 'https://github.com/caronc/apprise/wiki/Notify_nextcloud'
|
setup_url = 'https://github.com/caronc/apprise/wiki/Notify_nextcloud'
|
||||||
|
@ -89,13 +89,11 @@ class NotifyNextCloud(NotifyBase):
|
||||||
'user': {
|
'user': {
|
||||||
'name': _('Username'),
|
'name': _('Username'),
|
||||||
'type': 'string',
|
'type': 'string',
|
||||||
'required': True,
|
|
||||||
},
|
},
|
||||||
'password': {
|
'password': {
|
||||||
'name': _('Password'),
|
'name': _('Password'),
|
||||||
'type': 'string',
|
'type': 'string',
|
||||||
'private': True,
|
'private': True,
|
||||||
'required': True,
|
|
||||||
},
|
},
|
||||||
'target_user': {
|
'target_user': {
|
||||||
'name': _('Target User'),
|
'name': _('Target User'),
|
||||||
|
@ -162,8 +160,9 @@ class NotifyNextCloud(NotifyBase):
|
||||||
else:
|
else:
|
||||||
payload['shortMessage'] = body
|
payload['shortMessage'] = body
|
||||||
|
|
||||||
# Auth is used for SELFHOSTED queries
|
auth = None
|
||||||
auth = (self.user, self.password)
|
if self.user:
|
||||||
|
auth = (self.user, self.password)
|
||||||
|
|
||||||
notify_url = self.notify_url.format(
|
notify_url = self.notify_url.format(
|
||||||
schema='https' if self.secure else 'http',
|
schema='https' if self.secure else 'http',
|
||||||
|
@ -182,7 +181,7 @@ class NotifyNextCloud(NotifyBase):
|
||||||
|
|
||||||
try:
|
try:
|
||||||
r = requests.post(
|
r = requests.post(
|
||||||
notify_url.format(token=self.token),
|
notify_url,
|
||||||
data=payload,
|
data=payload,
|
||||||
headers=headers,
|
headers=headers,
|
||||||
auth=auth,
|
auth=auth,
|
||||||
|
@ -238,11 +237,18 @@ class NotifyNextCloud(NotifyBase):
|
||||||
# Append our headers into our args
|
# Append our headers into our args
|
||||||
args.update({'+{}'.format(k): v for k, v in self.headers.items()})
|
args.update({'+{}'.format(k): v for k, v in self.headers.items()})
|
||||||
|
|
||||||
auth = '{user}:{password}@'.format(
|
# Determine Authentication
|
||||||
user=NotifyNextCloud.quote(self.user, safe=''),
|
auth = ''
|
||||||
password=self.pprint(
|
if self.user and self.password:
|
||||||
self.password, privacy, mode=PrivacyMode.Secret, safe=''),
|
auth = '{user}:{password}@'.format(
|
||||||
)
|
user=NotifyNextCloud.quote(self.user, safe=''),
|
||||||
|
password=self.pprint(
|
||||||
|
self.password, privacy, mode=PrivacyMode.Secret, safe=''),
|
||||||
|
)
|
||||||
|
elif self.user:
|
||||||
|
auth = '{user}@'.format(
|
||||||
|
user=NotifyNextCloud.quote(self.user, safe=''),
|
||||||
|
)
|
||||||
|
|
||||||
default_port = 443 if self.secure else 80
|
default_port = 443 if self.secure else 80
|
||||||
|
|
||||||
|
@ -254,8 +260,6 @@ class NotifyNextCloud(NotifyBase):
|
||||||
hostname=NotifyNextCloud.quote(self.host, safe=''),
|
hostname=NotifyNextCloud.quote(self.host, safe=''),
|
||||||
port='' if self.port is None or self.port == default_port
|
port='' if self.port is None or self.port == default_port
|
||||||
else ':{}'.format(self.port),
|
else ':{}'.format(self.port),
|
||||||
fullpath=NotifyNextCloud.quote(
|
|
||||||
self.fullpath, safe='/'),
|
|
||||||
targets='/'.join([NotifyNextCloud.quote(x)
|
targets='/'.join([NotifyNextCloud.quote(x)
|
||||||
for x in self.targets]),
|
for x in self.targets]),
|
||||||
args=NotifyNextCloud.urlencode(args),
|
args=NotifyNextCloud.urlencode(args),
|
||||||
|
@ -268,7 +272,8 @@ class NotifyNextCloud(NotifyBase):
|
||||||
us to substantiate this object.
|
us to substantiate this object.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
results = NotifyBase.parse_url(url, verify_host=False)
|
|
||||||
|
results = NotifyBase.parse_url(url)
|
||||||
if not results:
|
if not results:
|
||||||
# We're done early as we couldn't load the results
|
# We're done early as we couldn't load the results
|
||||||
return results
|
return results
|
||||||
|
|
|
@ -49,10 +49,11 @@ it easy to access:
|
||||||
|
|
||||||
Boxcar, ClickSend, Discord, E-Mail, Emby, Faast, Flock, Gitter, Gotify, Growl,
|
Boxcar, ClickSend, Discord, E-Mail, Emby, Faast, Flock, Gitter, Gotify, Growl,
|
||||||
IFTTT, Join, KODI, Kumulos, Mailgun, MatterMost, Matrix, Microsoft Windows
|
IFTTT, Join, KODI, Kumulos, Mailgun, MatterMost, Matrix, Microsoft Windows
|
||||||
Notifications, Microsoft Teams, MessageBird, MSG91, Nexmo, Notica, Notifico,
|
Notifications, Microsoft Teams, MessageBird, MSG91, Nexmo, NextCloud, Notica,
|
||||||
Notify MyAndroid, Prowl, Pushalot, PushBullet, Pushjet, Pushover, PushSafer,
|
Notifico, Notify MyAndroid, Prowl, Pushalot, PushBullet, Pushjet, Pushover,
|
||||||
Rocket.Chat, SendGrid, SimplePush, Slack, Super Toasty, Stride, Syslog,
|
PushSafer, Rocket.Chat, SendGrid, SimplePush, Slack, Super Toasty, Stride,
|
||||||
Techulus Push, Telegram, Twilio, Twitter, Twist, XBMC, XMPP, Webex Teams}
|
Syslog, Techulus Push, Telegram, Twilio, Twitter, Twist, XBMC, XMPP,
|
||||||
|
Webex Teams}
|
||||||
|
|
||||||
Name: python-%{pypi_name}
|
Name: python-%{pypi_name}
|
||||||
Version: 0.8.2
|
Version: 0.8.2
|
||||||
|
|
8
setup.py
8
setup.py
|
@ -72,10 +72,10 @@ setup(
|
||||||
keywords='Push Notifications Alerts Email AWS SNS Boxcar ClickSend '
|
keywords='Push Notifications Alerts Email AWS SNS Boxcar ClickSend '
|
||||||
'Discord Dbus Emby Faast Flock Gitter Gnome Gotify Growl IFTTT Join '
|
'Discord Dbus Emby Faast Flock Gitter Gnome Gotify Growl IFTTT Join '
|
||||||
'KODI Kumulos Mailgun Matrix Mattermost MessageBird MSG91 Nexmo '
|
'KODI Kumulos Mailgun Matrix Mattermost MessageBird MSG91 Nexmo '
|
||||||
'Notica, Notifico Prowl PushBullet Pushjet Pushed Pushover PushSafer '
|
'NextCloud Notica, Notifico Prowl PushBullet Pushjet Pushed Pushover '
|
||||||
'Rocket.Chat Ryver SendGrid SimplePush Slack Stride Syslog Techulus '
|
'PushSafer Rocket.Chat Ryver SendGrid SimplePush Slack Stride Syslog '
|
||||||
'Push Telegram Twilio Twist Twitter XBMC Microsoft MSTeams Windows '
|
'Techulus Push Telegram Twilio Twist Twitter XBMC Microsoft MSTeams '
|
||||||
'Webex CLI API',
|
'Windows Webex CLI API',
|
||||||
author='Chris Caron',
|
author='Chris Caron',
|
||||||
author_email='lead2gold@gmail.com',
|
author_email='lead2gold@gmail.com',
|
||||||
packages=find_packages(),
|
packages=find_packages(),
|
||||||
|
|
|
@ -1737,6 +1737,72 @@ TEST_URLS = (
|
||||||
'test_requests_exceptions': True,
|
'test_requests_exceptions': True,
|
||||||
}),
|
}),
|
||||||
|
|
||||||
|
##################################
|
||||||
|
# NotifyNextCloud
|
||||||
|
##################################
|
||||||
|
('ncloud://:@/', {
|
||||||
|
'instance': None,
|
||||||
|
}),
|
||||||
|
('ncloud://', {
|
||||||
|
'instance': None,
|
||||||
|
}),
|
||||||
|
('nclouds://', {
|
||||||
|
# No hostname
|
||||||
|
'instance': None,
|
||||||
|
}),
|
||||||
|
('ncloud://localhost', {
|
||||||
|
# No user specified
|
||||||
|
'instance': TypeError,
|
||||||
|
}),
|
||||||
|
('ncloud://localhost/admin', {
|
||||||
|
'instance': plugins.NotifyNextCloud,
|
||||||
|
}),
|
||||||
|
('ncloud://user@localhost/admin', {
|
||||||
|
'instance': plugins.NotifyNextCloud,
|
||||||
|
}),
|
||||||
|
('ncloud://user@localhost?to=user1,user2', {
|
||||||
|
'instance': plugins.NotifyNextCloud,
|
||||||
|
}),
|
||||||
|
('ncloud://user:pass@localhost/user1/user2', {
|
||||||
|
'instance': plugins.NotifyNextCloud,
|
||||||
|
|
||||||
|
# Our expected url(privacy=True) startswith() response:
|
||||||
|
'privacy_url': 'ncloud://user:****@localhost/user1/user2',
|
||||||
|
}),
|
||||||
|
('ncloud://user:pass@localhost:8080/admin', {
|
||||||
|
'instance': plugins.NotifyNextCloud,
|
||||||
|
}),
|
||||||
|
('nclouds://user:pass@localhost/admin', {
|
||||||
|
'instance': plugins.NotifyNextCloud,
|
||||||
|
|
||||||
|
# Our expected url(privacy=True) startswith() response:
|
||||||
|
'privacy_url': 'nclouds://user:****@localhost/admin',
|
||||||
|
}),
|
||||||
|
('nclouds://user:pass@localhost:8080/admin/', {
|
||||||
|
'instance': plugins.NotifyNextCloud,
|
||||||
|
}),
|
||||||
|
('ncloud://localhost:8080/admin?-HeaderKey=HeaderValue', {
|
||||||
|
'instance': plugins.NotifyNextCloud,
|
||||||
|
}),
|
||||||
|
('ncloud://user:pass@localhost:8081/admin', {
|
||||||
|
'instance': plugins.NotifyNextCloud,
|
||||||
|
# force a failure
|
||||||
|
'response': False,
|
||||||
|
'requests_response_code': requests.codes.internal_server_error,
|
||||||
|
}),
|
||||||
|
('ncloud://user:pass@localhost:8082/admin', {
|
||||||
|
'instance': plugins.NotifyNextCloud,
|
||||||
|
# throw a bizzare code forcing us to fail to look it up
|
||||||
|
'response': False,
|
||||||
|
'requests_response_code': 999,
|
||||||
|
}),
|
||||||
|
('ncloud://user:pass@localhost:8083/user1/user2/user3', {
|
||||||
|
'instance': plugins.NotifyNextCloud,
|
||||||
|
# Throws a series of connection and transfer exceptions when this flag
|
||||||
|
# is set and tests that we gracfully handle them
|
||||||
|
'test_requests_exceptions': True,
|
||||||
|
}),
|
||||||
|
|
||||||
##################################
|
##################################
|
||||||
# NotifyProwl
|
# NotifyProwl
|
||||||
##################################
|
##################################
|
||||||
|
|
Loading…
Reference in New Issue