auto_away shouldn't change the user's status if it's set to dnd

Fixes #620
This commit is contained in:
JC Brand 2017-02-25 09:52:31 +00:00
parent 9779e83931
commit f60b4fc268
3 changed files with 45 additions and 9 deletions

View File

@ -57,6 +57,7 @@
[muc_show_join_leave](https://conversejs.org/docs/html/configuration.html#muc-show-join-leave) [muc_show_join_leave](https://conversejs.org/docs/html/configuration.html#muc-show-join-leave)
- #366 Show the chat room occupant's JID in the tooltip (if you're allowed to see it). [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] - #610, #785 Add presence priority handling [w3host, jcbrand]
- #620 `auto_away` shouldn't change the user's status if it's set to `dnd`. [jcbrand]
- #694 The `notification_option` wasn't being used consistently. [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] - #745 New config option [priority](https://conversejs.org/docs/html/configuration.html#priority) [jcbrand]
- #770 Allow setting contact attrs on chats.open [Ape] - #770 Allow setting contact attrs on chats.open [Ape]

View File

@ -96,10 +96,8 @@
_converse.auto_xa = 6; _converse.auto_xa = 6;
expect(_converse.xmppstatus.getStatus()).toBe('online'); expect(_converse.xmppstatus.getStatus()).toBe('online');
while (i <= _converse.auto_away) { while (i <= _converse.auto_away) {
_converse.onEverySecond(); _converse.onEverySecond(); i++;
i++;
} }
expect(_converse.auto_changed_status).toBe(true); expect(_converse.auto_changed_status).toBe(true);
@ -115,10 +113,46 @@
expect(_converse.xmppstatus.getStatus()).toBe('online'); expect(_converse.xmppstatus.getStatus()).toBe('online');
expect(_converse.auto_changed_status).toBe(false); expect(_converse.auto_changed_status).toBe(false);
// Reset values // Check that it also works for the chat feature
_converse.auto_away = 0; _converse.xmppstatus.setStatus('chat');
_converse.auto_xa = 0; i = 0;
_converse.auto_changed_status = false; while (i <= _converse.auto_away) {
_converse.onEverySecond();
i++;
}
expect(_converse.auto_changed_status).toBe(true);
while (i <= _converse.auto_xa) {
expect(_converse.xmppstatus.getStatus()).toBe('away');
_converse.onEverySecond();
i++;
}
expect(_converse.xmppstatus.getStatus()).toBe('xa');
expect(_converse.auto_changed_status).toBe(true);
_converse.onUserActivity();
expect(_converse.xmppstatus.getStatus()).toBe('online');
expect(_converse.auto_changed_status).toBe(false);
// Check that it doesn't work for 'dnd'
_converse.xmppstatus.setStatus('dnd');
i = 0;
while (i <= _converse.auto_away) {
_converse.onEverySecond();
i++;
}
expect(_converse.xmppstatus.getStatus()).toBe('dnd');
expect(_converse.auto_changed_status).toBe(false);
while (i <= _converse.auto_xa) {
expect(_converse.xmppstatus.getStatus()).toBe('dnd');
_converse.onEverySecond();
i++;
}
expect(_converse.xmppstatus.getStatus()).toBe('dnd');
expect(_converse.auto_changed_status).toBe(false);
_converse.onUserActivity();
expect(_converse.xmppstatus.getStatus()).toBe('dnd');
expect(_converse.auto_changed_status).toBe(false);
})); }));
}); });

View File

@ -350,11 +350,12 @@
} }
if (_converse.auto_away > 0 && if (_converse.auto_away > 0 &&
_converse.idle_seconds > _converse.auto_away && _converse.idle_seconds > _converse.auto_away &&
stat !== 'away' && stat !== 'xa') { stat !== 'away' && stat !== 'xa' && stat !== 'dnd') {
_converse.auto_changed_status = true; _converse.auto_changed_status = true;
_converse.xmppstatus.setStatus('away'); _converse.xmppstatus.setStatus('away');
} else if (_converse.auto_xa > 0 && } else if (_converse.auto_xa > 0 &&
_converse.idle_seconds > _converse.auto_xa && stat !== 'xa') { _converse.idle_seconds > _converse.auto_xa &&
stat !== 'xa' && stat !== 'dnd') {
_converse.auto_changed_status = true; _converse.auto_changed_status = true;
_converse.xmppstatus.setStatus('xa'); _converse.xmppstatus.setStatus('xa');
} }