Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Various of fixes for problems found by CodeQL #36

Merged
merged 3 commits into from Oct 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion dorpsgek/helpers/dorpsgek.py
Expand Up @@ -20,7 +20,7 @@ async def get_dorpsgek_yml(github_api, repository):
except gidgethub.BadRequest as err:
# Check if there simply wasn't any .dorpsgek.yml in this repository
if err.args == ("Not Found",):
return
return None

raise

Expand Down
12 changes: 5 additions & 7 deletions dorpsgek/patches/gidgethub.py
Expand Up @@ -13,20 +13,18 @@ async def dispatch(self, event, *args, **kwargs):
"""Dispatch an event to all registered function(s)."""

found_callbacks = []
try:
if event.event in self._shallow_routes:
found_callbacks.extend(self._shallow_routes[event.event])
except KeyError:
pass
try:

if event.event in self._deep_routes:
details = self._deep_routes[event.event]
except KeyError:
pass
else:

for data_key, data_values in details.items():
if data_key in event.data:
event_value = event.data[data_key]
if event_value in data_values:
found_callbacks.extend(data_values[event_value])

for callback in found_callbacks:
try:
await callback(event, *args, **kwargs)
Expand Down
2 changes: 2 additions & 0 deletions dorpsgek/protocols/irc.py
Expand Up @@ -80,6 +80,8 @@ async def issue(channels, repository_name, url, user, action, issue_id, title):
message = f"{user} closed issue #{issue_id}: {title}"
elif action == "comment":
message = f"{user} commented on issue #{issue_id}: {title}"
else:
return

shortened_url = await shorten(url)
_send_messages(channels, [f"[{repository_name}] {message} {shortened_url}"])
Expand Down