Skip to content

Commit

Permalink
Convert to lower case before checking equality
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisLovering committed Dec 12, 2023
1 parent 6a0efbb commit 02bb12d
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions pydis_site/apps/api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,30 +261,30 @@ class GitHubWebhookFilterView(APIView):
def post(self, request: Request, *, webhook_id: str, webhook_token: str) -> Response:
"""Filter a webhook POST from GitHub before sending it to Discord."""
sender = request.data.get('sender', {})
sender_name = sender.get('login', '')
sender_name = sender.get('login', '').lower()
event = request.headers.get('X-GitHub-Event')
repository = request.data.get('repository', {})

is_coveralls = 'coveralls' in sender_name
is_github_bot = sender.get('type') == 'bot'
is_github_bot = sender.get('type', '').lower() == 'bot'
is_sentry = 'sentry-io' in sender_name
is_dependabot_branch_deletion = (
'dependabot' in request.data.get('ref', '')
and event == 'delete'
'dependabot' in request.data.get('ref', '').lower()
and event.lower() == 'delete'
)
is_bot_pr_approval = (
'[bot]' in request.data.get('pull_request', {}).get('user', {}).get('login', '')
'[bot]' in request.data.get('pull_request', {}).get('user', {}).get('login', '').lower()
and event == 'pull_request_review'
)
is_empty_review = (
request.data.get('review', {}).get('state') == 'commented'
request.data.get('review', {}).get('state', '').lower() == 'commented'
and event == 'pull_request_review'
and request.data.get('review', {}).get('body') is None
)
is_black_non_main_push = (
request.data.get('ref') != 'refs/heads/main'
and repository.get('name') == 'black'
and repository.get('owner', {}).get('login') == 'psf'
and repository.get('name', '').lower() == 'black'
and repository.get('owner', {}).get('login', '').lower() == 'psf'
and event == 'push'
)

Expand Down

0 comments on commit 02bb12d

Please sign in to comment.