mirror of
https://github.com/caronc/apprise.git
synced 2025-06-21 18:21:29 +02:00
Add support for Join:// DeviceNames (#207)
This commit is contained in:
parent
a8ec23a9e8
commit
1ce7cbb679
@ -130,6 +130,11 @@ class NotifyJoin(NotifyBase):
|
|||||||
'regex': (r'^[a-z0-9]{32}$', 'i'),
|
'regex': (r'^[a-z0-9]{32}$', 'i'),
|
||||||
'map_to': 'targets',
|
'map_to': 'targets',
|
||||||
},
|
},
|
||||||
|
'device_name': {
|
||||||
|
'name': _('Device Name'),
|
||||||
|
'type': 'string',
|
||||||
|
'map_to': 'targets',
|
||||||
|
},
|
||||||
'group': {
|
'group': {
|
||||||
'name': _('Group'),
|
'name': _('Group'),
|
||||||
'type': 'choice:string',
|
'type': 'choice:string',
|
||||||
@ -210,18 +215,7 @@ class NotifyJoin(NotifyBase):
|
|||||||
'group.{}'.format(group_re.group('name').lower()))
|
'group.{}'.format(group_re.group('name').lower()))
|
||||||
continue
|
continue
|
||||||
|
|
||||||
elif IS_DEVICE_RE.match(target):
|
self.targets.append(target)
|
||||||
self.targets.append(target)
|
|
||||||
continue
|
|
||||||
|
|
||||||
self.logger.warning(
|
|
||||||
'Ignoring invalid Join device/group "{}"'.format(target)
|
|
||||||
)
|
|
||||||
|
|
||||||
if not self.targets:
|
|
||||||
msg = 'No Join targets to notify.'
|
|
||||||
self.logger.warning(msg)
|
|
||||||
raise TypeError(msg)
|
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
@ -247,12 +241,18 @@ class NotifyJoin(NotifyBase):
|
|||||||
|
|
||||||
url_args = {
|
url_args = {
|
||||||
'apikey': self.apikey,
|
'apikey': self.apikey,
|
||||||
'deviceId': target,
|
|
||||||
'priority': str(self.priority),
|
'priority': str(self.priority),
|
||||||
'title': title,
|
'title': title,
|
||||||
'text': body,
|
'text': body,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if IS_GROUP_RE.match(target) or IS_DEVICE_RE.match(target):
|
||||||
|
url_args['deviceId'] = target
|
||||||
|
|
||||||
|
else:
|
||||||
|
# Support Device Names
|
||||||
|
url_args['deviceNames'] = target
|
||||||
|
|
||||||
# prepare our image for display if configured to do so
|
# prepare our image for display if configured to do so
|
||||||
image_url = None if not self.include_image \
|
image_url = None if not self.include_image \
|
||||||
else self.image_url(notify_type)
|
else self.image_url(notify_type)
|
||||||
|
@ -921,9 +921,9 @@ TEST_URLS = (
|
|||||||
('join://%s@%s?image=False' % ('a' * 32, 'd' * 32), {
|
('join://%s@%s?image=False' % ('a' * 32, 'd' * 32), {
|
||||||
'instance': plugins.NotifyJoin,
|
'instance': plugins.NotifyJoin,
|
||||||
}),
|
}),
|
||||||
# API Key + invalid device
|
# API Key + Device Name
|
||||||
('join://%s/%s' % ('a' * 32, 'k' * 12), {
|
('join://%s/%s' % ('a' * 32, 'My Device'), {
|
||||||
'instance': TypeError,
|
'instance': plugins.NotifyJoin,
|
||||||
}),
|
}),
|
||||||
# API Key + device
|
# API Key + device
|
||||||
('join://%s/%s' % ('a' * 32, 'd' * 32), {
|
('join://%s/%s' % ('a' * 32, 'd' * 32), {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user