candy-plugins
candy-plugins copied to clipboard
Typing notification plugin not working...
Hi, Candy 2.0 with typing notifications is not working. I just check the code in plugin, its not getting "obj.chatstate", this value is undefined
Please provide a debug log including the stanzas you receive.
RECV: <message xmlns='jabber:client' type='chat' to='[email protected]/Candy' id='ab46a' from='[email protected]/smoku__'>
<x xmlns='jabber:x:event'>
<id/>
<composing/>
</x>
<composing xmlns='http://jabber.org/protocol/chatstates'/>
</message>
and at https://github.com/candy-chat/candy/blob/v2.0.0/src/core/event.js#L790 we have
} else if(msg.children('body').length > 0) {
// Private chat message
if(msg.attr('type') === 'chat' || msg.attr('type') === 'normal') {
[...]
self.Jabber.Room._checkForChatStateNotification(msg, roomJid, name);
// Unhandled message
} else {
return true;
}
So, chatstates are checked only for message with a <body>
which is pretty pointless, as there is little sense in announcing that the message is in the works, when you just received this message. ;-)
@smokku Would you drop a test case and potentially a fix? https://github.com/candy-chat/candy/blob/master/tests/candy/unit/core/event.js#L1266
Doh... If it was easy to fix, I would just post a diff. :-(
This whole else if
depends on 'body' existence... And I cannot just put _checkForChatStateNotification
in the else
, as this call depends on previous computation of roomJid
. Looks like this needs hell of a refactor, which I am not up to. Sorry. ;-)
As for the test case, drop https://github.com/candy-chat/candy/blob/master/tests/candy/unit/core/event.js#L1302-1303
bdd.describe('of state composing', function () {
var receiveMessage = function () {
testHelper.receiveStanza(
$msg({
to: '[email protected]',
from: '[email protected]/resource1',
type: 'chat'
})
- .c('body').t('Some message text')
- .up()
.c('composing', {xmlns: 'http://jabber.org/protocol/chatstates'})
);
};
"composing" message with a body is a unicorn. :)