add parameter 'flash' for plugin Seven

This commit is contained in:
André Matthies 2025-03-06 12:29:44 +01:00
parent 7c5a9bc12f
commit 5b8719a943
2 changed files with 25 additions and 4 deletions

View File

@ -34,10 +34,9 @@ import requests
import json
from .base import NotifyBase
from ..common import NotifyType
from ..utils.parse import is_phone_no, parse_phone_no
from ..utils.parse import is_phone_no, parse_phone_no, parse_bool
from ..locale import gettext_lazy as _
class NotifySeven(NotifyBase):
"""
A wrapper for seven Notifications
@ -108,9 +107,14 @@ class NotifySeven(NotifyBase):
'from': {
'alias_of': 'source',
},
'flash': {
'name': _('Flash'),
'type': 'bool',
'default': False,
},
})
def __init__(self, apikey, targets=None, source=None, **kwargs):
def __init__(self, apikey, targets=None, source=None, flash=None, **kwargs):
"""
Initialize Seven Object
"""
@ -125,6 +129,8 @@ class NotifySeven(NotifyBase):
self.source = None \
if not isinstance(source, str) else source.strip()
self.flash = self.template_args['flash']['default'] \
if flash is None else bool(flash)
# Parse our targets
self.targets = list()
@ -179,6 +185,8 @@ class NotifySeven(NotifyBase):
}
if self.source:
payload['from'] = self.source
if self.flash:
payload['flash'] = self.flash
# Create a copy of the targets list
targets = list(self.targets)
while len(targets):
@ -263,7 +271,9 @@ class NotifySeven(NotifyBase):
Returns the URL built dynamically based on specified arguments.
"""
params = {}
params = {
'flash': 'yes' if self.flash else 'no',
}
if self.source:
params['from'] = self.source
@ -318,4 +328,7 @@ class NotifySeven(NotifyBase):
results['source'] = \
NotifySeven.unquote(results['qsd']['source'])
results['flash'] = \
parse_bool(results['qsd'].get('flash', False))
return results

View File

@ -85,6 +85,14 @@ apprise_url_tests = (
# valid number, utilizing the optional source= variable (same as from)
'instance': NotifySeven,
}),
('seven://{}/15551232000?from=apprise&flash=true'.format('3' * 14), {
# valid number, utilizing the optional from= variable
'instance': NotifySeven,
}),
('seven://{}/15551232000?source=apprise&flash=true'.format('3' * 14), {
# valid number, utilizing the optional source= variable (same as from)
'instance': NotifySeven,
}),
)