Commit 8a63813f authored by JC Brand's avatar JC Brand

Add the ability to set the presence priority.

Fixes #745
parent 17e0e70e
......@@ -51,9 +51,10 @@
an instant room is created. [jcbrand]
- Ensure consistent behavior from `show_controlbox_by_default` [jcbrand]
- #366 Show the chat room occupant's JID in the tooltip (if you're allowed to see it). [jcbrand]
- #610, #785 Add presence priority handling [w3host, jcbrand]
- #694 The `notification_option` wasn't being used consistently. [jcbrand]
- #745 New config option [priority](https://conversejs.org/docs/html/configuration.html#priority) [jcbrand]
- #770 Allow setting contact attrs on chats.open [Ape]
- #610, #785 Add presence priority handling [w3host, jcbrand]
## 2.0.6 (2017-02-13)
......
......@@ -866,6 +866,26 @@ three tokens::
"rid": "876987608760"
}
priority
--------
* Default: ``0``
* Type: Number
Determines the priority used for presence stanzas sent out from this resource
(i.e. this instance of Converse.js).
The priority of a given XMPP chat client determines the importance of its presence
stanzas in relation to stanzas received from other clients of the same user.
In Converse.js, the indicated chat status of a roster contact will be taken from the
presence stanza (and associated resource) with the highest priority.
If multiple resources have the same top priority, then the chat status will be
taken from the most recent present stanza.
For more info you can read `Section 2.2.2.3 of RFC-3921 <https://xmpp.org/rfcs/rfc3921.html#rfc.section.2.2.2.3>`_.
providers_link
--------------
......
......@@ -14,6 +14,38 @@
var $pres = converse.env.$pres;
// See: https://xmpp.org/rfcs/rfc3921.html
describe("A sent presence stanza", function () {
it("has a given priority", mock.initConverse(function (_converse) {
var pres = _converse.xmppstatus.constructPresence('online', 'Hello world');
expect(pres.toLocaleString()).toBe(
"<presence xmlns='jabber:client'>"+
"<status>Hello world</status>"+
"<priority>0</priority>"+
"</presence>"
);
_converse.priority = 2;
pres = _converse.xmppstatus.constructPresence('away', 'Going jogging');
expect(pres.toLocaleString()).toBe(
"<presence xmlns='jabber:client'>"+
"<show>away</show>"+
"<status>Going jogging</status>"+
"<priority>2</priority>"+
"</presence>"
);
delete _converse.priority;
pres = _converse.xmppstatus.constructPresence('dnd', 'Doing taxes');
expect(pres.toLocaleString()).toBe(
"<presence xmlns='jabber:client'>"+
"<show>dnd</show>"+
"<status>Doing taxes</status>"+
"<priority>0</priority>"+
"</presence>"
);
}));
});
describe("A received presence stanza", function () {
it("has its priority taken into account", mock.initConverse(function (_converse) {
......
......@@ -246,6 +246,7 @@
message_storage: 'session',
password: undefined,
prebind_url: null,
priority: 0,
rid: undefined,
roster_groups: true,
show_only_online_users: false,
......@@ -1682,8 +1683,11 @@
presence = $pres().c('show').t(type).up();
}
if (status_message) {
presence.c('status').t(status_message);
presence.c('status').t(status_message).up();
}
presence.c('priority').t(
_.isNaN(Number(_converse.priority)) ? 0 : _converse.priority
);
return presence;
},
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment