[fs2zammad] add exact filter on looked up user emails

This commit is contained in:
fnux 2024-05-08 18:08:19 +02:00
parent 29431f72df
commit 5ca451510f
No known key found for this signature in database
GPG key ID: 4502C902C00A1E12

View file

@ -91,8 +91,8 @@ def maybe_create_zammad_user(userdata, zammad_session, attr="login", default=Non
except: except:
# The use probably exist already... # The use probably exist already...
result = list(zammad.user.search(lowercase_email)) result = list(zammad.user.search(lowercase_email))
if len(result) == 1: if len(result) >= 1:
user = list.pop(result) user = next(u for u in result if u.email == lowercase_email)
USERMAP[lowercase_email] = user USERMAP[lowercase_email] = user
else: else:
print(f"Could not create/fetch user {lowercase_email}") print(f"Could not create/fetch user {lowercase_email}")