Parcourir la source

Fix issue #305, show=online presence sent

setStatusMessage was modified to send the presence using
sendPresence method which skips show tag when type is 'online'
Added getStatus helper method
Guillermo Bonvehí il y a 10 ans
Parent
commit
fe03940f53
1 fichiers modifiés avec 12 ajouts et 6 suppressions
  1. 12 6
      converse.js

+ 12 - 6
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({