<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type='text/xsl' href='xep.xsl'?>
<xep xmlns="">
<header>
  <title>Pubsub Message Archive Management</title>
  <abstract>This document defines a protocol to query and control a pubsub node's message archive.</abstract>
  
<legal>
<copyright>This XMPP Extension Protocol is copyright © 1999 – 2024 by the <link url="https://xmpp.org/">XMPP Standards Foundation</link> (XSF).</copyright>
<permissions>Permission is hereby granted, free of charge, to any person obtaining a copy of this specification (the "Specification"), to make use of the Specification without restriction, including without limitation the rights to implement the Specification in a software program, deploy the Specification in a network service, and copy, modify, merge, publish, translate, distribute, sublicense, or sell copies of the Specification, and to permit persons to whom the Specification is furnished to do so, subject to the condition that the foregoing copyright notice and this permission notice shall be included in all copies or substantial portions of the Specification. Unless separate permission is granted, modified works that are redistributed shall not contain misleading information regarding the authors, title, number, or publisher of the Specification, and shall not claim endorsement of the modified works by the authors, any organization or project to which the authors belong, or the XMPP Standards Foundation.</permissions>
<warranty>## NOTE WELL: This Specification is provided on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. ##</warranty>
<liability>In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall the XMPP Standards Foundation or any author of this Specification be liable for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising from, out of, or in connection with the Specification or the implementation, deployment, or other use of the Specification (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if the XMPP Standards Foundation or such author has been advised of the possibility of such damages.</liability>
<conformance>This XMPP Extension Protocol has been contributed in full conformance with the XSF's Intellectual Property Rights Policy (a copy of which can be found at &lt;<link url="https://xmpp.org/about/xsf/ipr-policy">https://xmpp.org/about/xsf/ipr-policy</link>&gt; or obtained by writing to XMPP Standards Foundation, P.O. Box 787, Parker, CO 80134 USA).</conformance>
</legal>
  <number>0442</number>
  <status>Experimental</status>
  <type>Standards Track</type>
  <sig>Standards</sig>
  <approver>Council</approver>
  <dependencies>
    <spec>XMPP Core</spec>
    <spec>XEP-0030</spec>
    <spec>XEP-0059</spec>
    <spec>XEP-0060</spec>
    <spec>XEP-0297</spec>
    <spec>XEP-0313</spec>
  </dependencies>
  <supersedes/>
  <supersededby/>
  <shortname>pubsub-mam</shortname>
  
  <author>
    <firstname>Matthew</firstname>
    <surname>Wild</surname>
    <email>mwild1@gmail.com</email>
    <jid>me@matthewwild.co.uk</jid>
  </author>

  
  <author>
    <firstname>Kevin</firstname>
    <surname>Smith</surname>
    <email>kevin@kismith.co.uk</email>
    <jid>kevin@doomsong.co.uk</jid>
  </author>

  <revision>
    <version>0.2.0</version>
    <date>2020-08-25</date>
    <initials>XEP Editor (jsc)</initials>
    <remark>Accepted by vote of Council on 2020-08-19.</remark>
  </revision>
  <revision>
    <version>0.1.0</version>
    <date>2020-03-30</date>
    <initials>mw</initials>
    <remark>
      <p>Split off from XEP-0313 v0.6.3 to ease advancement of that XEP and allow further clarification and expansion of pubsub use cases.</p>
    </remark>
  </revision>
</header>

<section1 topic="Introduction" anchor="intro">
  <p>This document specifies how to use <span class="ref"><link url="https://xmpp.org/extensions/xep-0313.html">Message Archive Management (XEP-0313)</link></span> <note>XEP-0313: Message Archive Management &lt;<link url="https://xmpp.org/extensions/xep-0313.html">https://xmpp.org/extensions/xep-0313.html</link>&gt;.</note> in combination with <span class="ref"><link url="https://xmpp.org/extensions/xep-0060.html">Publish-Subscribe (XEP-0060)</link></span> <note>XEP-0060: Publish-Subscribe &lt;<link url="https://xmpp.org/extensions/xep-0060.html">https://xmpp.org/extensions/xep-0060.html</link>&gt;.</note> to host and query archives on pubsub nodes.</p>
</section1>

<section1 topic="Querying a pubsub archive" anchor="querying">
  <p>When querying a pubsub node's archive, the 'node' attribute is added to the &lt;query&gt; element.</p>
  <example caption="A user queries a pubsub node's archive for messages"><![CDATA[
<iq to='pubsub.shakespeare.lit' type='set' id='juliet1'>
  <query xmlns='urn:xmpp:mam:2' queryid='f28' node='fdp/submitted/capulet.lit/sonnets'/>
</iq>]]></example>

  <example caption="Server returns pubsub messages"><![CDATA[
<message id='iasd208' to='juliet@capulet.lit/chamber'>
  <result xmlns='urn:xmpp:mam:2' queryid='g28' id='28482-20987-73623'>
    <forwarded xmlns='urn:xmpp:forward:0'>
      <delay xmlns='urn:xmpp:delay' stamp='2010-07-10T23:08:25Z'/>
      <message xmlns="jabber:client">
		  <event xmlns='http://jabber.org/protocol/pubsub#event'>
		    <items node='princely_musings'>
		      <item id='ae890ac52d0df67ed7cfdf51b644e901'>
		        <entry xmlns='http://www.w3.org/2005/Atom'>
		          <title>Soliloquy</title>
		          <summary>
					To be, or not to be: that is the question:
					Whether 'tis nobler in the mind to suffer
					The slings and arrows of outrageous fortune,
					Or to take arms against a sea of troubles,
					And by opposing end them?
		          </summary>
		          <link rel='alternate' type='text/html'
		                href='http://denmark.lit/2003/12/13/atom03'/>
		          <id>tag:denmark.lit,2003:entry-32397</id>
		          <published>2003-12-13T18:30:02Z</published>
		          <updated>2003-12-13T18:30:02Z</updated>
		        </entry>
		      </item>
		    </items>
		  </event>
		</message>
    </forwarded>
  </result>
</message>]]></example>
</section1>

<section1 topic="Business Rules" anchor="business-rules">
  <p>A PubSub service offering MAM SHOULD store each of the items published to each node. When responding to MAM requests it MUST construct the message stanza within the &lt;forwarded&gt; element in the same manner as the notifications sent to subscribers for the item, except that specifying the 'from' 'to' and 'id' attributes are OPTIONAL. Pubsub items must be returned one per message stanza (i.e. there MUST NOT be multiple &lt;item&gt; elements within the &lt;items&gt; element).</p>
</section1>
</xep>
