When Alice adds an existing proper contact again via
briar:// link, we throw a
ContactExistsException that is used to show warnings to her to warn about a potential attack that might be in progress with one of the contacts trying to discover her contacts or non-contacts. The exception carries the local
AuthorId as well as the remote
Author so that a warning message can explain to Alice who the involved contacts are. However it lacks the alias Alice might have given to the existing contact. The result is that only the original self-given name of the contact can be displayed in warnings. I think this might confuse Alice as the contact name displayed in the warning can be different from the name displayed in her contact list and also can be rather ambiguous.
I propose we add the alias to the
ContactExistsException. Among the three places where this exception gets created, in one place (in
DatabaseComponentImpl#addPendingContact()) we already have the existing contact retrieved from the db readily available and could set the additional data right away. In the two other places (in
DatabaseComponentImpl#addContact()), we don't yet have the contact retrieved. Instead we checked
containsContact() there. I think we could either just retrieve the existing contact additionally there, shouldn't be a huge burden in terms of performance. We could also leave out the
containsContact() check and just check if the contact retrieved is
!= null. Maybe we can even leave out the
containsIdentity() in this case? Either way I think performance shouldn't be an issue.