Skip to content
This repository has been archived by the owner on Nov 21, 2024. It is now read-only.

Typing notification plugin not working... #141

Open
anishidk opened this issue Jul 17, 2015 · 5 comments
Open

Typing notification plugin not working... #141

anishidk opened this issue Jul 17, 2015 · 5 comments
Labels

Comments

@anishidk
Copy link

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

@benlangfeld
Copy link
Member

Please provide a debug log including the stanzas you receive.

@smokku
Copy link

smokku commented Apr 12, 2016

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

@benlangfeld
Copy link
Member

@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

@smokku
Copy link

smokku commented Apr 12, 2016

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
Copy link

smokku commented Apr 12, 2016

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants