Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Adding device options and bug fix

  • Loading branch information...
commit 6ee3b9d7e51f0f167074a692b0e7c91f33ea9caa 1 parent 43b20d4
@donovanh authored
Showing with 17 additions and 9 deletions.
  1. +17 −9 converser-feedback.js
View
26 converser-feedback.js
@@ -18,16 +18,24 @@ converser.api = {
//
// Returns true on success, false on failure
//
- subscribe: function(identity) {
+ subscribe: function(identity, device) {
+
+ // Check for whether device has been specified
+ if (typeof device == undefined) { device = null; }
+
+ if (!device) {
+ device = {
+ os: window.device.name, // phonegap
+ version: window.device.version, // phonegap - don't send if ios!
+ model: window.device.name // phonegap
+ };
+ }
+
var data = {
ident: identity,
- device: {
- os: device.name, // phonegap
- version: device.version, // phonegap - don't send if ios!
- model: device.name // phonegap
- }
+ device: device
};
-
+
var response = converser.api.post('/subscribe', JSON.stringify(data));
if (response.status == 201) {
@@ -37,7 +45,7 @@ converser.api = {
// If there's an error, there is error text available
// in the JSON response -> { "error_text" : "Oh Noes!"}
- return (response.status != 200 && response.status != 201);
+ return (response.status == 200 || response.status == 201);
},
// Send feedback from this device! Parameters are
@@ -61,7 +69,7 @@ converser.api = {
// If there's an error, there is error text available
// in the JSON response -> { "error_text" : "Oh Noes!"}
- return (response.status != 200 && response.status != 201);
+ return (response.status == 200 || response.status == 201);
},
// Utility function - get the stored device identity
Please sign in to comment.
Something went wrong with that request. Please try again.