Browse Source

P4TB-357: Follow-up to rev. 351c879ca627: Test existence of localId more elegantly.

1.1.101
Jorg Knobloch 2 years ago
parent
commit
4b221cf312
1 changed files with 6 additions and 10 deletions
  1. +6
    -10
      addon/content/TbContacts.js

+ 6
- 10
addon/content/TbContacts.js View File

@ -23,7 +23,7 @@ const TbContacts = {
// For LDAP and Outlook ABs, the `cardForEmailAddress()` method is not implemented,
// one would have to do a `nsIAbDirectoryQuery.doQuery()` to locate a card.
// The Mac AB doesn't return a stable UID, that is, in the next Thunderbird session
// a new UID is returned. However, localId can be used.
// a new UID is returned. However, localId can be used. More details below.
// Mac and LDAP ABs are readlonly, the Outlook AB is not.
let abURI = ab.URI;
if (abURI.startsWith("moz-abldapdirectory:") || abURI.startsWith("moz-aboutlookdirectory:")) continue;
@ -31,15 +31,11 @@ const TbContacts = {
try {
const card = ab.cardForEmailAddress(emailAddress);
if (card) {
if (abURI.startsWith("moz-abosxdirectory:")) {
try {
// localId is of the form: moz-abosxcard://ACE6A928-78EA-46CC-8186-1B4E5F08E7B8:ABPerson.
// Make it lowercase to match other UIDs allocated by Thunderbird.
userId = card.localId.substr(16).replace(/:.*/, "").toLowerCase();
} catch (ex) {
// localId was removed in bug 1662033, but since bug 1679364 a stable ID is provided in UID.
userId = card.UID;
}
if (abURI.startsWith("moz-abosxdirectory:") && "localId" in card) {
// localId was removed in bug 1662033, but since bug 1679364 the Mac system ID is provided in UID.
// localId is of the form: moz-abosxcard://ACE6A928-78EA-46CC-8186-1B4E5F08E7B8:ABPerson.
// Make it lowercase to match other UIDs allocated by Thunderbird.
userId = card.localId.substr(16).replace(/:.*/, "").toLowerCase();
} else {
userId = card.UID;
}


Loading…
Cancel
Save