ircdb: Fix hostmask conflict resolution in getUserId

When the first of the two conflicts comes from a transient hostmask set by NickAuth,
the first value in the 'ids' dict would be True, which causes a silly log message,
then Limnoria silently crashes to self.users[id].removeHostmask(hostmask) and then
does not remove the next hostmask which is responsible for the conflict.
This commit is contained in:
Valentin Lorentz 2024-10-20 20:40:35 +02:00
parent 54c0980978
commit 246f4d3e62

View File

@ -786,9 +786,21 @@ class UsersDictionary(utils.IterableMap):
elif len(ids) == 0:
raise KeyError(s)
else:
log.error('Multiple matches found in user database. '
'Removing the offending hostmasks.')
# values in 'ids' are strings if user was identified by
# actual hostmask, or True if they were identified by
# a transient authentication (@identify, NickAuth, GPG,
# etc.)
log.error(
'Multiple matches found in user database: [%s]. '
'Removing the offending hostmasks.',
', '.join(
'<transient>'
if hostmask is True
else repr(hostmask)
for hostmask in ids.values()))
for (id, hostmask) in ids.items():
if hostmask is True:
continue
log.error('Removing %q from user %s.', hostmask, id)
self.users[id].removeHostmask(hostmask)
raise DuplicateHostmask('Ids %r matched.' % ids)