Skip to content

Commit

Permalink
Fix error when 'data' is empty, Bump version to 0.2.3
Browse files Browse the repository at this point in the history
  • Loading branch information
hbrennhaeuser committed Aug 20, 2023
1 parent 41e40cb commit 236d75a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 27 deletions.
2 changes: 1 addition & 1 deletion custom_components/ntfy/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@
"requirements": ["requests"],
"ssdp": [],
"usb": [],
"version": "0.2.2",
"version": "0.2.3",
"zeroconf": []
}
43 changes: 17 additions & 26 deletions custom_components/ntfy/notify.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,33 +68,24 @@ def send_message(self, message="", **kwargs):
req_headers={
"Title": title.encode('utf-8')
}

if "tags" in data:
req_headers["Tags"] = data["tags"]




if "priority" in data:
schema_click = ['max','urgent','high','default','low','min']

if str(data["priority"]) not in schema_click:
raise SyntaxError('Incorrect value for attribute priority given')

req_headers["Priority"] = data["priority"]




if "click" in data:
schema_url = vol.Schema(vol.Url())

try:
schema_url(data["click"])
except vol.MultipleInvalid as e:
raise SyntaxError('expected a URL for attribute click')

req_headers["Click"] = data["click"]
if data is not None:
if "tags" in data:
req_headers["Tags"] = data["tags"]

if "priority" in data:
schema_click = ['max','urgent','high','default','low','min']
if str(data["priority"]) not in schema_click:
raise SyntaxError('Incorrect value for attribute priority given')
req_headers["Priority"] = data["priority"]

if "click" in data:
schema_url = vol.Schema(vol.Url())
try:
schema_url(data["click"])
except vol.MultipleInvalid as e:
raise SyntaxError('expected a URL for attribute click')
req_headers["Click"] = data["click"]


req_verify=True
Expand Down

0 comments on commit 236d75a

Please sign in to comment.