mirror of
https://gitlab.com/allianceauth/allianceauth.git
synced 2025-07-13 06:20:16 +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)
|
||||
if args:
|
||||
endpoint['path'] = endpoint['path'] % args
|
||||
endpoint['parsed_url'] = endpoint['path'] % args
|
||||
else:
|
||||
endpoint['parsed_url'] = endpoint['path']
|
||||
data = {}
|
||||
for arg in endpoint['args']['required']:
|
||||
data[arg] = kwargs[arg]
|
||||
@ -166,7 +168,7 @@ class DiscourseManager:
|
||||
for arg in kwargs:
|
||||
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))
|
||||
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:
|
||||
if 'errors' in r.json() and not silent:
|
||||
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
|
||||
|
||||
if not auth.discourse_enabled:
|
||||
auth.discourse_enabled = True
|
||||
auth.save()
|
||||
update_discourse_groups.delay(request.user.pk)
|
||||
update_discourse_groups.apply_async(args=[request.user.pk], countdown=30) # wait 30s for new user creation on Discourse
|
||||
|
||||
## Redirect back to Discourse
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user