mirror of https://github.com/caronc/apprise
applied some feedback
parent
5f34b60d3e
commit
e763f3b71e
|
@ -32,13 +32,13 @@ from __future__ import annotations
|
||||||
|
|
||||||
import base64
|
import base64
|
||||||
from email.utils import formataddr
|
from email.utils import formataddr
|
||||||
from itertools import chain
|
|
||||||
from json import dumps, loads
|
from json import dumps, loads
|
||||||
import re
|
import re
|
||||||
|
|
||||||
import requests
|
import requests
|
||||||
|
|
||||||
from ..common import NotifyImageSize, NotifyType
|
from ..common import NotifyFormat, NotifyImageSize, NotifyType
|
||||||
|
from ..conversion import convert_between
|
||||||
from ..locale import gettext_lazy as _
|
from ..locale import gettext_lazy as _
|
||||||
from ..utils.parse import (
|
from ..utils.parse import (
|
||||||
is_email,
|
is_email,
|
||||||
|
@ -49,12 +49,9 @@ from ..utils.parse import (
|
||||||
)
|
)
|
||||||
from .base import NotifyBase
|
from .base import NotifyBase
|
||||||
|
|
||||||
# Valid targets:
|
# Used to detect ID
|
||||||
# id:sms
|
IS_VALID_ID_RE = re.compile(
|
||||||
# id:email
|
r"^\s*(@|%40)?(?P<id>[\w_-]+)\s*", re.I)
|
||||||
# id
|
|
||||||
IS_VALID_TARGET_RE = re.compile(
|
|
||||||
r"^\s*(((?P<id>[\w_-]+)\s*:)?(?P<target>.+)|(?P<id2>[\w_-]+))", re.I)
|
|
||||||
|
|
||||||
|
|
||||||
class NotificationAPIRegion:
|
class NotificationAPIRegion:
|
||||||
|
@ -83,16 +80,36 @@ NOTIFICATIONAPI_REGIONS = (
|
||||||
class NotificationAPIChannel:
|
class NotificationAPIChannel:
|
||||||
"""Channels"""
|
"""Channels"""
|
||||||
|
|
||||||
AUTO = "AUTO"
|
EMAIL = "email"
|
||||||
EMAIL = "EMAIL"
|
SMS = "sms"
|
||||||
SMS = "SMS"
|
INAPP = "inapp"
|
||||||
|
WEB_PUSH = "web_push"
|
||||||
|
MOBILE_PUSH = "mobile_push"
|
||||||
|
SLACK = "mobile_push"
|
||||||
|
|
||||||
|
|
||||||
# A List of our channels we can use for verification
|
# A List of our channels we can use for verification
|
||||||
NOTIFICATIONAPI_CHANNELS: frozenset[str] = frozenset([
|
NOTIFICATIONAPI_CHANNELS: frozenset[str] = frozenset([
|
||||||
NotificationAPIChannel.AUTO,
|
|
||||||
NotificationAPIChannel.EMAIL,
|
NotificationAPIChannel.EMAIL,
|
||||||
NotificationAPIChannel.SMS,
|
NotificationAPIChannel.SMS,
|
||||||
|
NotificationAPIChannel.INAPP,
|
||||||
|
NotificationAPIChannel.WEB_PUSH,
|
||||||
|
NotificationAPIChannel.MOBILE_PUSH,
|
||||||
|
NotificationAPIChannel.SLACK,
|
||||||
|
])
|
||||||
|
|
||||||
|
|
||||||
|
class NotificationAPIMode:
|
||||||
|
"""Modes"""
|
||||||
|
|
||||||
|
TEMPLATE = "template"
|
||||||
|
MESSAGE = "message"
|
||||||
|
|
||||||
|
|
||||||
|
# A List of our channels we can use for verification
|
||||||
|
NOTIFICATIONAPI_MODES: frozenset[str] = frozenset([
|
||||||
|
NotificationAPIMode.TEMPLATE,
|
||||||
|
NotificationAPIMode.MESSAGE,
|
||||||
])
|
])
|
||||||
|
|
||||||
|
|
||||||
|
@ -176,11 +193,10 @@ class NotifyNotificationAPI(NotifyBase):
|
||||||
"type": {
|
"type": {
|
||||||
"alias_of": "type",
|
"alias_of": "type",
|
||||||
},
|
},
|
||||||
"channel": {
|
"channels": {
|
||||||
"name": _("Channel"),
|
"name": _("Channels"),
|
||||||
"type": "choice:string",
|
"type": "list:string",
|
||||||
"values": NOTIFICATIONAPI_CHANNELS,
|
"values": NOTIFICATIONAPI_CHANNELS,
|
||||||
"default": NotificationAPIChannel.AUTO,
|
|
||||||
},
|
},
|
||||||
"region": {
|
"region": {
|
||||||
"name": _("Region Name"),
|
"name": _("Region Name"),
|
||||||
|
@ -188,6 +204,11 @@ class NotifyNotificationAPI(NotifyBase):
|
||||||
"values": NOTIFICATIONAPI_REGIONS,
|
"values": NOTIFICATIONAPI_REGIONS,
|
||||||
"default": NotificationAPIRegion.US,
|
"default": NotificationAPIRegion.US,
|
||||||
},
|
},
|
||||||
|
"mode": {
|
||||||
|
"name": _("Mode"),
|
||||||
|
"type": "choice:string",
|
||||||
|
"values": NOTIFICATIONAPI_MODES,
|
||||||
|
},
|
||||||
"base_url": {
|
"base_url": {
|
||||||
"name": _("Base URL Override"),
|
"name": _("Base URL Override"),
|
||||||
"type": "string",
|
"type": "string",
|
||||||
|
@ -204,6 +225,11 @@ class NotifyNotificationAPI(NotifyBase):
|
||||||
"name": _("Blind Carbon Copy"),
|
"name": _("Blind Carbon Copy"),
|
||||||
"type": "list:string",
|
"type": "list:string",
|
||||||
},
|
},
|
||||||
|
"reply": {
|
||||||
|
"name": _("Reply To"),
|
||||||
|
"type": "string",
|
||||||
|
"map_to": "reply_to",
|
||||||
|
},
|
||||||
"from": {
|
"from": {
|
||||||
"name": _("From Email"),
|
"name": _("From Email"),
|
||||||
"type": "string",
|
"type": "string",
|
||||||
|
@ -226,8 +252,9 @@ class NotifyNotificationAPI(NotifyBase):
|
||||||
}
|
}
|
||||||
|
|
||||||
def __init__(self, client_id, client_secret, message_type=None,
|
def __init__(self, client_id, client_secret, message_type=None,
|
||||||
targets=None, cc=None, bcc=None, channel=None, region=None,
|
targets=None, cc=None, bcc=None, reply_to=None,
|
||||||
from_addr=None, tokens=None, **kwargs):
|
channels=None, region=None, mode=None, from_addr=None,
|
||||||
|
tokens=None, **kwargs):
|
||||||
"""
|
"""
|
||||||
Initialize Notify NotificationAPI Object
|
Initialize Notify NotificationAPI Object
|
||||||
"""
|
"""
|
||||||
|
@ -252,7 +279,7 @@ class NotifyNotificationAPI(NotifyBase):
|
||||||
# For tracking our email -> name lookups
|
# For tracking our email -> name lookups
|
||||||
self.names = {}
|
self.names = {}
|
||||||
|
|
||||||
# Temporary from_addr to work with for parsing
|
# Prepare our From Address
|
||||||
_from_addr = [self.app_id, ""]
|
_from_addr = [self.app_id, ""]
|
||||||
self.from_addr = None
|
self.from_addr = None
|
||||||
if isinstance(from_addr, str):
|
if isinstance(from_addr, str):
|
||||||
|
@ -269,11 +296,32 @@ class NotifyNotificationAPI(NotifyBase):
|
||||||
self.from_addr = _from_addr[1]
|
self.from_addr = _from_addr[1]
|
||||||
self.names[_from_addr[1]] = _from_addr[0]
|
self.names[_from_addr[1]] = _from_addr[0]
|
||||||
|
|
||||||
# Our Targets; must be formatted as
|
# Prepare our Reply-To Address
|
||||||
# id:email or id:phone_no
|
self.reply_to = {}
|
||||||
self.email_targets = []
|
if isinstance(reply_to, str):
|
||||||
self.sms_targets = []
|
result = is_email(reply_to)
|
||||||
self.id_targets = []
|
if result and "full_email" in result:
|
||||||
|
self.reply_to = {
|
||||||
|
"senderName": result["name"]
|
||||||
|
if result["name"] else _from_addr[0],
|
||||||
|
"senderEmail": result["full_email"],
|
||||||
|
}
|
||||||
|
|
||||||
|
# Our Targets are delimited by found ids
|
||||||
|
self.targets = []
|
||||||
|
if mode and isinstance(mode, str):
|
||||||
|
self.mode = next(
|
||||||
|
(a for a in NOTIFICATIONAPI_MODES if a.startswith(mode)), None
|
||||||
|
)
|
||||||
|
if self.mode not in NOTIFICATIONAPI_MODES:
|
||||||
|
msg = \
|
||||||
|
f"The NotificationAPI mode specified ({mode}) is invalid."
|
||||||
|
self.logger.warning(msg)
|
||||||
|
raise TypeError(msg)
|
||||||
|
else:
|
||||||
|
# Detect mode based on whether or not a message_type was provided
|
||||||
|
self.mode = NotificationAPIMode.MESSAGE if not message_type else \
|
||||||
|
NotificationAPIMode.TEMPLATE
|
||||||
|
|
||||||
if not message_type:
|
if not message_type:
|
||||||
# Assign a default message type
|
# Assign a default message type
|
||||||
|
@ -321,69 +369,111 @@ class NotifyNotificationAPI(NotifyBase):
|
||||||
self.logger.warning(msg)
|
self.logger.warning(msg)
|
||||||
raise TypeError(msg) from None
|
raise TypeError(msg) from None
|
||||||
|
|
||||||
if targets:
|
# Initialize an empty set of channels
|
||||||
# Validate recipients (to:) and drop bad ones:
|
self.channels = set()
|
||||||
for entry in parse_list(targets):
|
for _channel in parse_list(channels):
|
||||||
result = IS_VALID_TARGET_RE.match(entry)
|
channel = _channel.lower()
|
||||||
if not result:
|
if channel not in NOTIFICATIONAPI_CHANNELS:
|
||||||
msg = (
|
|
||||||
"The NotificationAPI target specified "
|
|
||||||
f"({entry}) is invalid.")
|
|
||||||
self.logger.warning(msg)
|
|
||||||
continue
|
|
||||||
|
|
||||||
if result.group("id2"):
|
|
||||||
self.id_targets.append({
|
|
||||||
"id": result.group("id2"),
|
|
||||||
})
|
|
||||||
continue
|
|
||||||
|
|
||||||
# Store our content
|
|
||||||
uid, recipient = result.group("id"), result.group("target")
|
|
||||||
|
|
||||||
result = is_email(recipient)
|
|
||||||
if result:
|
|
||||||
self.email_targets.append({
|
|
||||||
"id": uid,
|
|
||||||
"email": result["full_email"],
|
|
||||||
})
|
|
||||||
continue
|
|
||||||
|
|
||||||
result = is_phone_no(recipient)
|
|
||||||
if result:
|
|
||||||
self.sms_targets.append({
|
|
||||||
"id": uid,
|
|
||||||
"number": result["full"],
|
|
||||||
})
|
|
||||||
continue
|
|
||||||
|
|
||||||
msg = (
|
|
||||||
"The NotificationAPI target specified "
|
|
||||||
f"({entry}) is invalid.")
|
|
||||||
self.logger.warning(msg)
|
|
||||||
|
|
||||||
if channel is None:
|
|
||||||
self.channel = NotificationAPIChannel.AUTO
|
|
||||||
|
|
||||||
else:
|
|
||||||
# Store our channel
|
|
||||||
try:
|
|
||||||
self.channel = (
|
|
||||||
self.template_args["channel"]["default"]
|
|
||||||
if channel is None else channel.upper()
|
|
||||||
)
|
|
||||||
|
|
||||||
if self.channel not in NOTIFICATIONAPI_CHANNELS:
|
|
||||||
# allow the outer except to handle this common response
|
|
||||||
raise IndexError()
|
|
||||||
|
|
||||||
except (AttributeError, IndexError, TypeError):
|
|
||||||
# Invalid channel specified
|
# Invalid channel specified
|
||||||
msg = (
|
msg = (
|
||||||
"The NotificationAPI channel specified "
|
"The NotificationAPI forced channel specified "
|
||||||
f"({channel}) is invalid.")
|
f"({channel}) is invalid.")
|
||||||
self.logger.warning(msg)
|
self.logger.warning(msg)
|
||||||
raise TypeError(msg) from None
|
raise TypeError(msg) from None
|
||||||
|
self.channels.add(channel)
|
||||||
|
|
||||||
|
if targets:
|
||||||
|
current_target = {}
|
||||||
|
for entry in parse_list(targets, sort=False):
|
||||||
|
result = is_email(entry)
|
||||||
|
if result:
|
||||||
|
if "email" not in current_target:
|
||||||
|
current_target["email"] = result["full_email"]
|
||||||
|
if not self.channels:
|
||||||
|
self.channels.add(NotificationAPIChannel.EMAIL)
|
||||||
|
self.logger.info(
|
||||||
|
"The NotificationAPI default channel of "
|
||||||
|
f"{NotificationAPIChannel.EMAIL} was set.")
|
||||||
|
continue
|
||||||
|
|
||||||
|
elif "id" in current_target:
|
||||||
|
# Store and move on
|
||||||
|
self.targets.append(current_target)
|
||||||
|
current_target = {
|
||||||
|
"email": result["full_email"]
|
||||||
|
}
|
||||||
|
continue
|
||||||
|
|
||||||
|
# if we got here, we have to many emails making it now
|
||||||
|
# ambiguous as to who the sender intended to notify
|
||||||
|
msg = (
|
||||||
|
"The NotificationAPI received too many emails "
|
||||||
|
"creating an ambiguous situation; aborted at "
|
||||||
|
f"'{entry}'.")
|
||||||
|
self.logger.warning(msg)
|
||||||
|
raise TypeError(msg) from None
|
||||||
|
|
||||||
|
result = is_phone_no(entry)
|
||||||
|
if result:
|
||||||
|
if "number" not in current_target:
|
||||||
|
current_target["number"] = \
|
||||||
|
('+' if entry[0] == '+' else '') + result["full"]
|
||||||
|
if not self.channels:
|
||||||
|
self.channels.add(NotificationAPIChannel.SMS)
|
||||||
|
self.logger.info(
|
||||||
|
"The NotificationAPI default channel of "
|
||||||
|
f"{NotificationAPIChannel.SMS} was set.")
|
||||||
|
continue
|
||||||
|
|
||||||
|
elif "id" in current_target:
|
||||||
|
# Store and move on
|
||||||
|
self.targets.append(current_target)
|
||||||
|
current_target = {
|
||||||
|
"number": result["full"]
|
||||||
|
}
|
||||||
|
continue
|
||||||
|
|
||||||
|
# if we got here, we have to many emails making it now
|
||||||
|
# ambiguous as to who the sender intended to notify
|
||||||
|
msg = (
|
||||||
|
"The NotificationAPI received too many phone no's "
|
||||||
|
"creating an ambiguous situation; aborted at "
|
||||||
|
f"'{entry}'.")
|
||||||
|
self.logger.warning(msg)
|
||||||
|
raise TypeError(msg) from None
|
||||||
|
|
||||||
|
result = IS_VALID_ID_RE.match(entry)
|
||||||
|
if result:
|
||||||
|
if "id" not in current_target:
|
||||||
|
current_target["id"] = result.group("id")
|
||||||
|
continue
|
||||||
|
|
||||||
|
elif "id" in current_target:
|
||||||
|
# Store and move on
|
||||||
|
self.targets.append(current_target)
|
||||||
|
current_target = {
|
||||||
|
"id": result.group("id")
|
||||||
|
}
|
||||||
|
continue
|
||||||
|
|
||||||
|
self.logger.warning(
|
||||||
|
"Ignoring invalid NotificationAPI target "
|
||||||
|
f"({entry}) specified")
|
||||||
|
continue
|
||||||
|
|
||||||
|
if "id" in current_target:
|
||||||
|
# Store our final entry
|
||||||
|
self.targets.append(current_target)
|
||||||
|
current_target = {}
|
||||||
|
|
||||||
|
if current_target:
|
||||||
|
# we have email or sms, but no id to go with it
|
||||||
|
msg = (
|
||||||
|
"The NotificationAPI did not detect an id to "
|
||||||
|
"correlate the following with {}".format(
|
||||||
|
str(current_target)))
|
||||||
|
self.logger.warning(msg)
|
||||||
|
raise TypeError(msg) from None
|
||||||
|
|
||||||
# Validate recipients (cc:) and drop bad ones:
|
# Validate recipients (cc:) and drop bad ones:
|
||||||
for recipient in parse_emails(cc):
|
for recipient in parse_emails(cc):
|
||||||
|
@ -443,8 +533,13 @@ class NotifyNotificationAPI(NotifyBase):
|
||||||
Returns the URL built dynamically based on specified arguments.
|
Returns the URL built dynamically based on specified arguments.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# Our URL parameters
|
# Define any URL parameters
|
||||||
params = self.url_parameters(privacy=privacy, *args, **kwargs)
|
params = {
|
||||||
|
"mode": self.mode,
|
||||||
|
}
|
||||||
|
|
||||||
|
# Extend our parameters
|
||||||
|
params.update(self.url_parameters(privacy=privacy, *args, **kwargs))
|
||||||
|
|
||||||
if len(self.cc) > 0:
|
if len(self.cc) > 0:
|
||||||
# Handle our Carbon Copy Addresses
|
# Handle our Carbon Copy Addresses
|
||||||
|
@ -466,9 +561,18 @@ class NotifyNotificationAPI(NotifyBase):
|
||||||
charset="utf-8").replace(",", "%2C")
|
charset="utf-8").replace(",", "%2C")
|
||||||
for e in self.bcc])
|
for e in self.bcc])
|
||||||
|
|
||||||
if self.channel != self.template_args["channel"]["default"]:
|
if self.reply_to:
|
||||||
|
# Handle our Reply-To Address
|
||||||
|
params["reply"] = formataddr(
|
||||||
|
(self.reply_to["senderName"], self.reply_to["senderEmail"]),
|
||||||
|
# Swap comma for its escaped url code (if detected) since
|
||||||
|
# we're using that as a delimiter
|
||||||
|
charset="utf-8",
|
||||||
|
)
|
||||||
|
|
||||||
|
if self.channels:
|
||||||
# Prepare our default channel
|
# Prepare our default channel
|
||||||
params["channel"] = self.channel.lower()
|
params["channels"] = self.channels
|
||||||
|
|
||||||
if self.region != self.template_args["region"]["default"]:
|
if self.region != self.template_args["region"]["default"]:
|
||||||
# Prepare our default region
|
# Prepare our default region
|
||||||
|
@ -483,27 +587,23 @@ class NotifyNotificationAPI(NotifyBase):
|
||||||
# Store any template entries if specified
|
# Store any template entries if specified
|
||||||
params.update({f":{k}": v for k, v in self.tokens.items()})
|
params.update({f":{k}": v for k, v in self.tokens.items()})
|
||||||
|
|
||||||
return "{schema}://{mtype}@{cid}/{secret}/{targets}?{params}".format(
|
targets = []
|
||||||
|
for target in self.targets:
|
||||||
|
if "id" in target:
|
||||||
|
targets.append(f"@{target['id']}")
|
||||||
|
if "number" in target:
|
||||||
|
targets.append(f"{target['number']}")
|
||||||
|
if "email" in target:
|
||||||
|
targets.append(f"{target['email']}")
|
||||||
|
|
||||||
|
mtype = f"{self.message_type}@" \
|
||||||
|
if self.message_type != self.default_message_type else ""
|
||||||
|
return "{schema}://{mtype}{cid}/{secret}/{targets}?{params}".format(
|
||||||
schema=self.secure_protocol[0],
|
schema=self.secure_protocol[0],
|
||||||
mtype=self.message_type,
|
mtype=mtype,
|
||||||
cid=self.pprint(self.client_id, privacy, safe=""),
|
cid=self.pprint(self.client_id, privacy, safe=""),
|
||||||
secret=self.pprint(self.client_secret, privacy, safe=""),
|
secret=self.pprint(self.client_secret, privacy, safe=""),
|
||||||
targets="" if not (
|
targets=NotifyNotificationAPI.quote("/".join(targets), safe="/"),
|
||||||
self.sms_targets or self.email_targets) else "/".join(
|
|
||||||
chain(
|
|
||||||
[
|
|
||||||
NotifyNotificationAPI.quote(
|
|
||||||
"{}:{}".format(x["id"], x["email"]), safe="")
|
|
||||||
for x in self.email_targets],
|
|
||||||
[
|
|
||||||
NotifyNotificationAPI.quote(
|
|
||||||
"{}:{}".format(
|
|
||||||
x["id"], x["number"]), safe="")
|
|
||||||
for x in self.sms_targets],
|
|
||||||
[
|
|
||||||
NotifyNotificationAPI.quote(x["id"], safe="")
|
|
||||||
for x in self.id_targets],
|
|
||||||
)),
|
|
||||||
params=NotifyNotificationAPI.urlencode(params),
|
params=NotifyNotificationAPI.urlencode(params),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -512,10 +612,7 @@ class NotifyNotificationAPI(NotifyBase):
|
||||||
Returns the number of targets associated with this notification
|
Returns the number of targets associated with this notification
|
||||||
"""
|
"""
|
||||||
|
|
||||||
return max(
|
return max(1, len(self.targets))
|
||||||
1,
|
|
||||||
len(self.email_targets) + len(self.sms_targets)
|
|
||||||
+ len(self.id_targets))
|
|
||||||
|
|
||||||
def gen_payload(self, body, title="", notify_type=NotifyType.INFO,
|
def gen_payload(self, body, title="", notify_type=NotifyType.INFO,
|
||||||
**kwargs):
|
**kwargs):
|
||||||
|
@ -523,6 +620,10 @@ class NotifyNotificationAPI(NotifyBase):
|
||||||
generates our NotificationAPI payload
|
generates our NotificationAPI payload
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
_payload = {
|
||||||
|
"type": self.message_type,
|
||||||
|
}
|
||||||
|
if self.mode == NotificationAPIMode.TEMPLATE:
|
||||||
# Take a copy of our token dictionary
|
# Take a copy of our token dictionary
|
||||||
parameters = self.tokens.copy()
|
parameters = self.tokens.copy()
|
||||||
|
|
||||||
|
@ -537,18 +638,81 @@ class NotifyNotificationAPI(NotifyBase):
|
||||||
parameters["appUrl"] = self.app_url
|
parameters["appUrl"] = self.app_url
|
||||||
|
|
||||||
# A Simple Email Payload Template
|
# A Simple Email Payload Template
|
||||||
_payload = {
|
_payload.update({
|
||||||
"type": self.message_type,
|
|
||||||
"parameters": {**parameters},
|
"parameters": {**parameters},
|
||||||
}
|
})
|
||||||
|
|
||||||
if self.channel != NotificationAPIChannel.AUTO:
|
else:
|
||||||
_payload["forceChannels"] = [self.channel]
|
# Acquire text version of body if provided
|
||||||
|
text_body = convert_between(
|
||||||
|
NotifyFormat.HTML, NotifyFormat.TEXT, body) \
|
||||||
|
if self.notify_format == NotifyFormat.HTML else body
|
||||||
|
|
||||||
|
for channel in self.channels:
|
||||||
|
# Python v3.10 supports `match/case` but since Apprise aims to be
|
||||||
|
# compatible with Python v3.9+, we must use if/else for the time
|
||||||
|
# being
|
||||||
|
if channel == NotificationAPIChannel.SMS:
|
||||||
|
_payload.update({
|
||||||
|
NotificationAPIChannel.SMS: {
|
||||||
|
"message": (title + "\n" + text_body)
|
||||||
|
if title else text_body,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
elif channel == NotificationAPIChannel.EMAIL:
|
||||||
|
html_body = convert_between(
|
||||||
|
NotifyFormat.TEXT, NotifyFormat.HTML, body) \
|
||||||
|
if self.notify_format != NotifyFormat.HTML else body
|
||||||
|
|
||||||
|
_payload.update({
|
||||||
|
NotificationAPIChannel.EMAIL: {
|
||||||
|
"subject": title if title else self.app_id,
|
||||||
|
"html": html_body,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
if self.from_addr:
|
||||||
|
_payload[NotificationAPIChannel.EMAIL].update({
|
||||||
|
"senderName": self.from_addr,
|
||||||
|
"senderEmail": self.names[self.from_addr],
|
||||||
|
})
|
||||||
|
|
||||||
|
elif channel == NotificationAPIChannel.INAPP:
|
||||||
|
_payload.update({
|
||||||
|
NotificationAPIChannel.INAPP: {
|
||||||
|
"title": title if title else self.app_id,
|
||||||
|
"image": self.image_url(notify_type),
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
elif channel == NotificationAPIChannel.WEB_PUSH:
|
||||||
|
_payload.update({
|
||||||
|
NotificationAPIChannel.WEB_PUSH: {
|
||||||
|
"title": title if title else self.app_id,
|
||||||
|
"message": text_body,
|
||||||
|
"icon": self.image_url(notify_type),
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
elif channel == NotificationAPIChannel.MOBILE_PUSH:
|
||||||
|
_payload.update({
|
||||||
|
NotificationAPIChannel.MOBILE_PUSH: {
|
||||||
|
"title": title if title else self.app_id,
|
||||||
|
"message": text_body,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
elif channel == NotificationAPIChannel.SLACK:
|
||||||
|
_payload.update({
|
||||||
|
NotificationAPIChannel.SLACK: {
|
||||||
|
"text": (title + "\n" + text_body)
|
||||||
|
if title else text_body,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
# Copy our list to work with
|
# Copy our list to work with
|
||||||
targets = list(self.email_targets) + \
|
targets = list(self.targets)
|
||||||
list(self.sms_targets) + list(self.id_targets)
|
|
||||||
|
|
||||||
if self.from_addr:
|
if self.from_addr:
|
||||||
_payload.update({
|
_payload.update({
|
||||||
"options": {
|
"options": {
|
||||||
|
@ -600,7 +764,7 @@ class NotifyNotificationAPI(NotifyBase):
|
||||||
# error tracking (used for function return)
|
# error tracking (used for function return)
|
||||||
has_error = False
|
has_error = False
|
||||||
|
|
||||||
if not (self.email_targets or self.sms_targets or self.id_targets):
|
if not self.targets:
|
||||||
# There is no one to email or send an sms message to; we're done
|
# There is no one to email or send an sms message to; we're done
|
||||||
self.logger.warning(
|
self.logger.warning(
|
||||||
"There are no NotificationAPI recipients to notify"
|
"There are no NotificationAPI recipients to notify"
|
||||||
|
@ -689,7 +853,6 @@ class NotifyNotificationAPI(NotifyBase):
|
||||||
"Sent NotifiationAPI notification to %s.",
|
"Sent NotifiationAPI notification to %s.",
|
||||||
payload["to"]["id"])
|
payload["to"]["id"])
|
||||||
|
|
||||||
|
|
||||||
except requests.RequestException as e:
|
except requests.RequestException as e:
|
||||||
self.logger.warning(
|
self.logger.warning(
|
||||||
"A Connection error occurred sending NotifiationAPI "
|
"A Connection error occurred sending NotifiationAPI "
|
||||||
|
@ -764,6 +927,14 @@ class NotifyNotificationAPI(NotifyBase):
|
||||||
results["message_type"] = \
|
results["message_type"] = \
|
||||||
NotifyNotificationAPI.unquote(results["qsd"]["type"])
|
NotifyNotificationAPI.unquote(results["qsd"]["type"])
|
||||||
|
|
||||||
|
if "mode" in results["qsd"] and len(results["qsd"]["mode"]):
|
||||||
|
results["mode"] = \
|
||||||
|
NotifyNotificationAPI.unquote(results["qsd"]["mode"])
|
||||||
|
|
||||||
|
if "reply" in results["qsd"] and len(results["qsd"]["reply"]):
|
||||||
|
results["reply_to"] = \
|
||||||
|
NotifyNotificationAPI.unquote(results["qsd"]["reply"])
|
||||||
|
|
||||||
elif results["user"]:
|
elif results["user"]:
|
||||||
# Pull from user
|
# Pull from user
|
||||||
results["message_type"] = \
|
results["message_type"] = \
|
||||||
|
|
|
@ -1046,7 +1046,7 @@ def parse_urls(*args, store_unparseable=True, **kwargs):
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
||||||
def parse_list(*args, cast=None, allow_whitespace=True):
|
def parse_list(*args, cast=None, allow_whitespace=True, sort=True):
|
||||||
"""Take a string list and break it into a delimited list of arguments. This
|
"""Take a string list and break it into a delimited list of arguments. This
|
||||||
funciton also supports the processing of a list of delmited strings and
|
funciton also supports the processing of a list of delmited strings and
|
||||||
will always return a unique set of arguments. Duplicates are always
|
will always return a unique set of arguments. Duplicates are always
|
||||||
|
@ -1081,7 +1081,8 @@ def parse_list(*args, cast=None, allow_whitespace=True):
|
||||||
)
|
)
|
||||||
|
|
||||||
elif isinstance(arg, (set, list, tuple)):
|
elif isinstance(arg, (set, list, tuple)):
|
||||||
result += parse_list(*arg, allow_whitespace=allow_whitespace)
|
result += parse_list(
|
||||||
|
*arg, allow_whitespace=allow_whitespace, sort=sort)
|
||||||
|
|
||||||
#
|
#
|
||||||
# filter() eliminates any empty entries
|
# filter() eliminates any empty entries
|
||||||
|
@ -1089,13 +1090,20 @@ def parse_list(*args, cast=None, allow_whitespace=True):
|
||||||
# Since Python v3 returns a filter (iterator) whereas Python v2 returned
|
# Since Python v3 returns a filter (iterator) whereas Python v2 returned
|
||||||
# a list, we need to change it into a list object to remain compatible with
|
# a list, we need to change it into a list object to remain compatible with
|
||||||
# both distribution types.
|
# both distribution types.
|
||||||
|
if sort:
|
||||||
return (
|
return (
|
||||||
sorted(filter(bool, list(set(result))))
|
sorted(filter(bool, list(set(result))))
|
||||||
if allow_whitespace
|
if allow_whitespace
|
||||||
else sorted(
|
else sorted(
|
||||||
[x.strip() for x in filter(bool, list(set(result))) if x.strip()]
|
[x.strip() for x in filter(
|
||||||
|
bool, list(set(result))) if x.strip()]
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
return (
|
||||||
|
[x for x in filter(bool, list(result))]
|
||||||
|
if allow_whitespace
|
||||||
|
else [x.strip() for x in filter(bool, list(result)) if x.strip()]
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def validate_regex(value, regex=r"[^\s]+", flags=re.I, strip=True, fmt=None):
|
def validate_regex(value, regex=r"[^\s]+", flags=re.I, strip=True, fmt=None):
|
||||||
|
|
|
@ -63,32 +63,36 @@ apprise_url_tests = (
|
||||||
# Just an Email specified, no client_id or client_secret
|
# Just an Email specified, no client_id or client_secret
|
||||||
"instance": TypeError,
|
"instance": TypeError,
|
||||||
}),
|
}),
|
||||||
("napi://type@client_id/client_secret/id:+15551235555/", {
|
("napi://user@client_id/cs14/user@example.ca", {
|
||||||
|
# No id matched
|
||||||
|
"instance": TypeError,
|
||||||
|
}),
|
||||||
|
("napi://type@client_id/client_secret/id/+15551235553/", {
|
||||||
"instance": NotifyNotificationAPI,
|
"instance": NotifyNotificationAPI,
|
||||||
"requests_response_text": NOTIFICATIONAPI_GOOD_RESPONSE,
|
"requests_response_text": NOTIFICATIONAPI_GOOD_RESPONSE,
|
||||||
}),
|
}),
|
||||||
("napi://type@cid/secret/id:user@example.com/", {
|
("napi://type@cid/secret/id/user1@example.com/", {
|
||||||
"instance": NotifyNotificationAPI,
|
"instance": NotifyNotificationAPI,
|
||||||
"requests_response_text": NOTIFICATIONAPI_GOOD_RESPONSE,
|
"requests_response_text": NOTIFICATIONAPI_GOOD_RESPONSE,
|
||||||
}),
|
}),
|
||||||
(("napi://type@cid/secret/id:user@example.com/"
|
(("napi://type@cid/secret/id10/user2@example.com/"
|
||||||
"id:+15551235555/id:+15551235534"), {
|
"id5/+15551235555/id8/+15551235534"), {
|
||||||
"instance": NotifyNotificationAPI,
|
"instance": NotifyNotificationAPI,
|
||||||
"requests_response_text": NOTIFICATIONAPI_GOOD_RESPONSE,
|
"requests_response_text": NOTIFICATIONAPI_GOOD_RESPONSE,
|
||||||
}),
|
}),
|
||||||
(("napi://type@cid/secret/id:user@example.com/"
|
(("napi://type@cid/secret/id/user3@example.com/"
|
||||||
"?from=joe@example.ca"), {
|
"?from=joe@example.ca"), {
|
||||||
# Set from/source
|
# Set from/source
|
||||||
"instance": NotifyNotificationAPI,
|
"instance": NotifyNotificationAPI,
|
||||||
"requests_response_text": NOTIFICATIONAPI_GOOD_RESPONSE,
|
"requests_response_text": NOTIFICATIONAPI_GOOD_RESPONSE,
|
||||||
}),
|
}),
|
||||||
(("napi://type@cid/secret/id:user@example.com/"
|
(("napi://type@cid/secret/id/user4@example.com/"
|
||||||
"?from=joe@example.ca&bcc=user1@yahoo.ca&cc=user2@yahoo.ca"), {
|
"?from=joe@example.ca&bcc=user1@yahoo.ca&cc=user2@yahoo.ca"), {
|
||||||
# Set from/source
|
# Set from/source
|
||||||
"instance": NotifyNotificationAPI,
|
"instance": NotifyNotificationAPI,
|
||||||
"requests_response_text": NOTIFICATIONAPI_GOOD_RESPONSE,
|
"requests_response_text": NOTIFICATIONAPI_GOOD_RESPONSE,
|
||||||
}),
|
}),
|
||||||
("napi://?id=ci&secret=cs&to=id:user@example.com&type=type", {
|
("napi://?id=ci&secret=cs&to=id,user5@example.com&type=type", {
|
||||||
# use just kwargs
|
# use just kwargs
|
||||||
"instance": NotifyNotificationAPI,
|
"instance": NotifyNotificationAPI,
|
||||||
"requests_response_text": NOTIFICATIONAPI_GOOD_RESPONSE,
|
"requests_response_text": NOTIFICATIONAPI_GOOD_RESPONSE,
|
||||||
|
@ -99,90 +103,90 @@ apprise_url_tests = (
|
||||||
"requests_response_text": NOTIFICATIONAPI_GOOD_RESPONSE,
|
"requests_response_text": NOTIFICATIONAPI_GOOD_RESPONSE,
|
||||||
"notify_response": False,
|
"notify_response": False,
|
||||||
}),
|
}),
|
||||||
("napi://user@client_id/cs2/id:user@example.ca"
|
("napi://user@client_id/cs2/id/user6@example.ca"
|
||||||
"?bcc=invalid", {
|
"?bcc=invalid", {
|
||||||
# A good email with a bad Blind Carbon Copy
|
# A good email with a bad Blind Carbon Copy
|
||||||
"instance": NotifyNotificationAPI,
|
"instance": NotifyNotificationAPI,
|
||||||
"requests_response_text": NOTIFICATIONAPI_GOOD_RESPONSE,
|
"requests_response_text": NOTIFICATIONAPI_GOOD_RESPONSE,
|
||||||
}),
|
}),
|
||||||
("napi://user@client_id/cs3/id:user@example.ca"
|
("napi://user@client_id/cs3/id/user8@example.ca"
|
||||||
"?cc=l2g@nuxref.com", {
|
"?cc=l2g@nuxref.com", {
|
||||||
# A good email with Carbon Copy
|
# A good email with Carbon Copy
|
||||||
"instance": NotifyNotificationAPI,
|
"instance": NotifyNotificationAPI,
|
||||||
"requests_response_text": NOTIFICATIONAPI_GOOD_RESPONSE,
|
"requests_response_text": NOTIFICATIONAPI_GOOD_RESPONSE,
|
||||||
}),
|
}),
|
||||||
("napi://user@client_id/cs4/id:user@example.ca"
|
("napi://user@client_id/cs4/id/user9@example.ca"
|
||||||
"?cc=Chris<l2g@nuxref.com>", {
|
"?cc=Chris<l2g@nuxref.com>", {
|
||||||
# A good email with Carbon Copy
|
# A good email with Carbon Copy
|
||||||
"instance": NotifyNotificationAPI,
|
"instance": NotifyNotificationAPI,
|
||||||
"requests_response_text": NOTIFICATIONAPI_GOOD_RESPONSE,
|
"requests_response_text": NOTIFICATIONAPI_GOOD_RESPONSE,
|
||||||
}),
|
}),
|
||||||
("napi://user@client_id/cs5/id:user@example.ca"
|
("napi://user@client_id/cs5/id/user10@example.ca"
|
||||||
"?cc=invalid", {
|
"?cc=invalid", {
|
||||||
# A good email with Carbon Copy
|
# A good email with Carbon Copy
|
||||||
"instance": NotifyNotificationAPI,
|
"instance": NotifyNotificationAPI,
|
||||||
"requests_response_text": NOTIFICATIONAPI_GOOD_RESPONSE,
|
"requests_response_text": NOTIFICATIONAPI_GOOD_RESPONSE,
|
||||||
}),
|
}),
|
||||||
("napi://user@client_id/cs6/id:user@example.ca"
|
("napi://user@client_id/cs6/id/user11@example.ca"
|
||||||
"?to=invalid", {
|
"?to=invalid", {
|
||||||
# an invalid to email
|
# an invalid to email
|
||||||
"instance": NotifyNotificationAPI,
|
"instance": NotifyNotificationAPI,
|
||||||
"requests_response_text": NOTIFICATIONAPI_GOOD_RESPONSE,
|
"requests_response_text": NOTIFICATIONAPI_GOOD_RESPONSE,
|
||||||
}),
|
}),
|
||||||
("napi://user@client_id/cs7/id:chris@example.com", {
|
("napi://user@client_id/cs7/id/chris1@example.com", {
|
||||||
# An email with a designated to email
|
# An email with a designated to email
|
||||||
"instance": NotifyNotificationAPI,
|
"instance": NotifyNotificationAPI,
|
||||||
"requests_response_text": NOTIFICATIONAPI_GOOD_RESPONSE,
|
"requests_response_text": NOTIFICATIONAPI_GOOD_RESPONSE,
|
||||||
}),
|
}),
|
||||||
("napi://user@client_id/cs8/id:user@example.ca"
|
("napi://user@client_id/cs8/id1/user12@example.ca"
|
||||||
"?to=id:Chris<chris@example.com>", {
|
"?to=id,Chris<chris2@example.com>", {
|
||||||
# An email with a full name in in To field
|
# An email with a full name in in To field
|
||||||
"instance": NotifyNotificationAPI,
|
"instance": NotifyNotificationAPI,
|
||||||
"requests_response_text": NOTIFICATIONAPI_GOOD_RESPONSE,
|
"requests_response_text": NOTIFICATIONAPI_GOOD_RESPONSE,
|
||||||
}),
|
}),
|
||||||
("napi://user@client_id/cs9/id:user@example.ca"
|
("napi://user@client_id/cs9/id2/user13@example.ca/"
|
||||||
"id:chris@example.com/id:chris2@example.com/id:+15552341234", {
|
"id/kris@example.com/id/chris2@example.com/id/+15552341234", {
|
||||||
# Several emails to notify
|
# Several emails to notify
|
||||||
"instance": NotifyNotificationAPI,
|
"instance": NotifyNotificationAPI,
|
||||||
"requests_response_text": NOTIFICATIONAPI_GOOD_RESPONSE,
|
"requests_response_text": NOTIFICATIONAPI_GOOD_RESPONSE,
|
||||||
}),
|
}),
|
||||||
("napi://user@client_id/cs10/id:user@example.ca"
|
("napi://user@client_id/cs10/id/user14@example.ca"
|
||||||
"?cc=Chris<chris@example.com>", {
|
"?cc=Chris<chris10@example.com>", {
|
||||||
# An email with a full name in cc
|
# An email with a full name in cc
|
||||||
"instance": NotifyNotificationAPI,
|
"instance": NotifyNotificationAPI,
|
||||||
"requests_response_text": NOTIFICATIONAPI_GOOD_RESPONSE,
|
"requests_response_text": NOTIFICATIONAPI_GOOD_RESPONSE,
|
||||||
}),
|
}),
|
||||||
("napi://user@client_id/cs11/id:user@example.ca"
|
("napi://user@client_id/cs11/id/user15@example.ca"
|
||||||
"?cc=chris@example.com", {
|
"?cc=chris12@example.com", {
|
||||||
# An email with a full name in cc
|
# An email with a full name in cc
|
||||||
"instance": NotifyNotificationAPI,
|
"instance": NotifyNotificationAPI,
|
||||||
"requests_response_text": NOTIFICATIONAPI_GOOD_RESPONSE,
|
"requests_response_text": NOTIFICATIONAPI_GOOD_RESPONSE,
|
||||||
}),
|
}),
|
||||||
("napi://user@client_id/cs12/id:user@example.ca"
|
("napi://user@client_id/cs12/id/user16@example.ca"
|
||||||
"?bcc=Chris<chris@example.com>", {
|
"?bcc=Chris<chris14@example.com>", {
|
||||||
# An email with a full name in bcc
|
# An email with a full name in bcc
|
||||||
"instance": NotifyNotificationAPI,
|
"instance": NotifyNotificationAPI,
|
||||||
"requests_response_text": NOTIFICATIONAPI_GOOD_RESPONSE,
|
"requests_response_text": NOTIFICATIONAPI_GOOD_RESPONSE,
|
||||||
}),
|
}),
|
||||||
("napi://user@client_id/cs13/id:user@example.ca"
|
("napi://user@client_id/cs13/id/user@example.ca"
|
||||||
"?bcc=chris@example.com", {
|
"?bcc=chris13@example.com", {
|
||||||
# An email with a full name in bcc
|
# An email with a full name in bcc
|
||||||
"instance": NotifyNotificationAPI,
|
"instance": NotifyNotificationAPI,
|
||||||
"requests_response_text": NOTIFICATIONAPI_GOOD_RESPONSE,
|
"requests_response_text": NOTIFICATIONAPI_GOOD_RESPONSE,
|
||||||
}),
|
}),
|
||||||
("napi://user@client_id/cs14/id:user@example.ca"
|
("napi://user@client_id/cs14/id/user@example.ca"
|
||||||
"?to=Chris<chris@example.com>", {
|
"?to=Chris<chris9@example.com>,id14", {
|
||||||
# An email with a full name in bcc
|
# An email with a full name in bcc
|
||||||
"instance": NotifyNotificationAPI,
|
"instance": NotifyNotificationAPI,
|
||||||
"requests_response_text": NOTIFICATIONAPI_GOOD_RESPONSE,
|
"requests_response_text": NOTIFICATIONAPI_GOOD_RESPONSE,
|
||||||
}),
|
}),
|
||||||
("napi://user@client_id/cs15/id:user@example.ca"
|
("napi://user@client_id/cs15/id"
|
||||||
"?to=chris@example.com", {
|
"?to=user@example.com", {
|
||||||
# An email with a full name in bcc
|
# An email with a full name in bcc
|
||||||
"instance": NotifyNotificationAPI,
|
"instance": NotifyNotificationAPI,
|
||||||
"requests_response_text": NOTIFICATIONAPI_GOOD_RESPONSE,
|
"requests_response_text": NOTIFICATIONAPI_GOOD_RESPONSE,
|
||||||
}),
|
}),
|
||||||
("napi://user@client_id/cs16/id:user@example.ca"
|
("napi://user@client_id/cs16/id/user@example.ca"
|
||||||
"?template=1234&+sub=value&+sub2=value2", {
|
"?template=1234&+sub=value&+sub2=value2", {
|
||||||
# A good email with a template + substitutions
|
# A good email with a template + substitutions
|
||||||
"instance": NotifyNotificationAPI,
|
"instance": NotifyNotificationAPI,
|
||||||
|
@ -191,21 +195,21 @@ apprise_url_tests = (
|
||||||
# Our expected url(privacy=True) startswith() response:
|
# Our expected url(privacy=True) startswith() response:
|
||||||
"privacy_url": "napi://user@c...d/c...6/",
|
"privacy_url": "napi://user@c...d/c...6/",
|
||||||
}),
|
}),
|
||||||
("napi://user@client_id/cs17/id:user@example.ca", {
|
("napi://user@client_id/cs17/id/user@example.ca", {
|
||||||
"instance": NotifyNotificationAPI,
|
"instance": NotifyNotificationAPI,
|
||||||
# force a failure
|
# force a failure
|
||||||
"response": False,
|
"response": False,
|
||||||
"requests_response_code": requests.codes.internal_server_error,
|
"requests_response_code": requests.codes.internal_server_error,
|
||||||
"requests_response_text": NOTIFICATIONAPI_GOOD_RESPONSE,
|
"requests_response_text": NOTIFICATIONAPI_GOOD_RESPONSE,
|
||||||
}),
|
}),
|
||||||
("napi://user@client_id/cs18/id:user@example.ca", {
|
("napi://user@client_id/cs18/id/user@example.ca", {
|
||||||
"instance": NotifyNotificationAPI,
|
"instance": NotifyNotificationAPI,
|
||||||
# throw a bizzare code forcing us to fail to look it up
|
# throw a bizzare code forcing us to fail to look it up
|
||||||
"response": False,
|
"response": False,
|
||||||
"requests_response_code": 999,
|
"requests_response_code": 999,
|
||||||
"requests_response_text": NOTIFICATIONAPI_GOOD_RESPONSE,
|
"requests_response_text": NOTIFICATIONAPI_GOOD_RESPONSE,
|
||||||
}),
|
}),
|
||||||
("napi://user@client_id/cs19/id:user@example.ca", {
|
("napi://user@client_id/cs19/id/user@example.ca", {
|
||||||
"instance": NotifyNotificationAPI,
|
"instance": NotifyNotificationAPI,
|
||||||
# Throws a series of connection and transfer exceptions when this flag
|
# Throws a series of connection and transfer exceptions when this flag
|
||||||
# is set and tests that we gracfully handle them
|
# is set and tests that we gracfully handle them
|
||||||
|
@ -240,11 +244,11 @@ def test_plugin_napi_sms_payloads(mock_post):
|
||||||
client_id = "my_id"
|
client_id = "my_id"
|
||||||
client_secret = "my_secret"
|
client_secret = "my_secret"
|
||||||
message_type = "apprise-post"
|
message_type = "apprise-post"
|
||||||
phone_no = "userid:+1-555-123-4567"
|
targets = "userid/+1-555-123-4567"
|
||||||
|
|
||||||
obj = Apprise.instantiate(
|
obj = Apprise.instantiate(
|
||||||
f"napi://{message_type}@{client_id}/{client_secret}/"
|
f"napi://{message_type}@{client_id}/{client_secret}/"
|
||||||
f"{phone_no}")
|
f"{targets}?mode=template")
|
||||||
assert isinstance(obj, NotifyNotificationAPI)
|
assert isinstance(obj, NotifyNotificationAPI)
|
||||||
assert isinstance(obj.url(), str)
|
assert isinstance(obj.url(), str)
|
||||||
|
|
||||||
|
@ -270,7 +274,7 @@ def test_plugin_napi_sms_payloads(mock_post):
|
||||||
"type": "apprise-post",
|
"type": "apprise-post",
|
||||||
"to": {
|
"to": {
|
||||||
"id": "userid",
|
"id": "userid",
|
||||||
"number": "15551234567",
|
"number": "+15551234567",
|
||||||
},
|
},
|
||||||
"parameters": {
|
"parameters": {
|
||||||
"appBody": "body",
|
"appBody": "body",
|
||||||
|
@ -309,12 +313,12 @@ def test_plugin_napi_email_payloads(mock_post):
|
||||||
client_id = "my_id_abc"
|
client_id = "my_id_abc"
|
||||||
client_secret = "my_secret"
|
client_secret = "my_secret"
|
||||||
message_type = "apprise-post"
|
message_type = "apprise-post"
|
||||||
email = "userid:test@example.ca"
|
targets = "userid/test@example.ca"
|
||||||
|
|
||||||
obj = Apprise.instantiate(
|
obj = Apprise.instantiate(
|
||||||
f"napi://{message_type}@{client_id}/{client_secret}/"
|
f"napi://{message_type}@{client_id}/{client_secret}/"
|
||||||
f"{email}?from=Chris<chris@example.eu>&bcc=joe@hidden.com&"
|
f"{targets}?from=Chris<chris@example.eu>&bcc=joe@hidden.com&"
|
||||||
f"cc=jason@hidden.com&:customToken=customValue")
|
f"cc=jason@hidden.com&:customToken=customValue&mode=template")
|
||||||
assert isinstance(obj, NotifyNotificationAPI)
|
assert isinstance(obj, NotifyNotificationAPI)
|
||||||
assert isinstance(obj.url(), str)
|
assert isinstance(obj.url(), str)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue