# HG changeset patch # User Emmanuel Gil Peyrot # Date 1327719730 -3600 # Node ID 8b739d4e094b2d2c767b3cc0161cdd0b41ffd361 # Parent fbb08a31921de22e01efae6c3a3f4ac17b68feca [presence] Don’t require the object to be passed. diff --git a/plugins/presence.js b/plugins/presence.js --- a/plugins/presence.js +++ b/plugins/presence.js @@ -24,32 +24,34 @@ var legal_types = ['error', 'probe', 'subscribe', 'subscribed', 'unavailable', 'unsubscribe', 'unsubscribed']; Lightstring.stanza.presence = function(object) { - var aPriority, aShow, aStatus; - var payloads = ""; - var attributs = ""; + if (object) { + var payloads = ""; + var attributs = ""; + if (object.type && legal_types.indexOf(object.type) !== -1) + attributs += " type='" + object.type + "'"; - if (object.type && legal_types.indexOf(object.type) !== -1) - attributs += " type='" + object.type + "'"; + if (object.priority) + payloads += "" + object.priority + ""; - if (object.priority) - payloads += "" + object.priority + ""; + if (object.show) + payloads += "" + object.show + ""; - if (object.show) - payloads += "" + object.show + ""; + if (object.status) + payloads += "" + object.status + ""; - if (object.status) - payloads += "" + object.status + ""; + if (object.payload) + payloads += object.payload; - if (object.payload) - payloads += object.payload; + if (payloads) + return "" + payloads + ""; + else + return ""; - if (payloads) - return "" + payloads + ""; - else - return ""; + } else + return ""; }; - Lightstring.presence = function(aConnection, aPriority) { - aConnection.send(Lightstring.stanza.presence(aPriority)); + Lightstring.presence = function(aConnection, aObject) { + aConnection.send(Lightstring.stanza.presence(aObject)); }; })();