summaryrefslogtreecommitdiffstats
path: root/src/models
diff options
context:
space:
mode:
authorJohn Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>2018-09-25 12:40:22 +0200
committerJohn Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>2018-09-25 14:53:28 +0200
commit7349a6fc5bf22d50ac1550f73c12ebdb7536c16f (patch)
treeb90f11c5d596e709cf17119974ce23a2352f9a4d /src/models
parent040992884b416d5c86e3a06731f26a5b1c68d7a8 (diff)
Contact deletion fix and warning if fetchFull fails and/of contact gone
Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
Diffstat (limited to 'src/models')
-rw-r--r--src/models/contact.js10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/models/contact.js b/src/models/contact.js
index de1ba9a7..3836d91d 100644
--- a/src/models/contact.js
+++ b/src/models/contact.js
@@ -30,11 +30,15 @@ export default class Contact {
*
* @param {string} vcard the vcard data as string with proper new lines
* @param {object} addressbook the addressbook which the contat belongs to
- * @param {string} [url] the url of the contact
- * @param {string} [etag] the current etag of the contact
+ * @param {string} [url=''] the url of the contact
+ * @param {string} [etag=''] the current etag of the contact
* @memberof Contact
*/
- constructor(vcard = '', addressbook, url = '', etag = '') {
+ constructor(vcard, addressbook, url = '', etag = '') {
+ if (typeof vcard !== 'string' || vcard.length === 0) {
+ throw new Error('Invalid vCard')
+ }
+
let jCal = ICAL.parse(vcard)
if (jCal[0] !== 'vcard') {
throw new Error('Only one contact is allowed in the vcard data')