mirror of
https://github.com/caronc/apprise.git
synced 2024-11-25 09:33:50 +01:00
Cisco Webex Teams (wxteams://) Life Cycle Support (#819)
This commit is contained in:
parent
078ee799b0
commit
b5a9c25e86
@ -95,7 +95,7 @@ class NotifyWebexTeams(NotifyBase):
|
|||||||
service_url = 'https://webex.teams.com/'
|
service_url = 'https://webex.teams.com/'
|
||||||
|
|
||||||
# The default secure protocol
|
# The default secure protocol
|
||||||
secure_protocol = 'wxteams'
|
secure_protocol = ('wxteams', 'webex')
|
||||||
|
|
||||||
# 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_wxteams'
|
setup_url = 'https://github.com/caronc/apprise/wiki/Notify_wxteams'
|
||||||
@ -124,7 +124,7 @@ class NotifyWebexTeams(NotifyBase):
|
|||||||
'type': 'string',
|
'type': 'string',
|
||||||
'private': True,
|
'private': True,
|
||||||
'required': True,
|
'required': True,
|
||||||
'regex': (r'^[a-z0-9]{80}$', 'i'),
|
'regex': (r'^[a-z0-9]{80,160}$', 'i'),
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -220,7 +220,7 @@ class NotifyWebexTeams(NotifyBase):
|
|||||||
params = self.url_parameters(privacy=privacy, *args, **kwargs)
|
params = self.url_parameters(privacy=privacy, *args, **kwargs)
|
||||||
|
|
||||||
return '{schema}://{token}/?{params}'.format(
|
return '{schema}://{token}/?{params}'.format(
|
||||||
schema=self.secure_protocol,
|
schema=self.secure_protocol[0],
|
||||||
token=self.pprint(self.token, privacy, safe=''),
|
token=self.pprint(self.token, privacy, safe=''),
|
||||||
params=NotifyWebexTeams.urlencode(params),
|
params=NotifyWebexTeams.urlencode(params),
|
||||||
)
|
)
|
||||||
@ -249,14 +249,15 @@ class NotifyWebexTeams(NotifyBase):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
result = re.match(
|
result = re.match(
|
||||||
r'^https?://api\.ciscospark\.com/v[1-9][0-9]*/webhooks/incoming/'
|
r'^https?://(api\.ciscospark\.com|webexapis\.com)'
|
||||||
|
r'/v[1-9][0-9]*/webhooks/incoming/'
|
||||||
r'(?P<webhook_token>[A-Z0-9_-]+)/?'
|
r'(?P<webhook_token>[A-Z0-9_-]+)/?'
|
||||||
r'(?P<params>\?.+)?$', url, re.I)
|
r'(?P<params>\?.+)?$', url, re.I)
|
||||||
|
|
||||||
if result:
|
if result:
|
||||||
return NotifyWebexTeams.parse_url(
|
return NotifyWebexTeams.parse_url(
|
||||||
'{schema}://{webhook_token}/{params}'.format(
|
'{schema}://{webhook_token}/{params}'.format(
|
||||||
schema=NotifyWebexTeams.secure_protocol,
|
schema=NotifyWebexTeams.secure_protocol[0],
|
||||||
webhook_token=result.group('webhook_token'),
|
webhook_token=result.group('webhook_token'),
|
||||||
params='' if not result.group('params')
|
params='' if not result.group('params')
|
||||||
else result.group('params')))
|
else result.group('params')))
|
||||||
|
@ -57,11 +57,23 @@ apprise_url_tests = (
|
|||||||
# Our expected url(privacy=True) startswith() response:
|
# Our expected url(privacy=True) startswith() response:
|
||||||
'privacy_url': 'wxteams://a...a/',
|
'privacy_url': 'wxteams://a...a/',
|
||||||
}),
|
}),
|
||||||
|
('webex://{}'.format('a' * 140), {
|
||||||
|
# token provided - we're good
|
||||||
|
'instance': NotifyWebexTeams,
|
||||||
|
|
||||||
|
# Our expected url(privacy=True) startswith() response:
|
||||||
|
'privacy_url': 'wxteams://a...a/',
|
||||||
|
}),
|
||||||
# Support Native URLs
|
# Support Native URLs
|
||||||
('https://api.ciscospark.com/v1/webhooks/incoming/{}'.format('a' * 80), {
|
('https://api.ciscospark.com/v1/webhooks/incoming/{}'.format('a' * 80), {
|
||||||
# token provided - we're good
|
# token provided - we're good
|
||||||
'instance': NotifyWebexTeams,
|
'instance': NotifyWebexTeams,
|
||||||
}),
|
}),
|
||||||
|
# Support New Native URLs
|
||||||
|
('https://webexapis.com/v1/webhooks/incoming/{}'.format('a' * 100), {
|
||||||
|
# token provided - we're good
|
||||||
|
'instance': NotifyWebexTeams,
|
||||||
|
}),
|
||||||
# Support Native URLs with arguments
|
# Support Native URLs with arguments
|
||||||
('https://api.ciscospark.com/v1/webhooks/incoming/{}?format=text'.format(
|
('https://api.ciscospark.com/v1/webhooks/incoming/{}?format=text'.format(
|
||||||
'a' * 80), {
|
'a' * 80), {
|
||||||
|
Loading…
Reference in New Issue
Block a user