mirror of
https://github.com/caronc/apprise.git
synced 2024-11-22 08:04:02 +01:00
better fullpath support in XML and JSON services
This commit is contained in:
parent
5ec5414261
commit
031f6776cc
@ -68,7 +68,9 @@ class NotifyJSON(NotifyBase):
|
||||
'{schema}://{user}:{password}@{host}:{port}',
|
||||
)
|
||||
|
||||
# Define our tokens
|
||||
# Define our tokens; these are the minimum tokens required required to
|
||||
# be passed into this function (as arguments). The syntax appends any
|
||||
# previously defined in the base package and builds onto them
|
||||
template_tokens = dict(NotifyBase.template_tokens, **{
|
||||
'host': {
|
||||
'name': _('Hostname'),
|
||||
@ -151,12 +153,13 @@ class NotifyJSON(NotifyBase):
|
||||
|
||||
default_port = 443 if self.secure else 80
|
||||
|
||||
return '{schema}://{auth}{hostname}{port}/?{args}'.format(
|
||||
return '{schema}://{auth}{hostname}{port}{fullpath}/?{args}'.format(
|
||||
schema=self.secure_protocol if self.secure else self.protocol,
|
||||
auth=auth,
|
||||
hostname=NotifyJSON.quote(self.host, safe=''),
|
||||
port='' if self.port is None or self.port == default_port
|
||||
else ':{}'.format(self.port),
|
||||
fullpath=NotifyJSON.quote(self.fullpath, safe='/'),
|
||||
args=NotifyJSON.urlencode(args),
|
||||
)
|
||||
|
||||
|
@ -210,7 +210,7 @@ class NotifyNotica(NotifyBase):
|
||||
notify_url += ':%d' % self.port
|
||||
|
||||
notify_url += '{fullpath}?token={token}'.format(
|
||||
fullpath=self.fullpath.strip('/'),
|
||||
fullpath=self.fullpath,
|
||||
token=self.token)
|
||||
|
||||
self.logger.debug('Notica POST URL: %s (cert_verify=%r)' % (
|
||||
|
@ -58,7 +58,6 @@ class NotifyXML(NotifyBase):
|
||||
# local anyway
|
||||
request_rate_per_sec = 0
|
||||
|
||||
# Define object templates
|
||||
# Define object templates
|
||||
templates = (
|
||||
'{schema}://{host}',
|
||||
@ -169,12 +168,13 @@ class NotifyXML(NotifyBase):
|
||||
|
||||
default_port = 443 if self.secure else 80
|
||||
|
||||
return '{schema}://{auth}{hostname}{port}/?{args}'.format(
|
||||
return '{schema}://{auth}{hostname}{port}{fullpath}/?{args}'.format(
|
||||
schema=self.secure_protocol if self.secure else self.protocol,
|
||||
auth=auth,
|
||||
hostname=NotifyXML.quote(self.host, safe=''),
|
||||
port='' if self.port is None or self.port == default_port
|
||||
else ':{}'.format(self.port),
|
||||
fullpath=NotifyXML.quote(self.fullpath, safe='/'),
|
||||
args=NotifyXML.urlencode(args),
|
||||
)
|
||||
|
||||
|
@ -813,6 +813,9 @@ TEST_URLS = (
|
||||
##################################
|
||||
# NotifyJSON
|
||||
##################################
|
||||
('json://:@/', {
|
||||
'instance': None,
|
||||
}),
|
||||
('json://', {
|
||||
'instance': None,
|
||||
}),
|
||||
@ -845,6 +848,8 @@ TEST_URLS = (
|
||||
}),
|
||||
('jsons://localhost:8080/path/', {
|
||||
'instance': plugins.NotifyJSON,
|
||||
# Our expected url(privacy=True) startswith() response:
|
||||
'privacy_url': 'jsons://localhost:8080/path/',
|
||||
}),
|
||||
('jsons://user:password@localhost:8080', {
|
||||
'instance': plugins.NotifyJSON,
|
||||
@ -852,8 +857,8 @@ TEST_URLS = (
|
||||
# Our expected url(privacy=True) startswith() response:
|
||||
'privacy_url': 'jsons://user:****@localhost:8080',
|
||||
}),
|
||||
('json://:@/', {
|
||||
'instance': None,
|
||||
('json://localhost:8080/path?-HeaderKey=HeaderValue', {
|
||||
'instance': plugins.NotifyJSON,
|
||||
}),
|
||||
('json://user:pass@localhost:8081', {
|
||||
'instance': plugins.NotifyJSON,
|
||||
@ -873,9 +878,6 @@ TEST_URLS = (
|
||||
# is set and tests that we gracfully handle them
|
||||
'test_requests_exceptions': True,
|
||||
}),
|
||||
('json://localhost:8080/path?-HeaderKey=HeaderValue', {
|
||||
'instance': plugins.NotifyJSON,
|
||||
}),
|
||||
|
||||
##################################
|
||||
# NotifyKODI
|
||||
@ -3283,6 +3285,9 @@ TEST_URLS = (
|
||||
##################################
|
||||
# NotifyXML
|
||||
##################################
|
||||
('xml://:@/', {
|
||||
'instance': None,
|
||||
}),
|
||||
('xml://', {
|
||||
'instance': None,
|
||||
}),
|
||||
@ -3318,12 +3323,14 @@ TEST_URLS = (
|
||||
}),
|
||||
('xmls://localhost:8080/path/', {
|
||||
'instance': plugins.NotifyXML,
|
||||
# Our expected url(privacy=True) startswith() response:
|
||||
'privacy_url': 'xmls://localhost:8080/path/',
|
||||
}),
|
||||
('xmls://user:pass@localhost:8080', {
|
||||
'instance': plugins.NotifyXML,
|
||||
}),
|
||||
('xml://:@/', {
|
||||
'instance': None,
|
||||
('xml://localhost:8080/path?-HeaderKey=HeaderValue', {
|
||||
'instance': plugins.NotifyXML,
|
||||
}),
|
||||
('xml://user:pass@localhost:8081', {
|
||||
'instance': plugins.NotifyXML,
|
||||
@ -3343,9 +3350,6 @@ TEST_URLS = (
|
||||
# is set and tests that we gracfully handle them
|
||||
'test_requests_exceptions': True,
|
||||
}),
|
||||
('xml://localhost:8080/path?-HeaderKey=HeaderValue', {
|
||||
'instance': plugins.NotifyXML,
|
||||
}),
|
||||
|
||||
##################################
|
||||
# NotifyZulip
|
||||
|
Loading…
Reference in New Issue
Block a user