Anton Shestakov <av6@dwimlabs.net>, Sat, 16 Sep 2017 21:54:49 +0800
pipelines: retain node_modules between runs
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 iq = $iq(type: 'set').c('query', xmlns: Strophe.NS.REGISTER).c('remove') 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.') @trigger('status', status) generateVerificationString: -> ids = (i for i in @conn.disco._identities) if a.category > b.category if a.category < b.category features = (f for f in @conn.disco._features) ver += "#{ id.category }/#{ id.type }/#{ id.lang ? '' }/#{ id.name }<" ver = @generateVerificationString() pres = $pres().c('c', xmlns: Strophe.NS.CAPS, hash: 'sha-1', node: Tram.info.url, ver: ver).up() pres.c('priority').t(attrs.priority).up() pres.c('show').t(attrs.show).up() pres.c('status').t(attrs.status).up() _(Tram.XMPPInterface.prototype).extend(Backbone.Events)