mirror of https://github.com/caronc/apprise
enforce E.164 format
parent
b7f9320941
commit
ff3b57f5a4
|
@ -169,9 +169,8 @@ class NotifyPlivo(NotifyBase):
|
||||||
self.logger.warning(msg)
|
self.logger.warning(msg)
|
||||||
raise TypeError(msg)
|
raise TypeError(msg)
|
||||||
|
|
||||||
# Store our source
|
# Store our source; enforce E.164 format
|
||||||
self.source = '{}{}'.format(
|
self.source = f'+{result["full"]}'
|
||||||
'' if source[0] != '+' else '+', result['full'])
|
|
||||||
|
|
||||||
# Parse our targets
|
# Parse our targets
|
||||||
self.targets = list()
|
self.targets = list()
|
||||||
|
@ -181,9 +180,8 @@ class NotifyPlivo(NotifyBase):
|
||||||
# Validate targets and drop bad ones:
|
# Validate targets and drop bad ones:
|
||||||
result = is_phone_no(target)
|
result = is_phone_no(target)
|
||||||
if result:
|
if result:
|
||||||
# store valid phone number
|
# store valid phone number; enforce E.164 format
|
||||||
self.targets.append('{}{}'.format(
|
self.targets.append(f'+{result["full"]}')
|
||||||
'' if target[0] != '+' else '+', result['full']))
|
|
||||||
continue
|
continue
|
||||||
|
|
||||||
self.logger.warning(
|
self.logger.warning(
|
||||||
|
@ -331,7 +329,7 @@ class NotifyPlivo(NotifyBase):
|
||||||
token=self.pprint(self.token, privacy, safe=''),
|
token=self.pprint(self.token, privacy, safe=''),
|
||||||
source=self.source,
|
source=self.source,
|
||||||
targets='/'.join(
|
targets='/'.join(
|
||||||
[NotifyPlivo.quote(x, safe='') for x in self.targets]),
|
[NotifyPlivo.quote(x, safe='+') for x in self.targets]),
|
||||||
params=NotifyPlivo.urlencode(params))
|
params=NotifyPlivo.urlencode(params))
|
||||||
|
|
||||||
def __len__(self):
|
def __len__(self):
|
||||||
|
|
|
@ -83,7 +83,7 @@ apprise_url_tests = (
|
||||||
('plivo://?id={}&token={}&from=15551233000&to=15551232000'.format(
|
('plivo://?id={}&token={}&from=15551233000&to=15551232000'.format(
|
||||||
'a' * 25, 'a' * 40), {
|
'a' * 25, 'a' * 40), {
|
||||||
# Our expected url(privacy=True) startswith() response:
|
# Our expected url(privacy=True) startswith() response:
|
||||||
'privacy_url': 'plivo://a...a@a...a/15551233000/15551232000',
|
'privacy_url': 'plivo://a...a@a...a/+15551233000/+15551232000',
|
||||||
# reference to to= and from=
|
# reference to to= and from=
|
||||||
'instance': NotifyPlivo,
|
'instance': NotifyPlivo,
|
||||||
}),
|
}),
|
||||||
|
@ -92,7 +92,7 @@ apprise_url_tests = (
|
||||||
# reference to to= and from=
|
# reference to to= and from=
|
||||||
'instance': NotifyPlivo,
|
'instance': NotifyPlivo,
|
||||||
# Our expected url(privacy=True) startswith() response:
|
# Our expected url(privacy=True) startswith() response:
|
||||||
'privacy_url': 'plivo://a...a@a...a/15551233000/15551232123'}),
|
'privacy_url': 'plivo://a...a@a...a/+15551233000/+15551232123'}),
|
||||||
('plivo://{}@{}/15551232000'.format('a' * 25, 'a' * 40), {
|
('plivo://{}@{}/15551232000'.format('a' * 25, 'a' * 40), {
|
||||||
'instance': NotifyPlivo,
|
'instance': NotifyPlivo,
|
||||||
# throw a bizzare code forcing us to fail to look it up
|
# throw a bizzare code forcing us to fail to look it up
|
||||||
|
|
Loading…
Reference in New Issue