candy-plugins icon indicating copy to clipboard operation
candy-plugins copied to clipboard

Typing notification plugin not working...

Open anishidk opened this issue 9 years ago • 5 comments

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

anishidk avatar Jul 17 '15 04:07 anishidk

Please provide a debug log including the stanzas you receive.

benlangfeld avatar Jul 17 '15 11:07 benlangfeld

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 avatar Apr 12 '16 20:04 smokku

@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

benlangfeld avatar Apr 12 '16 20:04 benlangfeld

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. ;-)

smokku avatar Apr 12 '16 21:04 smokku

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. :)

smokku avatar Apr 12 '16 21:04 smokku