mirror of
https://gitlab.com/allianceauth/allianceauth.git
synced 2025-07-12 05:50:16 +02:00
Fix retry logic being suppressed by try block (#1035)
This commit is contained in:
parent
37bed989f1
commit
b4d33e5dfc
@ -219,22 +219,18 @@ class DiscordOAuthManager:
|
|||||||
@staticmethod
|
@staticmethod
|
||||||
@api_backoff
|
@api_backoff
|
||||||
def update_nickname(user_id, nickname):
|
def update_nickname(user_id, nickname):
|
||||||
try:
|
nickname = DiscordOAuthManager._sanitize_name(nickname)
|
||||||
nickname = DiscordOAuthManager._sanitize_name(nickname)
|
custom_headers = {'content-type': 'application/json', 'authorization': 'Bot ' + settings.DISCORD_BOT_TOKEN}
|
||||||
custom_headers = {'content-type': 'application/json', 'authorization': 'Bot ' + settings.DISCORD_BOT_TOKEN}
|
data = {'nick': nickname}
|
||||||
data = {'nick': nickname}
|
path = DISCORD_URL + "/guilds/" + str(settings.DISCORD_GUILD_ID) + "/members/" + str(user_id)
|
||||||
path = DISCORD_URL + "/guilds/" + str(settings.DISCORD_GUILD_ID) + "/members/" + str(user_id)
|
r = requests.patch(path, headers=custom_headers, json=data)
|
||||||
r = requests.patch(path, headers=custom_headers, json=data)
|
logger.debug("Got status code %s after setting nickname for Discord user ID %s (%s)" % (
|
||||||
logger.debug("Got status code %s after setting nickname for Discord user ID %s (%s)" % (
|
r.status_code, user_id, nickname))
|
||||||
r.status_code, user_id, nickname))
|
if r.status_code == 404:
|
||||||
if r.status_code == 404:
|
logger.warn("Discord user ID %s could not be found in server." % user_id)
|
||||||
logger.warn("Discord user ID %s could not be found in server." % user_id)
|
|
||||||
return True
|
|
||||||
r.raise_for_status()
|
|
||||||
return True
|
return True
|
||||||
except:
|
r.raise_for_status()
|
||||||
logger.exception("Failed to set nickname for Discord user ID %s (%s)" % (user_id, nickname))
|
return True
|
||||||
return False
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def delete_user(user_id):
|
def delete_user(user_id):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user