mirror of
https://gitlab.com/allianceauth/allianceauth.git
synced 2025-07-09 12:30:15 +02:00
Handle HTTP429 on nickname API endpoint
Closes #971 (cherry picked from commit a64dda2a2e64d1629f389adcf7ce67d15c3085bd)
This commit is contained in:
parent
1caa4b6baa
commit
0f1535161c
@ -212,6 +212,7 @@ class DiscordOAuthManager:
|
||||
return None
|
||||
|
||||
@staticmethod
|
||||
@api_backoff
|
||||
def update_nickname(user_id, nickname):
|
||||
try:
|
||||
nickname = DiscordOAuthManager._sanitize_name(nickname)
|
||||
|
@ -97,7 +97,7 @@ class DiscordTasks:
|
||||
|
||||
@staticmethod
|
||||
@app.task(bind=True, name='discord.update_nickname')
|
||||
def update_nickname(self, pk):
|
||||
def update_nickname(task_self, pk):
|
||||
user = User.objects.get(pk=pk)
|
||||
logger.debug("Updating discord nickname for user %s" % user)
|
||||
if DiscordTasks.has_account(user):
|
||||
@ -105,10 +105,14 @@ class DiscordTasks:
|
||||
logger.debug("Updating user %s discord nickname to %s" % (user, character.character_name))
|
||||
try:
|
||||
DiscordOAuthManager.update_nickname(user.discord.uid, character.character_name)
|
||||
except DiscordApiBackoff as bo:
|
||||
logger.info("Discord nickname update API back off for %s, "
|
||||
"retrying in %s seconds" % (user, bo.retry_after_seconds))
|
||||
raise task_self.retry(countdown=bo.retry_after_seconds)
|
||||
except Exception as e:
|
||||
if self:
|
||||
if task_self:
|
||||
logger.exception("Discord nickname sync failed for %s, retrying in 10 mins" % user)
|
||||
raise self.retry(countdown=60 * 10)
|
||||
raise task_self.retry(countdown=60 * 10)
|
||||
else:
|
||||
# Rethrow
|
||||
raise e
|
||||
|
Loading…
x
Reference in New Issue
Block a user