Anton Shestakov <av6@dwimlabs.net>, Thu, 07 Apr 2016 22:56:16 +0800
index: check if roster has the item before removing it
Sometimes we get events from contacts that are not in user's roster, trying to
remove such contacts used to fail before this patch.
coffee/xmpp.coffee
Permissions: -rw-r--r--
console.debug('connection exists, not reconnecting') @conn = new Strophe.Connection("https://#{ Tram.config.host }/http-bind") jid = "#{ node }@#{ Tram.config.domain }" @conn.connect(jid, pass, @onConnect) @conn.register.connect(Tram.config.domain, @onConnect) register: (username, password) -> @conn.register.fields.username = username @conn.register.fields.password = password savevCard: (data, okcb, failcb) -> $vcard = $iq(type: 'set').c('vCard', xmlns: Strophe.NS.VCARD) $vcard.c('NICKNAME').t(data.nickname).up() $vcard.c('FN').t(data.fullname).up() bi = data.avatar.indexOf(b) type = data.avatar.substr(dl, bi - dl) binval = data.avatar.substr(bi + bl) @conn.sendIQ($vcard.tree(), okcb, failcb) onConnect: (status, error) => when Strophe.Status.CONNECTING console.debug('Strophe is connecting.') when Strophe.Status.AUTHENTICATING console.debug('Strophe is authenticating.') @trigger('authenticating') when Strophe.Status.AUTHFAIL console.debug('Strophe failed to authenticate:', error) when Strophe.Status.ERROR console.debug('Strophe received an error:', error) when Strophe.Status.CONNFAIL console.debug('Strophe failed to connect:', error) when Strophe.Status.DISCONNECTING console.debug('Strophe is disconnecting.') @trigger('disconnecting') when Strophe.Status.DISCONNECTED console.debug('Strophe is disconnected.') when Strophe.Status.CONNECTED console.debug('Strophe is connected.') console.info('My jid:', @conn.jid) when Strophe.Status.ATTACHED console.debug('Strophe is attached.') console.info('My jid:', @conn.jid) when Strophe.Status.REGISTER console.debug('Got registration prompt.') when Strophe.Status.REGISTERED console.debug('Registered!') when Strophe.Status.CONFLICT console.debug('Contact already exists!') when Strophe.Status.NOTACCEPTABLE console.debug('Registration form not properly filled out.') @trigger('notacceptable') when Strophe.Status.REGIFAIL console.debug('The server does not support In-Band Registration.') _(Tram.XMPPInterface.prototype).extend(Backbone.Events)