XMPP::MessageArchives
MessageArchives is a high-level client for XEP-0313 - Message Archive Management.
MAM lets a client query the server for its archived messages, optionally filtered by chat partner and time range and paged with RSM. The IQ returns a MAMFin; each archived message is then streamed as a normal Message stanza carrying a Stanza::MAMResult payload, which is handled like any other message:
archives = XMPP::MessageArchives.new(client) return unless archives.supported? fin = archives.query(with: "juliet@capulet.lit", limit: 10) fin.try(&.complete) # true when all results were streamed
client.on("message") do |s, m| if result = m.as(XMPP::Stanza::Message).get(XMPP::Stanza::MAMResult) archived = result.as(XMPP::Stanza::MAMResult).forwarded.try(&.stanza) end end
See: https://xmpp.org/extensions/xep-0313.html
Constants
Disco feature advertised by servers that support MAM.
Constructors
Instance methods
query requests archived messages and returns the MAMFin IQ payload (nil on error or timeout). The archived messages themselves arrive as Message stanzas carrying Stanza::MAMResult and are delivered to the client's normal message handling. Filters: with restricts to a chat partner; since/until bound the time range; limit and after page the result set.
supported? queries the server for MAM support and returns true when the urn:xmpp:mam:2 feature is advertised on the given JID (defaults to the user's bare JID).