How to use the ltx.parse function in ltx

To help you get started, we’ve selected a few ltx examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github fabioberger / Mobile-Live-Chat-Support-Server / xmpp-server / modules / message.js View on Github external
client.on('stanza', function(stz) {

            // Parse stanza and check that it is of type message
            var stanza = ltx.parse(stz.toString());
            if (stanza.is('message') && stanza.attrs.type !== 'error') {

                var agentUsername = stanza.attrs.from.split("@")[0]; //isolate username
                var customerId = stanza.attrs.to.split("@")[0]; // isolate customerId

                // If message has body, send it to the customer
                if(stanza.getChild('body') !== undefined) {
                    var content = stanza.getChildText('body');
                    relay.agentMessage(customerId, content);
                } else if(stanza.getChild('composing') !== undefined) {
                    // Notify customer that agent is typing
                    //console.log('Agent is typing');
                    relay.agentStatus(agentUsername, 'composing');
                } else if(stanza.getChild('paused') !== undefined) {
                    // Notify customer that agent has paused
                    //console.log('Agent is paused');
github microsoft / azure-pipelines-tasks / Tasks / Common / packaging-common / nuget / NuGetXmlHelper.ts View on Github external
private static _updateXmlFile(xmlPath: string, updateFn: (xml: any) => any): void {
        let xmlString = fs.readFileSync(xmlPath).toString();

        // strip BOM; xml parser doesn't like it
        if (xmlString.charCodeAt(0) === 0xFEFF) {
            xmlString = xmlString.substr(1);
        }

        let xml = ltx.parse(xmlString);
        xml = updateFn(xml);
        fs.writeFileSync(xmlPath, xml.root().toString());
    }
github xmppjs / radiowave / test / rfc3921-ch07.js View on Github external
it('7.4. Adding a Roster Item', function (done) {
      var id = 'add-roaster-item';
      var el = ltx.parse("");
      var returnType = 'result';

      var stanza = generateRoasterStanza(helper.userJulia.jid, el, id);

      helper.sendMessageWithRomeo(stanza.root()).then(function (stanza) {
        try {
          assert.equal(stanza.is('iq'), true, 'wrong stanza ' + stanza.root().toString());
          assert.equal(stanza.attrs.type, returnType);
          assert.equal(stanza.attrs.id, id);
          done();
        } catch (err) {
          done(err);
        }
      }).catch(function (err) {
        done(err);
      });
github buddycloud / buddycloud-http-api / test / content_item.js View on Github external
tutil.get(options, function(res, body) {
        res.statusCode.should.equal(200);
        var entry = ltx.parse(body);

        entry.is('entry').should.be.true;
        entry.attrs.xmlns.should.equal(atom.ns);
        entry.getChildText('id').should.equal('foo');
        entry.getChild('author').getChildText('name')
            .should.equal('alice@localhost');
        entry.getChildText('content').should.equal('bar');
        entry.getChild('title').should.exist;

        done();
      }).on('error', done);
    });
github buddycloud / buddycloud-http-api / test / content_feed.js View on Github external
tutil.get(options, function(res, body) {
        res.statusCode.should.equal(200);
        var feed = ltx.parse(body);
        var entries = feed.getChildren('entry', atom.ns)
        entries.length.should.equal(2);
        entries[0].getChildText('id').should.equal('1');
        entries[1].getChildText('id').should.equal('2');
        done();
      }).on('error', done);
    });
github microsoft / azure-pipelines-tasks / Tasks / IISWebAppDeploymentOnMachineGroupV0 / Tests / L0.ts View on Github external
it('Runs successfully with XDT Transformation (L1)', (done:MochaDone) => {
        this.timeout(parseInt(process.env.TASK_TEST_TIMEOUT) || 20000);

        let tp = path.join(__dirname, "..", "node_modules","webdeployment-common-v2","Tests","L1XdtTransform.js");
        let tr : ttm.MockTestRunner = new ttm.MockTestRunner(tp);
        tr.run();

        if(tl.osType().match(/^Win/)) {
            var resultFile = ltx.parse(fs.readFileSync(path.join(__dirname, "..", "node_modules","webdeployment-common-v2","Tests", 'L1XdtTransform', 'Web_test.config')));
            var expectFile = ltx.parse(fs.readFileSync(path.join(__dirname, "..", "node_modules","webdeployment-common-v2","Tests", 'L1XdtTransform','Web_Expected.config')));
            assert(ltx.equal(resultFile, expectFile) , 'Should Transform attributes on Web.config');
        }
        else {
            tl.warning('Cannot test XDT Transformation in Non Windows Agent');
        }
        done();
    });
github xmppjs / radiowave / lib / components / Core / modules / Xep0016-privacylist.js View on Github external
PrivacyLists.prototype.handle = function (stanza) {
    
    var error = ltx.parse('');
    this.sendError(stanza, error);

    return true;
};
github pazznetwork / ngx-chat / projects / pazznetwork / ngx-chat / src / lib / services / adapters / xmpp / plugins / message-carbons.plugin.spec.ts View on Github external
to='romeo@montague.example/home'
                     type='chat'>
              
                
                  
                    What man art thou that, thus bescreen'd in night, so stumblest on my counsel?
                    0e3141cd80894871a68e6fe6b1ec56fa
                  
                
              
            `);

    const validSentCarbonMessage = parse(`
            
              
                
                  
                    What man art thou that, thus bescreen'd in night, so stumblest on my counsel?
                    0e3141cd80894871a68e6fe6b1ec56fa
                  
                
              
            `);
github kartikrustagi / nodejs-xmpp-server / modules / Roster.js View on Github external
client.on('stanza', function(stz) {
            var self = this;
            var stanza = ltx.parse(stz.toString());
            var query = null;
            if (stanza.is('iq') && (query = stanza.getChild('query', "jabber:iq:roster"))) {
                if(stanza.attrs.type === "get") {
					logger.info("Roster get request from : "+stanza.attrs.from);
                    stanza.attrs.type = "result";
					var contactJidBStr = null;
					for(contactJidBStr in client.roster.contacts) {
						if(client.roster.contacts.hasOwnProperty(contactJidBStr)) {
							var contact = client.roster.contacts[contactJidBStr];
							query.c("item", {jid: contact.contactJid, name: contact.name, subscription: contact.subscription});
						}
					}
					stanza.attrs.to = stanza.attrs.from;
					client.send(stanza); 
                } else if(stanza.attrs.type === "set") {
                    stanza.attrs.type = "result";
github superfeedr / xmpp-server / modules / offline.js View on Github external
Message.for(client.jid.bare().toString(), function(message) {
                client.send(ltx.parse(message.stanza));
            });
        });