diff --git a/modules/collection.js b/modules/collection.js index 26ff0ef..ed17ad9 100644 --- a/modules/collection.js +++ b/modules/collection.js @@ -158,6 +158,10 @@ SnowlCollection.prototype = { this._messageIndex[message.id] = message; } } + catch(ex) { + this._log.error("Error retrieving messages - " + ex); + return this._messages = []; + } finally { statement.reset(); } @@ -258,13 +262,16 @@ SnowlCollection.prototype = { if (condition.type != "ARRAY") for (let [name, value] in Iterator(condition.parameters)) { statement.params[name] = value; -this._log.info("_generateStatement: name:value - "+name+" : "+value.toString()); -this._log.info("_generateStatement: params - "+statement.params[name]); +//this._log.info("_generateStatement: name:value - "+name+" : "+value.toString()); +//this._log.info("_generateStatement: params - "+statement.params[name]); } for each (let condition in this.filters) - for (let [name, value] in Iterator(condition.parameters)) + for (let [name, value] in Iterator(condition.parameters)) { statement.params[name] = value; +//this._log.info("_generateStatement: name:value - "+name+" : "+value.toString()); +//this._log.info("_generateStatement: params - "+statement.params[name]); + } return statement; }, diff --git a/modules/feed.js b/modules/feed.js index 1c68b82..492c41d 100644 --- a/modules/feed.js +++ b/modules/feed.js @@ -431,10 +431,14 @@ SnowlFeed.prototype = { message.source = this; message.externalID = aExternalID; message.subject = aEntry.title.text; - message.timestamp = aEntry.updated ? new Date(SnowlDateUtils.RFC822Date(aEntry.updated)) - : aEntry.published ? new Date(SnowlDateUtils.RFC822Date(aEntry.published)) - : aEntry.fields.get("dc:date") ? ISO8601DateUtils.parse(aEntry.fields.get("dc:date")) + message.timestamp = aEntry.updated ? new Date(SnowlDateUtils.RFC822Date(aEntry.updated)) + : aEntry.published ? new Date(SnowlDateUtils.RFC822Date(aEntry.published)) : null; + if (!message.timestamp && aEntry.fields.get("dc:date")) { + // This date routine throws for really invalid dates. + try { message.timestamp = ISO8601DateUtils.parse(aEntry.fields.get("dc:date")) } + catch(ex) { message.timestamp = null; } + } message.received = aReceived; message.link = aEntry.link; @@ -628,6 +632,10 @@ SnowlFeed.prototype = { let fieldName = field.name.replace(/^null/, ""); message.headers[fieldName] = field.value.substring(0, 500) + (field.value.length > 500 ? " [...]" : ""); + + // One last try to get a valid date.. + if (!message.timestamp && fieldName == "publicationDate") + message.timestamp = new Date(SnowlDateUtils.RFC822Date(field.value)); } if (field.name.match(/lang/g)) {