Skip to content

Commit

Permalink
fix: logic for checking token length
Browse files Browse the repository at this point in the history
  • Loading branch information
MagneticNeedle committed Apr 10, 2023
1 parent 0d7ca29 commit 2a0a0ee
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion bfportal/core/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

def get_scheduled_events(event_id: str, server_id: str = "870246147455877181") -> dict:
"""Tries to retrieve Scheduled events via discord API"""
if len(DISCORD_TOKEN := os.getenv("DISCORD_BOT_TOKEN", "")):
if not len(DISCORD_TOKEN := os.getenv("DISCORD_BOT_TOKEN", "")):
headers = {
"Authorization": f"Bot {DISCORD_TOKEN}",
"content-type": "application/json",
Expand Down
4 changes: 2 additions & 2 deletions bfportal/core/signal_recivers.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ def send_to_discord(sender, **kwargs):
discord channel specified by APPROVAL_SUCCESS_CHANNEL_WEBHOOK_ID env
"""
if len(token := os.getenv("APPROVAL_SUCCESS_CHANNEL_WEBHOOK_TOKEN", "")):
if not len(token := os.getenv("APPROVAL_SUCCESS_CHANNEL_WEBHOOK_TOKEN", "")):
logger.warning(
"Unable to publish new experience to discord as APPROVAL_SUCCESS_CHANNEL_WEBHOOK_TOKEN is not set"
)
return
if len(webhook_id := os.getenv("APPROVAL_SUCCESS_CHANNEL_WEBHOOK_ID", "")):
if not len(webhook_id := os.getenv("APPROVAL_SUCCESS_CHANNEL_WEBHOOK_ID", "")):
logger.warning(
"Unable to publish new experience to discord as APPROVAL_SUCCESS_CHANNEL_WEBHOOK_ID is not set"
)
Expand Down
4 changes: 2 additions & 2 deletions bfportal/core/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ def send_approve_request(
discord channel specified by APPROVAL_CHANNEL_WEBHOOK_ID env
"""
if len(token := os.getenv("APPROVAL_CHANNEL_WEBHOOK_TOKEN", "")):
if len(webhook_id := os.getenv("APPROVAL_CHANNEL_WEBHOOK_ID", "")):
if not len(token := os.getenv("APPROVAL_CHANNEL_WEBHOOK_TOKEN", "")):
if not len(webhook_id := os.getenv("APPROVAL_CHANNEL_WEBHOOK_ID", "")):
webhook_url = f"https://discord.com/api/webhooks/{webhook_id}/{token}"
admin_add = False
uid = -1
Expand Down

0 comments on commit 2a0a0ee

Please sign in to comment.