fix potential race condition when fetching remote identities
This commit is contained in:
parent
e07869e2b7
commit
6b6c32882b
1 changed files with 10 additions and 8 deletions
|
@ -188,15 +188,17 @@ class Takahe:
|
|||
raise ValueError(f"local takahe identity {identity} missing APIdentity")
|
||||
if not identity.domain_id:
|
||||
raise ValueError(f"remote takahe identity {identity} missing domain")
|
||||
apid = APIdentity.objects.create(
|
||||
apid = APIdentity.objects.get_or_create(
|
||||
id=identity.pk,
|
||||
user=None,
|
||||
local=False,
|
||||
username=identity.username,
|
||||
domain_name=identity.domain_id,
|
||||
deleted=identity.deleted,
|
||||
anonymous_viewable=False,
|
||||
)
|
||||
defaults={
|
||||
"user": None,
|
||||
"local": False,
|
||||
"username": identity.username,
|
||||
"domain_name": identity.domain_id,
|
||||
"deleted": identity.deleted,
|
||||
"anonymous_viewable": False,
|
||||
},
|
||||
)[0]
|
||||
return apid
|
||||
|
||||
@staticmethod
|
||||
|
|
Loading…
Add table
Reference in a new issue