<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE xep SYSTEM 'xep.dtd' [
  <!ENTITY % ents SYSTEM 'xep.ent'>
%ents;
]>
<?xml-stylesheet type='text/xsl' href='xep.xsl'?>
<xep>
<header>
  <title>PubSub Since</title>
  <abstract>This specification defines a publish-subscribe feature that enables a subscriber to automatically receive pubsub and PEP notifications since its last logout time.</abstract>
  &LEGALNOTICE;
  <number>xxxx</number>
  <status>ProtoXEP</status>
  <type>Standards Track</type>
  <sig>Standards</sig>
  <approver>Council</approver>
  <dependencies>
    <spec>XMPP Core</spec>
  </dependencies>
  <supersedes/>
  <supersededby/>
  <shortname>NOT_YET_ASSIGNED</shortname>
  &hildjj;
  &stpeter;
  <revision>
    <version>0.0.2</version>
    <date>2012-02-29</date>
    <initials>psa</initials>
    <remark><p>Addressed some feedback from the XMPP Council.</p></remark>
  </revision>
  <revision>
    <version>0.0.1</version>
    <date>2012-02-27</date>
    <initials>psa</initials>
    <remark><p>First draft.</p></remark>
  </revision>
</header>

<section1 topic='Introduction' anchor='introduction'>
  <p>Many &xep0060; and &xep0163; services send notifications based on information about the presence of subscribers. This implies that subscribers might not receive notifications that were generated when they are offline at a particular resource. While &xep0256; defines a way for clients to include their last logout time, this specification closes the loop by defining how pubsub and PEP services can use the last logout information to send interim notifications to subscribers.</p>
</section1>

<section1 topic='How It Works' anchor='feature'>
  <p>As described in XEP-0256, a subscriber (i.e., a subscriber's specific full JID) can indicate its last logout time when sending initial presence.</p>
  <example caption='Last Indication in Initial Presence'><![CDATA[
<presence from='juliet@capulet.com/balcony'>
  <query xmlns='jabber:iq:last' seconds='86511'/>
</presence>
  ]]></example>
  <p>Upon receiving such an indication, a pubsub or PEP service that supports presence-based notifications and the "pubsub-since" feature defined herein would behave as follows:</p>
  <ol>
    <li>The service MUST send to the subscriber's full JID all of the notifications stored in the relevant node's history that were generated since the last logout time.</li>
    <li>The service MAY adjust its definition of "interim notification" to account for reasonable clock skew (e.g., including notifications up to five minutes older than the subscriber's last logout time).</li>
    <li>The service SHOULD include only the final version of each pubsub notification (e.g., in case of items that were updated during the period when the subscriber was offline).</li>
    <li>The service SHOULD NOT include items that were removed from the node.</li>
    <li>The service MAY limit the number of notifications that it sends to avoid resource contraints.</li>
    <li>The service MAY include &xep0059; data so that the subscriber can page through the set of interim notifications, as described in Section 6.5.3 of XEP-0060.</li>
  </ol>
  <p>If the pubsub service receives subsequent available presence from that full JID (even a presence update that includes the last availability indication), it MUST behave according to the rules in XEP-0060 or XEP-0163 (typically this means it would do nothing, since presence-based notifications toggle notifications on when receiving initial presence and toggling notifications off when receiving unavailable presence).</p>
</section1>

<section1 topic='Determining Support' anchor='disco'>
  <p>If a pubsub or PEP service supports the protocol defined herein, it MUST report that by including a &xep0030; feature of "http://jabber.org/protocol/pubsub#since" in response to disco#info requests:</p>
  <example caption="Service discovery information request"><![CDATA[
<iq from='bard@shakespeare.lit/globe'
    id='sb2t1d49'
    to='pubsub.shakespeare.lit'
    type='get'>
  <query xmlns='http://jabber.org/protocol/disco#info'/>
</iq>
  ]]></example>
  <example caption="Service discovery information response"><![CDATA[
<iq from='pubsub.shakespeare.lit'
    id='sb2t1d49'
    to='bard@shakespeare.lit/globe'
    type='result'>
  <query xmlns='http://jabber.org/protocol/disco#info'>
    <identity category='pubsub' type='service'/>
    <feature var='http://jabber.org/protocol/pubsub'/>
    <feature var='http://jabber.org/protocol/pubsub#auto-subscribe'/>
    <feature var='http://jabber.org/protocol/pubsub#presence-notifications'/>
    <feature var='http://jabber.org/protocol/pubsub#since'/>
  </query>
</iq>
  ]]></example>
</section1>

<section1 topic='Security Considerations' anchor='security'>
  <p>The number or cumulative size of the notifications published since the subscriber's last login time might be large, causing a significant load on the service. Implementations might consider truncating the interim notifications to avoid a denial of service.</p>
</section1>

<section1 topic='IANA Considerations' anchor='iana'>
  <p>This document requires no interaction with &IANA;.</p>
</section1>

<section1 topic='Implementation Notes' anchor='impl'>
  <p>The Last Activity extension (XEP-0012) notates time in seconds before the moment of stanza generation. Although some commenters have suggested that it would be easier to implement last activity notations in terms of UTC timestamps, clients can mitigate some implementation problems by storing the last activity time in UTC instead of local time (in case the device is moved across time zones) and by using standard technologies for clock synchronization such as &rfc1305; and &xep0202;. The five-minute grace period is merely an implementation suggestion; implementation and deployment experience might indicate that other values are more prudent.</p>
</section1>

<section1 topic='XMPP Registrar Considerations' anchor='registrar'>
  <section2 topic='Service Discovery Features' anchor='registrar-features'>
    <p>Support for the feature defined in this document is advertised by the ""http://jabber.org/protocol/pubsub#since"" Service Discovery feature.</p>
    <p>The XMPP Registrar shall add this feature to its registry at &DISCOFEATURES;. The registration is as follows.</p>
    <code caption='Registry Submission'><![CDATA[
<var>
  <name>http://jabber.org/protocol/pubsub#since</name>
  <desc>
    The pubsub or PEP service sends interim notifications upon receiving
    initial presence containing the subscriber's last logout time.
  </desc>
  <doc>XEP-xxxx</doc>
</var>
    ]]></code>
  </section2>
</section1>

</xep>
