From 5088abf327caec2238a432987c923d55c790813c Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Thu, 6 Aug 2020 10:32:30 +0200 Subject: [PATCH] Retrieve the email field rather than the bugzilla_email one The bugzilla_email relies on a user id -> email mapping that is kept in python-fedora fedora/client/fas2.py. That mapping is out-dated and, in fact, conflicts with the one used in this project in email_overrides.toml. So instead of retrieving the bugzilla_email, we retrieve the regular email and use our, up to date and maintained mapping to do the overrides. Otherwise, we end up in the situation described at: https://pagure.io/fesco/issue/2460#comment-669474 where user A was marked as having an invalid account because they had a bugzilla_email entry that was returning an invalid bugzilla account. Changing to use the email field led to more people having invalid accounts because their mapping had not been updated. So let's make sure that mapping remains up to date now and use only one. Signed-off-by: Pierre-Yves Chibon --- distgit_bugzilla_sync/script.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/distgit_bugzilla_sync/script.py b/distgit_bugzilla_sync/script.py index 887e9c2..f75b0d2 100644 --- a/distgit_bugzilla_sync/script.py +++ b/distgit_bugzilla_sync/script.py @@ -145,7 +145,7 @@ class BugzillaProxy: try: self.user_cache = self.fas.people_by_key( - key="username", fields=["bugzilla_email"] + key="username", fields=["email"] ) except fedora.client.ServerError: # Sometimes, building the user cache up front fails with a timeout. @@ -238,20 +238,20 @@ class BugzillaProxy: reloads the cache from fas and tries again. """ try: - bz_email = self.user_cache[username]["bugzilla_email"].lower() + bz_email = self.user_cache[username]["email"].lower() except KeyError: if username.startswith("@"): group = self.fas.group_by_name(username[1:]) bz_email = group.mailing_list if bz_email is None: return - self.user_cache[username] = {"bugzilla_email": bz_email} + self.user_cache[username] = {"email": bz_email} else: person = self.fas.person_by_username(username) - bz_email = person.get("bugzilla_email", None) + bz_email = person.get("email") if bz_email is None: return - self.user_cache[username] = {"bugzilla_email": bz_email} + self.user_cache[username] = {"email": bz_email} bz_email = bz_email.lower() self.inverted_user_cache[bz_email] = username bz_email = email_overrides.get(bz_email, bz_email)