diff options
author | Matěj Cepl <mcepl@redhat.com> | 2013-05-25 01:40:38 +0200 |
---|---|---|
committer | Matěj Cepl <mcepl@redhat.com> | 2013-05-25 01:40:38 +0200 |
commit | b5214aa7a28866cca39e62324b8a5a2fca1f09a5 (patch) | |
tree | afd4b166def4c4c6276741e701d0f6214dfb6196 /importAddrBook.js | |
parent | 5fa320c7ce4ba1b29d32e50a478ba278c904aa4c (diff) | |
download | importLDIF-b5214aa7a28866cca39e62324b8a5a2fca1f09a5.tar.gz |
Calculate .name value if not present in the source.
Fixes #104
Diffstat (limited to 'importAddrBook.js')
-rw-r--r-- | importAddrBook.js | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/importAddrBook.js b/importAddrBook.js index 83256c4..1cb390c 100644 --- a/importAddrBook.js +++ b/importAddrBook.js @@ -201,6 +201,21 @@ } } + // Per RFC 4519 section 3.12 cn and sn attributes are always + // required + if (! contact.hasOwnProperty('name')) { + if (contact.hasOwnProperty('familyName') && + contact.hasOwnProperty('givenName')) { + contact.name = contact.givenName + " " + contact.familyName; + } + else if (contact.hasOwnProperty("org")) { + contact.name = contact.org; + } + else if (contact.hasOwnProperty("jobTitle")) { + contact.name = contact.jobTitle; + } + } + console.log("contact:\n" + contact.toSource()); if (Object.keys(contact).length > 0) { var outObj = new mozContact(); |