Giter Club home page Giter Club logo

strophejs-plugin-mam's Introduction

strophe.mam.js

Plugin for strophe.js to provide Message Archiving Management (XEP-0313).

This plugin requires the Strophe.RSM plugin to be loaded as well.

Install

npm install strophejs-plugin-mam

Usage

Querying an archive

connection.mam.query(where, parameters)

where is the JID hosting the archive. In most cases you will want to set this to your own bare JID in order query your personal archive, but it could also be a MUC room, an archiving component or a bot.

parameters is an object containing parameters for the query. This can have properties from two and a half categories:

Handlers: onMessage which gets called for each message received, and onComplete which is called when the query is completed.

Filtering: Half of this is the parameters defined by MAM; with, start or end, which allow you to filter the results on who the conversation was with, and the time range.

Additionally, parameters from Result Set Management can be supplied. You would probably be most interested in the after and before properties, which allow you to do pagination of the result set, and the max property, which allow you to limit the number of items in each page. Note: Better RSM integration is on the TODO, you currently have to pick out the last or first items yourself and pass those as after or before respectively.

Example

To query, for example, your personal archive for conversations with [email protected] you could do:

connection.mam.query("[email protected]", {
  "with": "[email protected]",
  onMessage: function(message) {
			console.log("Message from ", $(message).find("forwarded message").attr("from"),
				": ", $(message).find("forwarded message body").text());
			return true;
  },
  onComplete: function(response) {
			console.log("Got all the messages");
  }
	});

strophejs-plugin-mam's People

Contributors

debchy avatar destreyf avatar jcbrand avatar mremond avatar omichelsen avatar quezx avatar siadat avatar sualko avatar tamoyal avatar zash avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.