mirror of
https://gitlab.com/allianceauth/allianceauth.git
synced 2025-07-13 14:30:17 +02:00
Delay new Discourse user group sync to allow request to complete.
Ensures Discourse creates user model to avoid 404s when calling API.
This commit is contained in:
parent
5ee65706cb
commit
00341f8a50
@ -156,7 +156,9 @@ class DiscourseManager:
|
|||||||
}
|
}
|
||||||
silent = kwargs.pop('silent', False)
|
silent = kwargs.pop('silent', False)
|
||||||
if args:
|
if args:
|
||||||
endpoint['path'] = endpoint['path'] % args
|
endpoint['parsed_url'] = endpoint['path'] % args
|
||||||
|
else:
|
||||||
|
endpoint['parsed_url'] = endpoint['path']
|
||||||
data = {}
|
data = {}
|
||||||
for arg in endpoint['args']['required']:
|
for arg in endpoint['args']['required']:
|
||||||
data[arg] = kwargs[arg]
|
data[arg] = kwargs[arg]
|
||||||
@ -166,7 +168,7 @@ class DiscourseManager:
|
|||||||
for arg in kwargs:
|
for arg in kwargs:
|
||||||
if arg not in endpoint['args']['required'] and arg not in endpoint['args']['optional'] and not silent:
|
if arg not in endpoint['args']['required'] and arg not in endpoint['args']['optional'] and not silent:
|
||||||
logger.warn("Received unrecognized kwarg %s for endpoint %s" % (arg, endpoint))
|
logger.warn("Received unrecognized kwarg %s for endpoint %s" % (arg, endpoint))
|
||||||
r = endpoint['method'](settings.DISCOURSE_URL + endpoint['path'], params=params, json=data)
|
r = endpoint['method'](settings.DISCOURSE_URL + endpoint['parsed_url'], params=params, json=data)
|
||||||
try:
|
try:
|
||||||
if 'errors' in r.json() and not silent:
|
if 'errors' in r.json() and not silent:
|
||||||
logger.error("Discourse execution failed.\nEndpoint: %s\nErrors: %s" % (endpoint, r.json()['errors']))
|
logger.error("Discourse execution failed.\nEndpoint: %s\nErrors: %s" % (endpoint, r.json()['errors']))
|
||||||
|
@ -1199,9 +1199,10 @@ def discourse_sso(request):
|
|||||||
|
|
||||||
## Record activation and queue group sync
|
## Record activation and queue group sync
|
||||||
|
|
||||||
auth.discourse_enabled = True
|
if not auth.discourse_enabled:
|
||||||
auth.save()
|
auth.discourse_enabled = True
|
||||||
update_discourse_groups.delay(request.user.pk)
|
auth.save()
|
||||||
|
update_discourse_groups.apply_async(args=[request.user.pk], countdown=30) # wait 30s for new user creation on Discourse
|
||||||
|
|
||||||
## Redirect back to Discourse
|
## Redirect back to Discourse
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user