#54 Retrieve the email field rather than the bugzilla_email one
Merged 3 years ago by nphilipp. Opened 3 years ago by pingou.
fedora-infra/ pingou/distgit-bugzilla-sync people_by_email  into  master

@@ -145,7 +145,7 @@ 

  

          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 @@ 

          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)

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 pingou@pingoured.fr

This needs change in _get_bugzilla_email() below.

Right now, this only fills the cache with the email rather than bugzilla_email fields of users, but _get_bugzilla_email() still attempts to look up bugzilla_email (and at first, fails to do so, retrieves it for each user looked up and stores it in the cache).

Metadata Update from @nphilipp:
- Request assigned

3 years ago

rebased onto 23035ef

3 years ago

Let's get rid of the None here (which is the default):

    bz_email = person.get("email")

rebased onto 5088abf

3 years ago

Pull-Request has been merged by nphilipp

3 years ago
Metadata