Merge pull request #311 from gbonvehi/fix-show-online-presence-issue-305
Fix show online presence issue #305
This commit is contained in:
commit
75c4e8f118
18
converse.js
18
converse.js
|
@ -4250,7 +4250,7 @@
|
|||
this.XMPPStatus = Backbone.Model.extend({
|
||||
initialize: function () {
|
||||
this.set({
|
||||
'status' : this.get('status') || 'online'
|
||||
'status' : this.getStatus()
|
||||
});
|
||||
this.on('change', $.proxy(function (item) {
|
||||
if (this.get('fullname') === undefined) {
|
||||
|
@ -4270,12 +4270,14 @@
|
|||
}, this));
|
||||
},
|
||||
|
||||
sendPresence: function (type) {
|
||||
if (type === undefined) {
|
||||
sendPresence: function (type, status_message) {
|
||||
if (typeof type === 'undefined') {
|
||||
type = this.get('status') || 'online';
|
||||
}
|
||||
var status_message = this.get('status_message'),
|
||||
presence;
|
||||
if (typeof status_message === 'undefined') {
|
||||
status_message = this.get('status_message');
|
||||
}
|
||||
var presence;
|
||||
// Most of these presence types are actually not explicitly sent,
|
||||
// but I add all of them here fore reference and future proofing.
|
||||
if ((type === 'unavailable') ||
|
||||
|
@ -4309,8 +4311,12 @@
|
|||
this.save({'status': value});
|
||||
},
|
||||
|
||||
getStatus: function() {
|
||||
return this.get('status') || 'online';
|
||||
},
|
||||
|
||||
setStatusMessage: function (status_message) {
|
||||
converse.connection.send($pres().c('show').t(this.get('status')).up().c('status').t(status_message));
|
||||
this.sendPresence(this.getStatus(), status_message);
|
||||
this.save({'status_message': status_message});
|
||||
if (this.xhr_custom_status) {
|
||||
$.ajax({
|
||||
|
|
|
@ -14,6 +14,7 @@ Changelog
|
|||
* #304 Added Polish translations. [ser]
|
||||
* New Makefile.win to build in Windows environments. [gbonvehi]
|
||||
* Strophe.log and Strophe.error now uses converse.log to output messages. [gbonvehi]
|
||||
* #305 presence/show text in XMPP request isn't allowed by specification. [gbonvehi]
|
||||
|
||||
0.8.6 (2014-12-07)
|
||||
------------------
|
||||
|
|
29
spec/xmppstatus.js
Normal file
29
spec/xmppstatus.js
Normal file
|
@ -0,0 +1,29 @@
|
|||
(function (root, factory) {
|
||||
define([
|
||||
"jquery",
|
||||
"mock",
|
||||
"test_utils"
|
||||
], function ($, mock, test_utils) {
|
||||
return factory($, mock, test_utils);
|
||||
}
|
||||
);
|
||||
} (this, function ($, mock, test_utils) {
|
||||
return describe("The XMPPStatus model", $.proxy(function(mock, test_utils) {
|
||||
beforeEach($.proxy(function () {
|
||||
window.localStorage.clear();
|
||||
window.sessionStorage.clear();
|
||||
}, converse));
|
||||
it("won't send <show>online when setting a custom status message", $.proxy(function () {
|
||||
this.xmppstatus.save({'status': 'online'});
|
||||
spyOn(this.xmppstatus, 'setStatusMessage').andCallThrough();
|
||||
spyOn(converse.connection, 'send');
|
||||
this.xmppstatus.setStatusMessage("I'm also happy!");
|
||||
runs (function () {
|
||||
expect(converse.connection.send).toHaveBeenCalled();
|
||||
var $stanza = $(converse.connection.send.argsForCall[0][0].tree());
|
||||
expect($stanza.children().length).toBe(1);
|
||||
expect($stanza.children('show').length).toBe(0);
|
||||
});
|
||||
}, converse));
|
||||
}, converse, mock, test_utils));
|
||||
}));
|
|
@ -67,7 +67,8 @@ require([
|
|||
"spec/chatroom",
|
||||
"spec/minchats",
|
||||
"spec/profiling",
|
||||
"spec/register"
|
||||
"spec/register",
|
||||
"spec/xmppstatus"
|
||||
], function () {
|
||||
// Make sure this callback is only called once.
|
||||
delete converse.callback;
|
||||
|
|
Loading…
Reference in New Issue
Block a user