Deal with users or groups not having the expected email address

An user could have no "bugzilla_email" set and a group no "mailing_list"
address set, both of which are expected to sync the ACLs to bugzilla.

Signed-off-by: Pierre-Yves Chibon <pingou@pingoured.fr>
This commit is contained in:
Pierre-Yves Chibon 2019-11-20 10:52:20 +01:00 committed by Nils Philippsen
parent 1f75496059
commit d61e83a157

View file

@ -199,16 +199,18 @@ class BugzillaProxy:
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.userCache[username] = {
'bugzilla_email': group.mailing_list}
'bugzilla_email': bz_email}
else:
person = self.fas.person_by_username(username)
bz_email = person.get('bugzilla_email', None)
if bz_email is None:
print('%s has no bugzilla email, valid account?'
% username)
else:
self.userCache[username] = {'bugzilla_email': bz_email}
return
self.userCache[username] = {'bugzilla_email': bz_email}
return self.userCache[username]['bugzilla_email'].lower()
def add_edit_component(self, package, collection, owner, description=None,
@ -216,15 +218,21 @@ class BugzillaProxy:
'''Add or update a component to have the values specified.
'''
# Turn the cclist into something usable by bugzilla
initialCCList = list()
if 'people' in cclist:
user_cc = [
self._get_bugzilla_email(cc) for cc in cclist['people']]
initialCCList.extend(user_cc)
if 'groups' in cclist:
group_cc = [
self._get_bugzilla_email(cc) for cc in cclist['groups']]
initialCCList.extend(group_cc)
initialCCList = []
if cclist and 'people' in cclist:
for cc in cclist["people"]:
bz_email = self._get_bugzilla_email(cc)
if bz_email:
initialCCList.append(bz_email)
else:
print(f"** {cc} has no bugzilla_email or mailing_list set **")
if cclist and 'groups' in cclist:
for cc in cclist["groups"]:
bz_email = self._get_bugzilla_email(cc)
if bz_email:
initialCCList.append(bz_email)
else:
print(f"** {cc} has no mailing-list set in FAS! **")
# Add owner to the cclist so comaintainers taking over a bug don't
# have to do this manually