Skip to content

Commit

Permalink
Merge pull request matryer#1790 from elalemanyo/fix/github_notifications
Browse files Browse the repository at this point in the history
001-notifications.30s.py: fix small bugs and add discussion
  • Loading branch information
matryer authored Aug 23, 2022
2 parents c379023 + bc0f340 commit 82e185b
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions Dev/GitHub/notifications.30s.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def make_github_request(url, method="GET", data=None, enterprise=False):
request.get_method = lambda: method
response = urlopen(request, data)
return (
json.load(response) if response.headers.get("content-length", 0) > 0 else {}
json.load(response) if int(response.headers.get("content-length", 0)) > 0 else {}
)
except Exception:
return None
Expand Down Expand Up @@ -129,7 +129,7 @@ def format_notification(notification):
}
if len(formatted["title"]) > 90:
formatted["title"] = formatted["title"][:79] + "…"
formatted["title"] = formatted["title"].replace("|", "-")
formatted["title"] = formatted["title"].decode().replace("|", "-")
latest_comment_url = notification.get("subject", {}).get("latest_comment_url", None)
typejson = make_github_request(formatted["href"])
if latest_comment_url:
Expand Down Expand Up @@ -185,6 +185,16 @@ def format_notification(notification):
"image"
] += "JdJREFUKJGl0DsKwkAUBdDTRgvFHbgmNyLY+QWzKxM/kK2kSKc70MIIQ0ziqBceA/dxinn8mSkKVMGUmH+CBWaNboQjdn2wqt97Pa8kNd5+C0O86YNdSZC34RLjCJxhHZYLXDCIxKuwTHGOwBNcm2WKUw9OcMCybZl6XjHpQOs30cB5gKNQiDPPP0WjV/a4aVwxNsNfUGce7P8k4XgVPSYAAAAASUVORK5CYII="
formatted["templateImage"] = formatted.pop("image")
elif type == "Discussion":
formatted[
"image"
] += ""
formatted["templateImage"] = formatted.pop("image")
elif type == "CheckSuite":
formatted[
"image"
] += ""
formatted["templateImage"] = formatted.pop("image")
return formatted


Expand Down

0 comments on commit 82e185b

Please sign in to comment.