freedom-social-xmpp
Advanced tools
Comparing version 0.3.14 to 0.3.15
@@ -297,6 +297,2 @@ /*jslint white:true,sloppy:true */ | ||
message.t(JSON.stringify(body)); | ||
stanza.c('nos:skiparchive', { | ||
value: 'true', | ||
'xmlns:nos' : 'google:nosave' | ||
}); | ||
} else { | ||
@@ -313,2 +309,6 @@ body = ''; | ||
stanza.c('nos:skiparchive', { | ||
value: 'true', | ||
'xmlns:nos' : 'google:nosave' | ||
}); | ||
@@ -543,3 +543,3 @@ try { | ||
// No response to ping, we are disconnected. | ||
console.warn('No ping response from server, logging out'); | ||
this.logger.warn('No ping response from server, logging out'); | ||
this.logout(); | ||
@@ -552,3 +552,3 @@ } | ||
if (this.pollForDisconnectInterval_) { | ||
console.error('startPollingForDisconnect_ called while already polling'); | ||
this.logger.error('startPollingForDisconnect_ called while already polling'); | ||
return; | ||
@@ -565,3 +565,3 @@ } | ||
// that we are still connected to the XMPP server. | ||
console.log('Detected sleep for ' + | ||
this.logger.log('Detected sleep for ' + | ||
(nowTimestampMs - lastAwakeTimestampMs) + 'ms'); | ||
@@ -568,0 +568,0 @@ this.ping_(); |
@@ -1,2 +0,2 @@ | ||
/*globals freedom:true,setTimeout,window,VCardStore:true */ | ||
/*globals freedom:true,setTimeout,window,VCardStore:true,console */ | ||
/*jslint indent:2,white:true,sloppy:true */ | ||
@@ -6,9 +6,11 @@ | ||
if (freedom && freedom['core.storage']) { | ||
this.storage = freedom['core.storage'](); | ||
this._storage = freedom['core.storage'](); | ||
} | ||
this.clients = {}; | ||
this.users = {}; | ||
this.requestTime = {}; | ||
this.requestQueue = []; | ||
this.fetchTime = new Date(); | ||
this._requestTime = {}; | ||
this._requestQueue = []; | ||
this._fetchTime = new Date(); | ||
this._init(); | ||
}; | ||
@@ -36,2 +38,4 @@ | ||
VCardStore.prototype.PREFIX = "vcard-"; | ||
VCardStore.prototype.hasClient = function(user) { | ||
@@ -96,52 +100,28 @@ return this.clients[user] ? true : false; | ||
VCardStore.prototype.updateVcard = function(from, message) { | ||
var userid = new window.XMPP.JID(from).bare().toString(), | ||
user = this.users[userid] || {}, | ||
name, url, photo, | ||
changed = false; | ||
if (message.attr('xmlns') !== 'vcard-temp' || | ||
!this.storage) { | ||
var userid = new window.XMPP.JID(from).bare().toString(); | ||
if (message.attr('xmlns') !== 'vcard-temp') { | ||
return; | ||
} | ||
user.userId = userid; | ||
name = message.getChildText('FN'); | ||
url = message.getChildText('URL'); | ||
photo = message.getChild('PHOTO'); | ||
// Store that we've seen a vcard from the server | ||
this.updateUser(userid, "haveVcard", true); | ||
if (name) { | ||
if (name !== user.name) { | ||
changed = true; | ||
} | ||
user.name = name; | ||
if (message.getChildText("FN")) { | ||
this.updateUser(userid, "name", message.getChildText("FN")); | ||
} | ||
if (url) { | ||
if (url !== user.url) { | ||
changed = true; | ||
} | ||
user.url = url; | ||
if (message.getChildText("URL")) { | ||
this.updateUser(userid, "url", message.getChildText("URL")); | ||
} | ||
var photo = message.getChild('PHOTO'); | ||
if (photo && photo.getChildText('EXTVAL')) { | ||
if (user.imageData !== photo.getChildText('EXTVAL')) { | ||
changed = true; | ||
} | ||
user.imageData = photo.getChildText('EXTVAL'); | ||
this.updateUser(userid, "imageData", photo.getChildText("EXTVAL")); | ||
} else if (photo && photo.getChildText('TYPE') && | ||
photo.getChildText('BINVAL')) { | ||
url = 'data:' + | ||
this.updateUser(userid, "imageData", 'data:' + | ||
photo.getChildText('TYPE') + ';base64,' + | ||
photo.getChildText('BINVAL'); | ||
if (user.imageData !== url) { | ||
changed = true; | ||
} | ||
user.imageData = url; | ||
photo.getChildText('BINVAL') | ||
); | ||
} | ||
user.lastSeen = Date.now(); | ||
if (changed) { | ||
user.lastUpdated = Date.now(); | ||
this.users[userid] = user; | ||
this.onUserChange(user); | ||
} | ||
this.storage.set('vcard-' + userid, JSON.stringify(user)); | ||
}; | ||
@@ -173,3 +153,4 @@ | ||
this.users[user] = { | ||
userId: user | ||
userId: user, | ||
haveVcard: false | ||
}; | ||
@@ -181,2 +162,5 @@ } | ||
this.onUserChange(this.users[user]); | ||
if (this._storage) { | ||
this._storage.set(this.PREFIX + user, JSON.stringify(this.users[user])); | ||
} | ||
}; | ||
@@ -186,29 +170,24 @@ | ||
var userid = new window.XMPP.JID(user).bare().toString(); | ||
var time = new Date(); | ||
this.storage.get('vcard-' + userid).then(function(result) { | ||
if (result === null || result === undefined) { | ||
this.fetchVcard(user); | ||
} else if (hash && hash !== result.hash) { | ||
this.fetchVcard(user); | ||
if (!this.users.hasOwnProperty(userid) || // Haven't seen user | ||
this.users[userid].haveVcard === false || // Haven't tried to request vcard before | ||
(hash && this.users[userid].hash !== hash)) { | ||
if (!this._requestTime[user] || | ||
(time - this._requestTime[user] > this.REQUEST_TIMEOUT)) { | ||
this.updateUser(userid, "hash", hash); | ||
this._requestTime[user] = time; | ||
this._requestQueue.push(user); | ||
this._checkVCardQueue(); | ||
} | ||
}.bind(this)); | ||
}; | ||
VCardStore.prototype.fetchVcard = function(user) { | ||
var time = new Date(); | ||
if (!this.requestTime[user] || (time - this.requestTime[user] > | ||
this.REQUEST_TIMEOUT)) { | ||
this.requestTime[user] = time; | ||
this.requestQueue.push(user); | ||
this.checkVCardQueue(); | ||
} | ||
}; | ||
VCardStore.prototype.checkVCardQueue = function() { | ||
VCardStore.prototype._checkVCardQueue = function() { | ||
var time = new Date(), next; | ||
if (this.requestQueue.length < 1) { | ||
if (this._requestQueue.length < 1) { | ||
return; | ||
} else if ((time - this.fetchTime) > this.THROTTLE_TIMEOUT) { | ||
next = this.requestQueue.shift(); | ||
this.fetchTime = time; | ||
} else if ((time - this._fetchTime) > this.THROTTLE_TIMEOUT) { | ||
next = this._requestQueue.shift(); | ||
this._fetchTime = time; | ||
@@ -218,4 +197,29 @@ // Request loadCard from delegate. | ||
} else { | ||
setTimeout(this.checkVCardQueue.bind(this), this.THROTTLE_TIMEOUT); | ||
setTimeout(this._checkVCardQueue.bind(this), this.THROTTLE_TIMEOUT); | ||
} | ||
}; | ||
VCardStore.prototype._init = function() { | ||
var userId, profile; | ||
var tryLoad = function(k, v) { | ||
try { | ||
userId = k.substr(this.PREFIX.length); | ||
this.users[userId] = JSON.parse(v); | ||
} catch(e) { | ||
console.warn(e); | ||
} | ||
}; | ||
if (!this._storage) { | ||
return; | ||
} | ||
this._storage.keys().then(function(keys) { | ||
for(var i = 0; i < keys.length; i++) { | ||
var k = keys[i]; | ||
if (k.substr(0, this.PREFIX.length) === this.PREFIX) { | ||
this._storage.get(k).then(tryLoad.bind(this, k)); | ||
} | ||
} | ||
}.bind(this)); | ||
}; |
{ | ||
"name": "freedom-social-xmpp", | ||
"description": "XMPP Social provider for freedomjs", | ||
"version": "0.3.14", | ||
"version": "0.3.15", | ||
"homepage": "http://freedomjs.org", | ||
@@ -6,0 +6,0 @@ "bugs": { |
@@ -297,6 +297,2 @@ /*jslint white:true,sloppy:true */ | ||
message.t(JSON.stringify(body)); | ||
stanza.c('nos:skiparchive', { | ||
value: 'true', | ||
'xmlns:nos' : 'google:nosave' | ||
}); | ||
} else { | ||
@@ -313,2 +309,6 @@ body = ''; | ||
stanza.c('nos:skiparchive', { | ||
value: 'true', | ||
'xmlns:nos' : 'google:nosave' | ||
}); | ||
@@ -543,3 +543,3 @@ try { | ||
// No response to ping, we are disconnected. | ||
console.warn('No ping response from server, logging out'); | ||
this.logger.warn('No ping response from server, logging out'); | ||
this.logout(); | ||
@@ -552,3 +552,3 @@ } | ||
if (this.pollForDisconnectInterval_) { | ||
console.error('startPollingForDisconnect_ called while already polling'); | ||
this.logger.error('startPollingForDisconnect_ called while already polling'); | ||
return; | ||
@@ -565,3 +565,3 @@ } | ||
// that we are still connected to the XMPP server. | ||
console.log('Detected sleep for ' + | ||
this.logger.log('Detected sleep for ' + | ||
(nowTimestampMs - lastAwakeTimestampMs) + 'ms'); | ||
@@ -568,0 +568,0 @@ this.ping_(); |
@@ -1,2 +0,2 @@ | ||
/*globals freedom:true,setTimeout,window,VCardStore:true */ | ||
/*globals freedom:true,setTimeout,window,VCardStore:true,console */ | ||
/*jslint indent:2,white:true,sloppy:true */ | ||
@@ -6,9 +6,11 @@ | ||
if (freedom && freedom['core.storage']) { | ||
this.storage = freedom['core.storage'](); | ||
this._storage = freedom['core.storage'](); | ||
} | ||
this.clients = {}; | ||
this.users = {}; | ||
this.requestTime = {}; | ||
this.requestQueue = []; | ||
this.fetchTime = new Date(); | ||
this._requestTime = {}; | ||
this._requestQueue = []; | ||
this._fetchTime = new Date(); | ||
this._init(); | ||
}; | ||
@@ -36,2 +38,4 @@ | ||
VCardStore.prototype.PREFIX = "vcard-"; | ||
VCardStore.prototype.hasClient = function(user) { | ||
@@ -96,52 +100,28 @@ return this.clients[user] ? true : false; | ||
VCardStore.prototype.updateVcard = function(from, message) { | ||
var userid = new window.XMPP.JID(from).bare().toString(), | ||
user = this.users[userid] || {}, | ||
name, url, photo, | ||
changed = false; | ||
if (message.attr('xmlns') !== 'vcard-temp' || | ||
!this.storage) { | ||
var userid = new window.XMPP.JID(from).bare().toString(); | ||
if (message.attr('xmlns') !== 'vcard-temp') { | ||
return; | ||
} | ||
user.userId = userid; | ||
name = message.getChildText('FN'); | ||
url = message.getChildText('URL'); | ||
photo = message.getChild('PHOTO'); | ||
// Store that we've seen a vcard from the server | ||
this.updateUser(userid, "haveVcard", true); | ||
if (name) { | ||
if (name !== user.name) { | ||
changed = true; | ||
} | ||
user.name = name; | ||
if (message.getChildText("FN")) { | ||
this.updateUser(userid, "name", message.getChildText("FN")); | ||
} | ||
if (url) { | ||
if (url !== user.url) { | ||
changed = true; | ||
} | ||
user.url = url; | ||
if (message.getChildText("URL")) { | ||
this.updateUser(userid, "url", message.getChildText("URL")); | ||
} | ||
var photo = message.getChild('PHOTO'); | ||
if (photo && photo.getChildText('EXTVAL')) { | ||
if (user.imageData !== photo.getChildText('EXTVAL')) { | ||
changed = true; | ||
} | ||
user.imageData = photo.getChildText('EXTVAL'); | ||
this.updateUser(userid, "imageData", photo.getChildText("EXTVAL")); | ||
} else if (photo && photo.getChildText('TYPE') && | ||
photo.getChildText('BINVAL')) { | ||
url = 'data:' + | ||
this.updateUser(userid, "imageData", 'data:' + | ||
photo.getChildText('TYPE') + ';base64,' + | ||
photo.getChildText('BINVAL'); | ||
if (user.imageData !== url) { | ||
changed = true; | ||
} | ||
user.imageData = url; | ||
photo.getChildText('BINVAL') | ||
); | ||
} | ||
user.lastSeen = Date.now(); | ||
if (changed) { | ||
user.lastUpdated = Date.now(); | ||
this.users[userid] = user; | ||
this.onUserChange(user); | ||
} | ||
this.storage.set('vcard-' + userid, JSON.stringify(user)); | ||
}; | ||
@@ -173,3 +153,4 @@ | ||
this.users[user] = { | ||
userId: user | ||
userId: user, | ||
haveVcard: false | ||
}; | ||
@@ -181,2 +162,5 @@ } | ||
this.onUserChange(this.users[user]); | ||
if (this._storage) { | ||
this._storage.set(this.PREFIX + user, JSON.stringify(this.users[user])); | ||
} | ||
}; | ||
@@ -186,29 +170,24 @@ | ||
var userid = new window.XMPP.JID(user).bare().toString(); | ||
var time = new Date(); | ||
this.storage.get('vcard-' + userid).then(function(result) { | ||
if (result === null || result === undefined) { | ||
this.fetchVcard(user); | ||
} else if (hash && hash !== result.hash) { | ||
this.fetchVcard(user); | ||
if (!this.users.hasOwnProperty(userid) || // Haven't seen user | ||
this.users[userid].haveVcard === false || // Haven't tried to request vcard before | ||
(hash && this.users[userid].hash !== hash)) { | ||
if (!this._requestTime[user] || | ||
(time - this._requestTime[user] > this.REQUEST_TIMEOUT)) { | ||
this.updateUser(userid, "hash", hash); | ||
this._requestTime[user] = time; | ||
this._requestQueue.push(user); | ||
this._checkVCardQueue(); | ||
} | ||
}.bind(this)); | ||
}; | ||
VCardStore.prototype.fetchVcard = function(user) { | ||
var time = new Date(); | ||
if (!this.requestTime[user] || (time - this.requestTime[user] > | ||
this.REQUEST_TIMEOUT)) { | ||
this.requestTime[user] = time; | ||
this.requestQueue.push(user); | ||
this.checkVCardQueue(); | ||
} | ||
}; | ||
VCardStore.prototype.checkVCardQueue = function() { | ||
VCardStore.prototype._checkVCardQueue = function() { | ||
var time = new Date(), next; | ||
if (this.requestQueue.length < 1) { | ||
if (this._requestQueue.length < 1) { | ||
return; | ||
} else if ((time - this.fetchTime) > this.THROTTLE_TIMEOUT) { | ||
next = this.requestQueue.shift(); | ||
this.fetchTime = time; | ||
} else if ((time - this._fetchTime) > this.THROTTLE_TIMEOUT) { | ||
next = this._requestQueue.shift(); | ||
this._fetchTime = time; | ||
@@ -218,4 +197,29 @@ // Request loadCard from delegate. | ||
} else { | ||
setTimeout(this.checkVCardQueue.bind(this), this.THROTTLE_TIMEOUT); | ||
setTimeout(this._checkVCardQueue.bind(this), this.THROTTLE_TIMEOUT); | ||
} | ||
}; | ||
VCardStore.prototype._init = function() { | ||
var userId, profile; | ||
var tryLoad = function(k, v) { | ||
try { | ||
userId = k.substr(this.PREFIX.length); | ||
this.users[userId] = JSON.parse(v); | ||
} catch(e) { | ||
console.warn(e); | ||
} | ||
}; | ||
if (!this._storage) { | ||
return; | ||
} | ||
this._storage.keys().then(function(keys) { | ||
for(var i = 0; i < keys.length; i++) { | ||
var k = keys[i]; | ||
if (k.substr(0, this.PREFIX.length) === this.PREFIX) { | ||
this._storage.get(k).then(tryLoad.bind(this, k)); | ||
} | ||
} | ||
}.bind(this)); | ||
}; |
@@ -121,3 +121,3 @@ /*globals freedom, console, self*/ | ||
// Just call boot when login is clicked | ||
document.getElementById('uid').onclick = function() { | ||
document.getElementById('log-in-or-out').onclick = function() { | ||
chatClient.login(); | ||
@@ -124,0 +124,0 @@ }; |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
11
879328
26780