cozy-notifications-helper
Advanced tools
Comparing version 1.0.1 to 1.0.2
// Generated by CoffeeScript 1.6.3 | ||
(function() { | ||
var Client, authentifiedEnvs, client, initialized, map, queue, _ref, | ||
var Client, authentifiedEnvs, client, initialized, queue, _ref, | ||
__indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; }; | ||
@@ -16,21 +16,26 @@ | ||
queue = []; | ||
initialized = false; | ||
queue = []; | ||
module.exports.initializeRequest = function() { | ||
var map; | ||
initialized = false; | ||
map = "function (doc) {\n if (doc.docType.toLowerCase() === \"notification\") {\n if(doc.type === 'persistent') {\n emit([doc.app, doc.ref], doc);\n }\n }\n}"; | ||
return client.put('request/notification/byApps/', { | ||
map: map | ||
}, function(err, res, body) { | ||
var msg; | ||
if (err != null) { | ||
msg = "An error occurred while initializing notification module"; | ||
return console.log("" + msg + " -- " + err); | ||
} else { | ||
initialized = true; | ||
return module.exports._emptyQueue(); | ||
} | ||
}); | ||
}; | ||
map = "function (doc) {\n if (doc.docType.toLowerCase() === \"notification\") {\n if(doc.type === 'persistent') {\n emit([doc.app, doc.ref], doc);\n }\n }\n}"; | ||
module.exports.initializeRequest(); | ||
client.put('request/notification/byApps/', { | ||
map: map | ||
}, function(err, res, body) { | ||
var msg; | ||
if (err != null) { | ||
msg = "An error occurred while initializing notification module"; | ||
return console.log("" + msg + " -- " + err); | ||
} else { | ||
initialized = true; | ||
return module.exports._emptyQueue(); | ||
} | ||
}); | ||
module.exports.manage = function(notification, type, callback) { | ||
@@ -66,3 +71,6 @@ var issues, msg; | ||
return callback(err); | ||
} else if (!body || body.length === 0) { | ||
} else if ((body != null) && (body.error != null) && (res != null ? res.statusCode : void 0) === 404) { | ||
module.exports._queueOperation('createOrUpdate', notification, callback); | ||
return module.exports.initializeRequest(); | ||
} else if ((body == null) || body.length === 0) { | ||
return module.exports._processCreation(notification, callback); | ||
@@ -69,0 +77,0 @@ } else { |
{ | ||
"name": "cozy-notifications-helper", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "lib/main.js", |
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
33542
233
0