1.1pre1, mainly auto-create and publish-and-configure

git-svn-id: file:///home/ksmith/gitmigration/svn/xmpp/trunk@725 4b5297f7-1745-476d-ba37-a9c6900126ab
This commit is contained in:
Peter Saint-Andre 2007-04-04 01:59:16 +00:00
parent 8203d9d11e
commit d561e3c05a
1 changed files with 441 additions and 398 deletions

View File

@ -26,6 +26,12 @@
<shortname>pep</shortname>
&stpeter;
&ksmith;
<revision>
<version>1.1pre1</version>
<date>in progress, last updated 2007-04-03</date>
<initials>psa</initials>
<remark><p>Defined atomic publish+configure action for use on first publish; added friendly but non-normative How It Works section to introduction; tightened up definition of normative sections; explicitly defined auto-create and publish-and-configure features.</p></remark>
</revision>
<revision>
<version>1.0</version>
<date>2006-09-20</date>
@ -137,19 +143,189 @@
</header>
<section1 topic='Introduction' anchor='intro'>
<p>The XMPP &xep0060; extension ("pubsub") can be used to broadcast state change events associated with a Jabber/XMPP account or user, such as those described in &xep0080;, &xep0107;, &xep0108;, and &xep0118;. <note>Currently, many "extended presence" formats are sent using the &PRESENCE; stanza type; however, this overloads presence, results in unnecessary presence traffic, and does not provide fine-grained control over access. The use of publish-subscribe rather than presence is therefore preferable.</note> However, the full, generic pubsub protocol is often thought of as complicated and therefore has not been widely implemented. To make publish-subscribe functionality more accessible (especially to instant messaging and presence applications that conform to &xmppim;), this document defines simplified protocol semantics that can be followed by instant messaging client and server developers, hopefully resulting in the deployment of personal eventing services across the Jabber/XMPP network.</p>
<p><em>Note: This document does not show error flows related to the various publish-subscribe use cases referenced herein, since they are exhaustively defined in <cite>XEP-0060</cite>. The reader is referred to <cite>XEP-0060</cite> for all relevant protocol details related to the XMPP publish-subscribe extension.</em></p>
<section2 topic='Motivation' anchor='motivation'>
<p>Personal eventing provides a way for a Jabber/XMPP user to send updates or "events" to other users, who are typically contacts in the user's roster. An event can be anything that a user wants to make known to other people, such as those described in &xep0080;, &xep0107;, &xep0108;, and &xep0118;. While the XMPP &xep0060; extension ("pubsub") can be used to broadcast such events associated, the full pubsub protocol is often thought of as complicated and therefore has not been widely implemented.
<note>Instead, many "extended presence" formats are currently sent using the &PRESENCE; stanza type; unfortunately, this overloads presence, results in unnecessary presence traffic, and does not provide fine-grained control over access. The use of publish-subscribe rather than presence is therefore preferable.</note>
To make publish-subscribe functionality more accessible (especially to instant messaging and presence applications that conform to &xmppim;), this document defines a simplified subset of pubsub that can be followed by instant messaging client and server developers to more easily deploy personal eventing services across the Jabber/XMPP network. We label this subset "Personal Eventing via Pubsub" or PEP.
<note>This document does not show error flows related to the various publish-subscribe use cases referenced herein, since they are exhaustively defined in <cite>XEP-0060</cite>. The reader is referred to <cite>XEP-0060</cite> for all relevant protocol details related to the XMPP publish-subscribe extension.</note></p>
</section2>
<section2 topic='How It Works' anchor='howitworks'>
<p>This section provides a friendly, non-normative introduction to the workings of personal eventing via pubsub (PEP).</p>
<p>There are two sides to personal eventing: what the user does to generate events and what the contact does to receive events. As shown in the following examples, both are simplified in PEP as compared to generic pubsub.</p>
<p>Imagine that you are a Shakespearean character named Juliet and that you want to generate the following kinds of events that may be of interest to other people:</p>
<ol start='1'>
<li>Information about what music you're listening to, which anyone may see even if they are not allowed to know your online/offline presence (i.e., a pubsub access model of "presence")</li>
<li>Information about your geographical location, which only contacts in your "Friends" roster group may see (i.e., a pubsub access model of "roster" with a group of "Friends")</li>
</ol>
<p>We assume that there are three other users who have the following relationship to you:</p>
<ol start='1'>
<li>benvolio@montague.net, who has no subscription to your presence</li>
<li>nurse@capulet.com, who has a bidirectional subscription to your presence and who is in your "Servants" roster group</li>
<li>romeo@montague.net, who has a bidirectional subscription to your presence and who is in your "Friends" roster group</li>
</ol>
<p>We also assume that your server (montague.net) supports PEP and that your client discovered that support when you logged in.</p>
<p>Now you start playing a song on your music playing software. Your client captures that "event" and publishes it to your server:</p>
<example caption='Publishing an event'><![CDATA[
<iq from='juliet@capulet.com/balcony' type='set' id='pub1'>
<pubsub xmlns='http://jabber.org/protocol/pubsub'>
<publish node='http://jabber.org/protocol/tune'>
<item>
<tune xmlns='http://jabber.org/protocol/tune'>
<artist>Gerald Finzi</artist>
<title>Introduction (Allegro vigoroso)</title>
<source>Music for "Love's Labors Lost" (Suite for small orchestra)</source>
<track>1</track>
<length>255</length>
</tune>
</item>
</publish>
<configure>
<x xmlns='jabber:x:data' type='submit'>
<field var='FORM_TYPE' type='hidden'>
<value>http://jabber.org/protocol/pubsub#node_config</value>
</field>
<field var='pubsub#access_model'>
<value>presence</value>
</field>
</x>
</configure>
</pubsub>
</iq>
]]></example>
<p>Note the following about your publish request:</p>
<ol start='1'>
<li>It is sent with no 'to' address (see <link url='#approach-everyjid'>Every Account a Pubsub Service</link>).</li>
<li>It specifies a node of "http://jabber.org/protocol/tune" (see <link url='#approach-onenode'>One Node per Namespace</link>).</li>
<li>It includes the desired node configuration, which here is a presence access model (see <link url='#approach-fire'>Fire and Forget</link>).</li>
</ol>
<p>If all goes well (see <link url='#publish'>Publishing Events</link>), everyone who is interested in what you are listening to will receive notification of the event:</p>
<example caption='Interested parties receive event notifications'><![CDATA[
<message from='juliet@capulet.com'
to='romeo@montague.net/orchard'
type='headline'
id='tunefoo1'>
<event xmlns='http://jabber.org/protocol/pubsub#event'>
<items node='http://jabber.org/protocol/tune'>
<item>
<tune xmlns='http://jabber.org/protocol/tune'>
<artist>Gerald Finzi</artist>
<title>Introduction (Allegro vigoroso)</title>
<source>Music for "Love's Labors Lost" (Suite for small orchestra)</source>
<track>1</track>
<length>255</length>
</tune>
</item>
</items>
</event>
</message>
<message from='juliet@capulet.com'
to='nurse@capulet.com/chamber'
type='headline'
id='tunefoo2'>
<event xmlns='http://jabber.org/protocol/pubsub#event'>
<items node='http://jabber.org/protocol/tune'>
<item>
<tune xmlns='http://jabber.org/protocol/tune'>
<artist>Gerald Finzi</artist>
<title>Introduction (Allegro vigoroso)</title>
<source>Music for "Love's Labors Lost" (Suite for small orchestra)</source>
<track>1</track>
<length>255</length>
</tune>
</item>
</items>
</event>
</message>
]]></example>
<p>But how do Romeo and the Nurse tell your server that they are interested in knowing what you're listening to? In generic pubsub they need to explicitly subscribe to your "http://jabber.org/protocol/tune" node. <note>That is still necessary for open access model nodes in PEP if another user does not have a subscription to your presence, such as benvolio@montague.net in our scenario.</note> In PEP, they only need to advertise that they are interested by including some special flags (see <link url='#approach-filter'>Filtered Notifications</link>) in the &xep0115; information they include in their presence broadcasts (see <link url='#approach-presence'>Use Presence</link>).</p>
<example caption='Romeo sends presence with caps'><![CDATA[
<presence from='romeo@montague.net/orchard'>
<c xmlns='http://jabber.org/protocol/caps'
node='http://www.chatopus.com/ec'
ver='2.1'
ext='sendmeloc sendmetunes'/>
</presence>
]]></example>
<p>Your server knows to send tune information to Romeo not directly because his client advertises an 'ext' value of "sendmetunes" (the 'ext' values have no semantic meaning in <cite>XEP-0115</cite>) but because the disco#info response from the "http://www.chatopus.com/ec#sendmetunes" node advertises a feature of "http://jabber.org/protocol/tune+notify", where the "+notify" suffix indicates interest in the protocol that precedes the suffix:</p>
<example caption='Disco#info result from extension'><![CDATA[
<iq from='romeo@montague.net/orchard'
to='juliet@capulet.com'
type='result'
id='disco123'>
<query xmlns='http://jabber.org/protocol/disco#info'
node='http://www.chatopus.com/ec#sendmetunes'/>
<feature var='http://jabber.org/protocol/tune'/>
<feature var='http://jabber.org/protocol/tune+notify'/>
</query>
</iq>
]]></example>
<p>Naturally your server doesn't need to send out a disco#info request every time, since it will quickly create a large cache of such extensions!</p>
<p>So that's the general idea. We'll demonstrate it again with an example of geolocation...</p>
<p>First your client generates a geolocation event:</p>
<example caption='Publishing another event'><![CDATA[
<iq from='juliet@capulet.com/balcony' type='set' id='pub2'>
<pubsub xmlns='http://jabber.org/protocol/pubsub'>
<publish node='http://jabber.org/protocol/geoloc'>
<item>
<geoloc xmlns='http://jabber.org/protocol/geoloc' xml:lang='en'>
<country>Italy</country>
<lat>45.44</lat>
<locality>Venice</locality>
<lon>12.33</lon>
</geoloc>
</item>
</publish>
<configure>
<x xmlns='jabber:x:data' type='submit'>
<field var='FORM_TYPE' type='hidden'>
<value>http://jabber.org/protocol/pubsub#node_config</value>
</field>
<field var='pubsub#access_model'>
<value>roster</value>
</field>
<field var='pubsub#roster_groups_allowed'>
<value>Friends</value>
</field>
</x>
</configure>
</pubsub>
</iq>
]]></example>
<p>Then your server sends event notifications, this time addressing the event only to Romeo, since the Nurse is not in your Friends roster group:</p>
<example caption='Interested parties receive event notifications'><![CDATA[
<message from='juliet@capulet.com'
to='romeo@montague.net/orchard'
type='headline'
id='locfoo1'>
<event xmlns='http://jabber.org/protocol/pubsub#event'>
<items node='http://jabber.org/protocol/geoloc'>
<item>
<geoloc xmlns='http://jabber.org/protocol/geoloc' xml:lang='en'>
<country>Italy</country>
<lat>45.44</lat>
<locality>Venice</locality>
<lon>12.33</lon>
</geoloc>
</item>
</items>
</event>
</message>
]]></example>
<p>And your server knows to send the geolocation notification to Romeo because (1) he is in your Friends group and (2) his client advertised interest in "http://jabber.org/protocol/geolocation" events.</p>
</section2>
</section1>
<section1 topic='Concepts and Approach' anchor='approach'>
<p>Personal eventing via pubsub ("PEP") is based on six principles:</p>
<p>Personal eventing via pubsub ("PEP") is based on the following principles:</p>
<ol start='1'>
<li>Every account a pubsub service.</li>
<li>One publisher per node.</li>
<li>One node per namespace.</li>
<li>Use presence.</li>
<li>Notifications are filtered based on expressed interests.</li>
<li>Filter notifications based on expressed interest.</li>
<li>Smart defaults.</li>
<li>Fire and forget.</li>
</ol>
<p>These principles are described more fully below.</p>
<section2 topic='Every Account a Pubsub Service' anchor='approach-everyjid'>
@ -177,259 +353,101 @@
<section2 topic='Smart Defaults' anchor='approach-defaults'>
<p>Most pubsub configuration options and metadata are not needed for personal eventing. Instead, PEP services offer smart defaults to simplify node creation and management.</p>
</section2>
<section2 topic='Fire and Forget' anchor='approach-fire'>
<p>A client should be able to publish an item without having to worry about whether the node exists; if the node does not exist, the server simply creates the node automatically and applies the specified configuration.</p>
</section2>
</section1>
<section1 topic='Scenario' anchor='scenario'>
<p>This document illustrates PEP through a series of examples that use the following scenario:</p>
<ol start='1'>
<li>
<p>An owner-publisher juliet@capulet.com who publishes the following information:</p>
<ol start='1'>
<li>Tune information that anyone may see (i.e., an access model of "open")</li>
<li>Activity information that only subscribers to her presence may see (i.e., an access model of "presence")</li>
<li>Geolocation information that only contacts in her "Friends" group may see (i.e., an access model of "roster" with a group of "Friends")</li>
<li>Bookmark information that only the account owner may see (i.e., an access model of "whitelist")</li>
</ol>
<p>Note: A PEP node with an access model of "whitelist" and no entities on the whitelist effectively results in a node that enables private data storage; for details, see the <link url='#privatedata'>Private Data Storage</link> section of this document.</p>
</li>
<li>
<p>Three users who have the following relationship to Juliet:</p>
<ol start='1'>
<li>benvolio@montague.net, who has no subscription to Juliet's presence</li>
<li>nurse@capulet.com, who has a bidirectional subscription to Juliet's presence and who is in the "Servants" group in Juliet's roster</li>
<li>romeo@montague.net, who has a bidirectional subscription to Juliet's presence and who is in the "Friends" group in Juliet's roster</li>
</ol>
</li>
</ol>
<p>The examples shown in the following sections walk through the protocol flows for node creation, discovery, publishing, and subscribing.</p>
</section1>
<section1 topic='Account Owner Service Discovery' anchor='owner-disco'>
<p>Naturally, before an account owner attempts to complete any PEP use cases, its client SHOULD determine whether the account owner's server supports PEP; to do so, it MUST send a &xep0030; information request to the server:</p>
<example caption='Account owner queries server regarding protocol support'><![CDATA[
<iq from='juliet@capulet.com/balcony'
to='capulet.com'
id='disco1'
type='get'>
<query xmlns='http://jabber.org/protocol/disco#info'/>
</iq>
]]></example>
<p>If a server supports PEP, it MUST return an identity of "pubsub/pep" (as well as a list of the namespaces and other features it supports, including all supported <cite>XEP-0060</cite> features):</p>
<example caption='Server communicates protocol support'><![CDATA[
<iq from='capulet.com'
to='juliet@capulet.com/balcony'
id='disco1'
type='result'>
<query xmlns='http://jabber.org/protocol/disco#info'>
<identity category='server' type='im'/>
<identity category='pubsub' type='pep'/>
<feature var='http://jabber.org/protocol/pubsub#config-node'/>
<feature var='http://jabber.org/protocol/pubsub#create-and-configure'/>
<feature var='http://jabber.org/protocol/pubsub#create-nodes'/>
<feature var='http://jabber.org/protocol/pubsub#persistent-items'/>
<feature var='http://jabber.org/protocol/pubsub#publish'/>
<feature var='http://jabber.org/protocol/pubsub#retrieve-items'/>
<feature var='http://jabber.org/protocol/pubsub#subscribe'/>
...
</query>
</iq>
]]></example>
</section1>
<section1 topic='Account Owner Node Creation' anchor='owner-create'>
<p>When an account owner attempts to publish an item to a PEP node and that node does not already exist, the PEP service MUST automatically create the node with default configuration. <note>This similar to the room creation process in <cite>XEP-0045: Multi-User Chat</cite>.</note> However, if the account owner wishes to create a node with a configuration other than the default (e.g., a node with an access model of "open", "roster", or "whitelist"), the account owner MUST follow the node creation protocol specified in <cite>XEP-0060</cite>.</p>
<p>For example, Juliet would send the following stanzas in order to create the nodes mentioned above:</p>
<example caption='Account owner creates open node for tune data'><![CDATA[
<iq from='juliet@capulet.com/balcony' type='set' id='create-open'>
<section1 topic='Publishing Events' anchor='publish'>
<p>An account owner publishes an item to a node by following the protocol specified in <cite>XEP-0060</cite>:</p>
<example caption='Account owner publishes item'><![CDATA[
<iq from='juliet@capulet.com/balcony' type='set' id='pub1'>
<pubsub xmlns='http://jabber.org/protocol/pubsub'>
<create node='http://jabber.org/protocol/tune'/>
<configure>
<x xmlns='jabber:x:data' type='submit'>
<field var='FORM_TYPE' type='hidden'>
<value>http://jabber.org/protocol/pubsub#node_config</value>
</field>
<field var='pubsub#access_model'>
<value>open</value>
</field>
</x>
</configure>
</pubsub>
</iq>
<iq to='juliet@capulet.com/balcony' type='result' id='create-open'/>
]]></example>
<example caption='Account owner publishes initial item to presence node for activity data'><![CDATA[
<iq from='juliet@capulet.com/balcony' type='set' id='create-presence'>
<pubsub xmlns='http://jabber.org/protocol/pubsub'>
<publish node='http://jabber.org/protocol/activity'/>
<publish node='http://jabber.org/protocol/tune'>
<item>
<activity xmlns='http://jabber.org/protocol/activity'>
<relaxing>
<partying/>
</relaxing>
<text xml:lang='en'>My nurse&apos;s birthday!</text>
</activity>
<tune xmlns='http://jabber.org/protocol/tune'>
<artist>Gerald Finzi</artist>
<title>Introduction (Allegro vigoroso)</title>
<source>Music for "Love's Labors Lost" (Suite for small orchestra)</source>
<track>1</track>
<length>255</length>
</tune>
</item>
</publish>
</pubsub>
</iq>
<iq to='juliet@capulet.com/balcony' type='result' id='create-presence'/>
]]></example>
<example caption='Account owner creates roster access node for geolocation data'><![CDATA[
<iq from='juliet@capulet.com/balcony' type='set' id='create-roster'>
<p>If the node does not already exist, the PEP service MUST create the node (see <link url='approach-fire'>fire and forget</link>). This "auto-create" feature MUST be supported by a PEP service, but support for the feature is OPTIONAL on the part of a generic pubsub service. (Naturally, the account owner's client MAY follow the node creation use case specified in <cite>XEP-0060</cite> before attempting to publish an item.)</p>
<p>Because PEP nodes may be automatically created, a client MAY specify the desired node configuration along with the publish request:</p>
<example caption='Publishing an event'><![CDATA[
<iq from='juliet@capulet.com/balcony' type='set' id='pub1'>
<pubsub xmlns='http://jabber.org/protocol/pubsub'>
<create node='http://jabber.org/protocol/geoloc'/>
<publish node='http://jabber.org/protocol/tune'>
<item>
<tune xmlns='http://jabber.org/protocol/tune'>
<artist>Gerald Finzi</artist>
<title>Introduction (Allegro vigoroso)</title>
<source>Music for "Love's Labors Lost" (Suite for small orchestra)</source>
<track>1</track>
<length>255</length>
</tune>
</item>
</publish>
<configure>
<x xmlns='jabber:x:data' type='submit'>
<field var='FORM_TYPE' type='hidden'>
<value>http://jabber.org/protocol/pubsub#node_config</value>
</field>
<field var='pubsub#access_model'>
<option><value>roster</value></option>
</field>
<field var='pubsub#roster_groups_allowed'>
<option><value>Friends</value></option>
<value>presence</value>
</field>
</x>
</configure>
</pubsub>
</iq>
<iq to='juliet@capulet.com/balcony' type='result' id='create-roster'/>
]]></example>
<example caption='Account owner creates whitelist node for bookmark data'><![CDATA[
<iq from='juliet@capulet.com/balcony' type='set' id='create-whitelist'>
<pubsub xmlns='http://jabber.org/protocol/pubsub'>
<create node='storage:bookmarks'/>
<configure>
<x xmlns='jabber:x:data' type='submit'>
<field var='FORM_TYPE' type='hidden'>
<value>http://jabber.org/protocol/pubsub#node_config</value>
</field>
<field var='pubsub#access_model'>
<option><value>whitelist</value></option>
</field>
</x>
</configure>
</pubsub>
</iq>
<iq to='juliet@capulet.com/balcony' type='result' id='create-whitelist'/>
]]></example>
<p>The PEP service MUST process such a request in accordance with the rules shown in the table below. This "publish-and-configure" feature MUST be supported by a PEP service, but support for the feature is OPTIONAL on the part of a generic pubsub service.</p>
<table caption='Processing of Publish+Configure Requests'>
<tr>
<th>Case</th>
<th>Result</th>
</tr>
<tr>
<td>The node does not exist and the publish request does not include a &lt;configure/&gt; element.</td>
<td>The node is automatically created with default configuration (which for PEP nodes MUST be the presence access model) and the item is published.</td>
</tr>
<tr>
<td>The node does not exist and the publish request includes a &lt;configure/&gt; element.</td>
<td>The node is automatically created with the specified configuration and the item is published.</td>
</tr>
<tr>
<td>The node exists and the publish request does not include a &lt;configure/&gt; element.</td>
<td>The item is published and the node configuration is not modified.</td>
</tr>
<tr>
<td>The node exists and the publish request includes a &lt;configure/&gt; element.</td>
<td>If the specified configuration matches the existing node configuration, the item is published and the node configuration is not modified. If the specified configuration does not match the existing node configuration, the server returns a &conflict; error to the account owner (with an application-specific error of &lt;config-does-not-match/&gt;), the item is not published, and the node configuration is not modified.</td>
</tr>
</table>
<p>If the publication logic dictates that event notifications shall be sent, the account owner's server generates notifications and sends them to all appropriate entities as described in the <link url='#notify'>Receiving Event Notifications</link> section of this document, as well as to any of the account owner's available resources.</p>
</section1>
<section1 topic='Contact Service Discovery' anchor='contact-disco'>
<p>A contact MAY send service discovery requests to the account owner's bare JID (&BAREJID;). Although this is not necessary in order to subscribe to the account owner's personal eventing data (as explained in the following section), it is shown here to further illustrate the role of access models.</p>
<p>First, benvolio@montague.net sends a disco#info request to juliet@capulet.com:</p>
<example caption='Unaffiliated entity queries account owner regarding identity'><![CDATA[
<iq from='benvolio@montague.net/home'
to='juliet@capulet.com'
id='disco2'
type='get'>
<query xmlns='http://jabber.org/protocol/disco#info'/>
</iq>
]]></example>
<p>If Juliet's server supports PEP (thereby making juliet@capulet.com a virtual pubsub service), it MUST return an identity of "pubsub/pep":</p>
<example caption='Server communicates protocol support'><![CDATA[
<iq from='juliet@capulet.com'
to='benvolio@montague.net/home'
id='disco2'
type='result'>
<query xmlns='http://jabber.org/protocol/disco#info'>
<identity category='pubsub' type='pep'/>
<identity category='account' type='registered'/>
...
</query>
</iq>
]]></example>
<p>Second, benvolio@montague.net sends a disco#items request to juliet@capulet.com:</p>
<example caption='Unaffiliated entity queries account owner regarding items'><![CDATA[
<iq from='benvolio@montague.net/home'
to='juliet@capulet.com'
id='disco3'
type='get'>
<query xmlns='http://jabber.org/protocol/disco#items'/>
</iq>
]]></example>
<p>The account owner's server MUST check the access model for each of the account owner's PEP nodes and MUST return as service discovery items only those nodes to which the contact is allowed to subscribe or from which the contact is allowed to retrieve items without first subscribing.</p>
<p>Therefore, in this case, the server would return only the "http://jabber.org/protocol/tune" node (since it has an open access model and the contact does not have a presence subscription to the account owner's presence):</p>
<example caption='Server returns appropriate items'><![CDATA[
<iq from='juliet@capulet.com'
to='benvolio@montague.net/home'
id='disco3'
type='result'>
<query xmlns='http://jabber.org/protocol/disco#items'>
<item jid='juliet@capulet.com' node='http://jabber.org/protocol/tune'/>
</query>
</iq>
]]></example>
<p>Next, nurse@capulet.com sends a disco#items request to juliet@capulet.com:</p>
<example caption='Contact with presence subscription queries account owner regarding items'><![CDATA[
<iq from='nurse@capulet.com/chamber'
to='juliet@capulet.com'
id='disco4'
type='get'>
<query xmlns='http://jabber.org/protocol/disco#items'/>
</iq>
]]></example>
<p>However, in this case, the server would return the "http://jabber.org/protocol/tune" node (open access model) <em>and</em> the "http://jabber.org/protocol/activity" node (presence access model):</p>
<example caption='Server returns appropriate items'><![CDATA[
<iq from='juliet@capulet.com'
to='nurse@capulet.com/chamber'
id='disco4'
type='result'>
<query xmlns='http://jabber.org/protocol/disco#items'>
<item jid='juliet@capulet.com' node='http://jabber.org/protocol/tune'/>
<item jid='juliet@capulet.com' node='http://jabber.org/protocol/activity'/>
</query>
</iq>
]]></example>
<p>Finally, romeo@montague.net sends a disco#items request to juliet@capulet.com:</p>
<example caption='Contact with presence subscription and in privileged roster group queries account owner regarding items'><![CDATA[
<iq from='romeo@montague.net/orchard'
to='juliet@capulet.com'
id='disco5'
type='get'>
<query xmlns='http://jabber.org/protocol/disco#items'/>
</iq>
]]></example>
<p>In this case, the server would return the "http://jabber.org/protocol/tune" node (open access model) <em>and</em> the "http://jabber.org/protocol/activity" node (presence access model) <em>and</em> the "http://jabber.org/protocol/geoloc" node (roster access model):</p>
<example caption='Server returns appropriate items'><![CDATA[
<iq from='juliet@capulet.com'
to='romeo@montague.net/orchard'
id='disco5'
type='result'>
<query xmlns='http://jabber.org/protocol/disco#items'>
<item jid='juliet@capulet.com' node='http://jabber.org/protocol/tune'/>
<item jid='juliet@capulet.com' node='http://jabber.org/protocol/activity'/>
<item jid='juliet@capulet.com' node='http://jabber.org/protocol/geoloc'/>
</query>
</iq>
]]></example>
</section1>
<section1 topic='Contact Subscription' anchor='contact-subscribe'>
<p>If an entity is not subscribed to the account owner's presence, it MUST subscribe to a node using the protocol defined in <cite>XEP-0060</cite>. For instance, here is how benvolio@montague.net would subscribe Juliet's tune information:</p>
<example caption='Unaffiliated entity subscribes to an open node'><![CDATA[
<iq type='set'
from='benvolio@montague.net/home'
to='juliet@capulet.com'
id='sub1'>
<pubsub xmlns='http://jabber.org/protocol/pubsub'>
<subscribe node='http://jabber.org/protocol/tune' jid='benvolio@montague.net'/>
</pubsub>
</iq>
]]></example>
<p>However, when a contact is affiliated with the account owner through a presence subscription, PEP greatly simplifies the subscription process. This is done by associating the presence subscription with a pubsub subscription to the account owner's root collection node (i.e., bare JID), with a subscription_type of "items" and a subscription_depth of "all".</p>
<p>Consider the following presence subscription exchange:</p>
<example caption='Presence subscription handshake'><![CDATA[
<section1 topic='Receiving Event Notifications' anchor='notify'>
<p>An entity shall receive event notifications if:</p>
<ol start='1'>
<li>The node has an open access model and the entity has explicitly discovered and subscribed to the node as explained in <cite>XEP-0060</cite>.</li>
<li>The entity shares presence with the account owner (see <link url='#notify-presence'>Presence Sharing</link>), is authorized to receive events from the node in accordance with the node access model (see <cite>XEP-0060</cite>), and advertises an interest in the payload type (see <link url='#notify-filter'>Notification Filtering</link>).</li>
</ol>
<section2 topic='Presence Sharing' anchor='notify-presence'>
<p>When a contact is affiliated with the account owner through a presence subscription, PEP greatly simplifies the subscription process. This is done by associating the presence subscription with a pubsub subscription to the account owner's root collection node (i.e., bare JID), with a subscription_type of "items" and a subscription_depth of "all".</p>
<p>Consider the following presence subscription exchange:</p>
<example caption='Presence subscription handshake'><![CDATA[
<presence from='nurse@capulet.com' to='juliet@capulet.com' type='subscribe'/>
<presence from='juliet@capulet.com' to='nurse@capulet.com' type='subscribed'/>
]]></example>
<p>For PEP purposes, this is equivalent to the following pubsub subscription exchange:</p>
<example caption='Entity subscribes to a collection node'><![CDATA[
]]></example>
<p>For PEP purposes, this is equivalent to the following pubsub subscription exchange:</p>
<example caption='Entity subscribes to a collection node'><![CDATA[
<iq type='set'
from='nurse@capulet.com/chamber'
to='juliet@capulet.com
@ -453,135 +471,45 @@
</iq>
<iq type='result' from='juliet@capulet.com' to='nurse@capulet.com/chamber' id='collsub'/>
]]></example>
<p>Note: Automated pubsub subscriptions MUST be based on the JID contained in the 'from' address of the presence subscription request, which for IM contacts will be a bare JID (&BAREJID;).</p>
</section1>
<section1 topic='Account Owner Publishing' anchor='owner-publish'>
<p>An account owner publishes an item to a node by following the protocol specified in <cite>XEP-0060</cite>:</p>
<example caption='Account owner publishes item'><![CDATA[
<iq from='juliet@capulet.com/balcony' type='set' id='pub1'>
<pubsub xmlns='http://jabber.org/protocol/pubsub'>
<publish node='http://jabber.org/protocol/tune'>
<item>
<tune xmlns='http://jabber.org/protocol/tune'>
<artist>Gerald Finzi</artist>
<title>Introduction (Allegro vigoroso)</title>
<source>Music for "Love's Labors Lost" (Suite for small orchestra)</source>
<track>1</track>
<length>255</length>
</tune>
</item>
</publish>
</pubsub>
</iq>
]]></example>
<p>As a result, the account owner's server generates notifications and sends them to all subscribers who have requested or are interested in the data as described in the <link url='#notifications'>Contact Notification Filtering</link> and <link url='#notifications'>Generating Notifications</link> sections of this document, as well as to any of the account owner's available resources.</p>
<p>The server MUST set the 'from' address on the notification to the bare JID (&BAREJID;) of the account owner (in this example, "juliet@capulet.com"). When sending notifications to an entity that has a presence subscription to the account owner, the server SHOULD include an &xep0033; "replyto" extension specifying the publishing resource (in this example, "juliet@capulet.com/balcony"); this enables the subscriber's client to differentiate between information received from each of the account owner's resources (for example, different resources may be in different places and therefore may need to specify distinct geolocation data). However, a server MUST NOT include the "replyto" address when sending a notification to an entity that does not have a presence subscription to the account owner. In addition, any errors related to the notification MUST be directed to the JID of the 'from' address on the notification (i.e., the bare JID) so that bounce processing can be handled by the PEP service rather than by the publishing client.</p>
<p>Assuming that all three entities previously mentioned would receive the notifications, the PEP service would generate the following stanzas:</p>
<example caption='Server sends notification to subscribers'><![CDATA[
<message from='juliet@capulet.com'
to='benvolio@montague.net'
type='headline'
id='foo'>
<event xmlns='http://jabber.org/protocol/pubsub#event'>
<items node='http://jabber.org/protocol/tune'>
<item>
<tune xmlns='http://jabber.org/protocol/tune'>
<artist>Gerald Finzi</artist>
<title>Introduction (Allegro vigoroso)</title>
<source>Music for "Love's Labors Lost" (Suite for small orchestra)</source>
<track>1</track>
<length>255</length>
</tune>
</item>
</items>
</event>
</message>
<message from='juliet@capulet.com'
to='nurse@capulet.com/chamber'
type='headline'
id='foo'>
<event xmlns='http://jabber.org/protocol/pubsub#event'>
<items node='http://jabber.org/protocol/tune'>
<item>
<tune xmlns='http://jabber.org/protocol/tune'>
<artist>Gerald Finzi</artist>
<title>Introduction (Allegro vigoroso)</title>
<source>Music for "Love's Labors Lost" (Suite for small orchestra)</source>
<track>1</track>
<length>255</length>
</tune>
</item>
</items>
</event>
<addresses xmlns='http://jabber.org/protocol/address'>
<address type='replyto' jid='juliet@capulet.com/balcony'/>
</addresses>
</message>
<message from='juliet@capulet.com'
to='romeo@montague.net/orchard'
type='headline'
id='foo'>
<event xmlns='http://jabber.org/protocol/pubsub#event'>
<items node='http://jabber.org/protocol/tune'>
<item>
<tune xmlns='http://jabber.org/protocol/tune'>
<artist>Gerald Finzi</artist>
<title>Introduction (Allegro vigoroso)</title>
<source>Music for "Love's Labors Lost" (Suite for small orchestra)</source>
<track>1</track>
<length>255</length>
</tune>
</item>
</items>
</event>
<addresses xmlns='http://jabber.org/protocol/address'>
<address type='replyto' jid='juliet@capulet.com/balcony'/>
</addresses>
</message>
]]></example>
<p>Note the 'to' addresses: the notification to Benvolio is addressed to "benvolio@montague.net" (bare JID) since the PEP service does not have presence information about the subscriber, whereas the notifications to the Nurse and to Romeo are addressed to the full JIDs of those subscribers.</p>
</section1>
<section1 topic='Contact Notification Filtering' anchor='contact-filter'>
<p>A contact may not want to receive notifications for all payload types. A contact SHOULD signal its preferences to the account owner's server by including <cite>XEP-0115</cite> information that specifies the namespaces for which the contact wishes to receive notifications (if any).</p>
<p>In order to make this possible, all possible payload namespaces can be appended with the string "+notify" to indicate that the contact wishes to receive notifications for the payload format. Thus if Romeo wants to receive notifications for activity data and geolocation data but not tune data, his client would advertise support for the following namespaces in the disco#info results it sends: <note>Including, say, the 'http://jabber.org/protocol/geoloc' namespace indicates that the client understands the geolocation namespace, whereas including the 'http://jabber.org/protocol/geoloc+notify' namespace indicates that the client wishes to receive notifications related to geolocation.</note></p>
<ul>
<li>http://jabber.org/protocol/activity+notify</li>
<li>http://jabber.org/protocol/geoloc+notify</li>
</ul>
<p>This set of namespaces would then be advertised as a <cite>XEP-0115</cite> "ext" value, such as the following:</p>
<example caption='Contact sends presence with caps'><![CDATA[
]]></example>
<p>Note: Automated pubsub subscriptions MUST be based on the JID contained in the 'from' address of the presence subscription request, which for IM contacts will be a bare JID (&BAREJID;).</p>
</section2>
<section2 topic='Notification Filtering' anchor='notify-filter'>
<p>A contact may not want to receive notifications for all payload types. A contact SHOULD signal its preferences to the account owner's server by including <cite>XEP-0115</cite> information that specifies the namespaces for which the contact wishes to receive notifications (if any).</p>
<p>In order to make this possible, all possible payload namespaces can be appended with the string "+notify" to indicate that the contact wishes to receive notifications for the payload format. Thus if Romeo wants to receive notifications for activity data and geolocation data but not tune data, his client would advertise support for the following namespaces in the disco#info results it sends: <note>Including, say, the 'http://jabber.org/protocol/geoloc' namespace indicates that the client understands the geolocation namespace, whereas including the 'http://jabber.org/protocol/geoloc+notify' namespace indicates that the client wishes to receive notifications related to geolocation.</note></p>
<ul>
<li>http://jabber.org/protocol/geoloc+notify</li>
<li>http://jabber.org/protocol/tune+notify</li>
</ul>
<p>This set of namespaces would then be advertised as a <cite>XEP-0115</cite> "ext" value, such as the following:</p>
<example caption='Contact sends presence with caps'><![CDATA[
<presence from='romeo@montague.net/orchard'>
<c xmlns='http://jabber.org/protocol/caps'
node='http://www.chatopus.com/'
node='http://www.chatopus.com/ec'
ver='2.1'
ext='foobar pres+'/>
ext='sendmeloc tunes'/>
</presence>
]]></example>
<p>Note: In <cite>XEP-0115</cite>, the "ext" values are opaque strings with no semantic meaning.</p>
<p>It is the responsibility of the account owner's server to cache <cite>XEP-0115</cite> information (including "ext" values and their associated namespaces). When the server receives presence from a contact, it MUST check that presence information for entity capabilities data and correlate that data with the desired namespaces for the contact's client. The server MUST NOT send notifications related to any data formats that the contact's client has not asked for via the relevant "namespace+notify" disco#info feature. This enables a client to turn off all notifications (e.g., because of bandwidth restrictions) and to easily receive all desired data formats simply by adding support for the appropriate "namespace+notify" combination in its disco#info results and client capabililies. However, it also implies that a client can request notifications only on a global basis and cannot request, say, mood information only from certain contacts in the user's roster. Community consensus is that this is an acceptable tradeoff. Also, note that this works only if the account owner has a presence subscription to the contact and the contact has a presence subscription to the account owner.</p>
<p>Some examples may help to illustrate the concept of notification filtering. Here we show presence generated by two of the contacts listed above (benvolio@montague.net does have any presence subscriptions to or from juliet@capulet.com and therefore is not involved in these protocol flows).</p>
<example caption='Presence with caps'><![CDATA[
]]></example>
<p>Note: In <cite>XEP-0115</cite>, the "ext" values are opaque strings with no semantic meaning.</p>
<p>It is the responsibility of the account owner's server to cache <cite>XEP-0115</cite> information (including "ext" values and their associated namespaces). When the server receives presence from a contact, it MUST check that presence information for entity capabilities data and correlate that data with the desired namespaces for the contact's client. The server MUST NOT send notifications related to any data formats that the contact's client has not asked for via the relevant "namespace+notify" disco#info feature. This enables a client to turn off all notifications (e.g., because of bandwidth restrictions) and to easily receive all desired data formats simply by adding support for the appropriate "namespace+notify" combination in its disco#info results and client capabililies. However, it also implies that a client can request notifications only on a global basis and cannot request, say, mood information only from certain contacts in the user's roster. Community consensus is that this is an acceptable tradeoff. Also, note that this works only if the account owner has a presence subscription to the contact and the contact has a presence subscription to the account owner.</p>
<p>Some examples may help to illustrate the concept of notification filtering. Here we show presence generated by two of the contacts listed above (benvolio@montague.net does have any presence subscriptions to or from juliet@capulet.com and therefore is not involved in these protocol flows).</p>
<example caption='Presence with caps'><![CDATA[
<presence from='nurse@capulet.com/chamber'>
<c xmlns='http://jabber.org/protocol/caps'
node='http://exodus.jabberstudio.org/caps'
ver='0.9'
ext='asdf fdsa bar baz'/>
ext='foo bar baz'/>
</presence>
<presence from='romeo@montague.net/orchard'>
<c xmlns='http://jabber.org/protocol/caps'
node='http://www.chatopus.com/ec'
ver='2.1'
ext='foobar pres+'/>
ext='sendmeloc sendmetunes'/>
</presence>
]]></example>
<p>We assume that Juliet's server doesn't know anything about these capabilities, so it sends service discovery information requests to each of the clients on Juliet's behalf (realistically, the capulet.com server will quickly build up a cache of client capabilities, with the result that it will not need to send these service discovery requests):</p>
<example caption='Account server queries contact'><![CDATA[
]]></example>
<p>We assume that Juliet's server doesn't know anything about these capabilities, so it sends service discovery information requests to each of the clients on Juliet's behalf (realistically, the capulet.com server will quickly build up a cache of client capabilities, with the result that it will not need to send these service discovery requests):</p>
<example caption='Account server queries node#ver'><![CDATA[
<iq from='juliet@capulet.com'
to='nurse@capulet.com/chamber'
type='get'
@ -597,80 +525,118 @@
<query xmlns='http://jabber.org/protocol/disco#info'
node='http://exodus.jabberstudio.org/caps#0.9'/>
<feature var='http://jabber.org/protocol/tune'/>
<feature var='http://jabber.org/protocol/tune+notify'/>
<feature var='http://jabber.org/protocol/activity'/>
<feature var='http://jabber.org/protocol/activity+notify'/>
<feature var='http://jabber.org/protocol/geoloc'/>
<feature var='http://jabber.org/protocol/geoloc+notify'/>
</query>
</iq>
]]></example>
<example caption='Account server queries contact'><![CDATA[
]]></example>
<p>Note: The disco#info result from the node#ver includes only base protocol support, since user-configured notification preferences are to be specified in entity capability extensions. Therefore the server also needs to query the relevant extensions:</p>
<example caption='Account server queries node#ext combinations'><![CDATA[
<iq from='juliet@capulet.com'
to='romeo@montague.net/orchard'
to='nurse@capulet.com/chamber'
type='get'
id='disco234'>
id='ext123'>
<query xmlns='http://jabber.org/protocol/disco#info'
node='http://www.chatopus.com/ec#2.1'/>
node='http://exodus.jabberstudio.org/caps#foo'/>
</iq>
<iq from='romeo@montague.net/orchard'
<iq from='nurse@capulet.com/chamber'
to='juliet@capulet.com'
type='result'
id='disco234'>
id='ext123'>
<query xmlns='http://jabber.org/protocol/disco#info'
node='http://www.chatopus.com/ec#2.1'/>
<feature var='http://jabber.org/protocol/tune'/>
<feature var='http://jabber.org/protocol/activity'/>
<feature var='http://jabber.org/protocol/geoloc'/>
node='http://exodus.jabberstudio.org/caps#foo'/>
<feature var='http://jabber.org/protocol/tune+notify'/>
</query>
</iq>
<iq from='juliet@capulet.com'
to='nurse@capulet.com/chamber'
type='get'
id='ext234'>
<query xmlns='http://jabber.org/protocol/disco#info'
node='http://exodus.jabberstudio.org/caps#bar'/>
</iq>
<iq from='nurse@capulet.com/chamber'
to='juliet@capulet.com'
type='result'
id='ext234'>
<query xmlns='http://jabber.org/protocol/disco#info'
node='http://exodus.jabberstudio.org/caps#bar'/>
<feature var='http://jabber.org/protocol/activity+notify'/>
</query>
</iq>
<iq from='juliet@capulet.com'
to='nurse@capulet.com/chamber'
type='get'
id='ext123'>
<query xmlns='http://jabber.org/protocol/disco#info'
node='http://exodus.jabberstudio.org/caps#baz'/>
</iq>
<iq from='nurse@capulet.com/chamber'
to='juliet@capulet.com'
type='result'
id='ext123'>
<query xmlns='http://jabber.org/protocol/disco#info'
node='http://exodus.jabberstudio.org/caps#baz'/>
<feature var='http://jabber.org/protocol/geoloc+notify'/>
</query>
</iq>
]]></example>
<p>Now we revisit account owner publication and server generation of notifications, with filtering enabled because the server has caps information:</p>
<ul>
<li><p>If Juliet publishes a tune item to the open-access "http://jabber.org/protocol/tune" node, her server will send notifications to &lt;benvolio@montague.net&gt; (bare JID) and to &lt;nurse@capulet.com/chamber&gt; (full JID) but not to &lt;romeo@montague.net/orchard&gt;.</p></li>
<li><p>If Juliet publishes an activity item to the presence-access "http://jabber.org/protocol/activity" node, her server will send notifications only to &lt;nurse@capulet.com/chamber&gt;.</p></li>
<li><p>If Juliet publishes a geolocation item to the roster-access "http://jabber.org/protocol/geoloc" node, her server will send notifications only to &lt;romeo@montague.net/orchard&gt;.</p></li>
</ul>
</section1>
<section1 topic='Generating Notifications' anchor='notifications'>
<section2 topic='Number of Notifications' anchor='notifications-num'>
<ol start='1'>
<li><p>If a subscriber subscribed using a full JID (&FULLJID;), domain identifier (&DOMAIN;), or domain plus resource (&DOMAINRES;), a PEP service MUST send one notification only, addressed to the subscribed JID.</p></li>
<li><p>If a subscriber subscribed using a bare JID (&BAREJID;) and a PEP service does not have appropriate presence information about the subscriber, a PEP service MUST send at most one notification, addressed to the bare JID (&BAREJID;) of the subscriber, and MAY choose not to send any notification. (By "appropriate presence information" is meant an available presence stanza with non-negative priority and <cite>XEP-0115</cite> data that indicates interest in the relevant data format.)</p></li>
<li><p>If a subscriber subscribed using a bare JID (&BAREJID;) and a PEP service has appropriate presence information about the subscriber, the PEP service MUST send one notification to the full JID (&FULLJID;) of each of the subscriber's available resources that have specified non-negative presence priority and included <cite>XEP-0115</cite> information that indicates an interest in the data format.</p></li>
</ol>
]]></example>
<p>Note: As explained in <cite>XEP-0115</cite>, these requests would not all be sent to the same client and resource, but rather would be sent to random entities that advertise the same entity capabilities information.</p>
<p>The server shall also query the node#ver and node#ext combinations for other contacts (not shown here), which for &lt;romeo@montague.net&gt; indicate an interest in "http://jabber.org/protocol/geoloc+notify" and "http://jabber.org/protocol/tune+notify" but not "http://jabber.org/protocol/activity+notify".</p>
<p>Now we revisit account owner publication and server generation of notifications, with filtering enabled because the server has caps information:</p>
<ul>
<li><p>If Juliet publishes a tune item to the presence-access "http://jabber.org/protocol/tune" node, her server will send notifications to &lt;nurse@capulet.com/chamber&gt; and &lt;romeo@montague.net/orchard&gt; (full JIDs).</p></li>
<li><p>If Juliet publishes an activity item to the presence-access "http://jabber.org/protocol/activity" node, her server will send notifications only to &lt;nurse@capulet.com/chamber&gt;.</p></li>
<li><p>If Juliet publishes a geolocation item to the roster-access "http://jabber.org/protocol/geoloc" node, her server will send notifications only to &lt;romeo@montague.net/orchard&gt;.</p></li>
</ul>
</section2>
<section2 topic='When to Generate Notifications' anchor='notifications-when'>
<ol start='1'>
<li><p>When an account owner publishes an item to a node, a PEP service MUST generate a notification and send it to all appropriate subscribers (where the number of notifications is determined by the foregoing rules).</p></li>
<li><p>When a PEP service receives initial presence information from a subscriber's resource with a non-negative priority and including <cite>XEP-0115</cite> information that indicates an interest in the data format, it MUST generate a notification containing the last published item for that node and send it to the newly-available resource.</p></li>
<li><p>As an exception to the foregoing MUST rules, a PEP service MUST NOT send notifications to a subscriber if the user has blocked the subscriber from receiving all or any kinds of stanza (presence, message, IQ, or any combination thereof) using communiations blocking as specified in <cite>XMPP IM</cite>.</p></li>
</ol>
</section2>
</section1>
<section1 topic='Sending the Last Published Item' anchor='last'>
<p>As described in the <link url='#notifications'>Generating Notifications</link> section of this document, a PEP service MUST send the last published item to all new subscribers and to all newly-available resources for each subscriber. <note>That is, the default value of the "pubsub#send_last_published_item" node configuration field must be "on_sub_and_presence"; this behavior essentially mimics the functionality of presence as defined in <cite>XMPP IM</cite>.</note></p>
<example caption='Subscriber sends presence from newly-available resource'><![CDATA[
<section2 topic='Generating Notifications' anchor='notify-generate'>
<section3 topic='Addressing' anchor='notify-addressing'>
<ol start='1'>
<li><p>The server MUST set the 'from' address on the notification to the bare JID (&BAREJID;) of the account owner (in these examples, "juliet@capulet.com").</p></li>
<li><p>Any errors generated by the recipient or the recipient's server in relation to the notification MUST be directed to the JID of the 'from' address on the notification (i.e., the bare JID) so that bounce processing can be handled by the PEP service rather than by the publishing client.</p></li>
<li><p>When sending notifications to an entity that has a presence subscription to the account owner, the server SHOULD include an &xep0033; "replyto" extension specifying the publishing resource (in this example, "juliet@capulet.com/balcony"); this enables the subscriber's client to differentiate between information received from each of the account owner's resources (for example, different resources may be in different places and therefore may need to specify distinct geolocation data). However, a server MUST NOT include the "replyto" address when sending a notification to an entity that does not have a presence subscription to the account owner.</p></li>
<li><p>If the PEP service has presence information about the intended recipient, it SHOULD direct the notification(s) to the full JID(s) of the recipients (&FULLJID;); if the PEP service does not have presence information about a subscriber, it MUST address the notification to the subscriber's bare JID (&BAREJID;).</p></li>
</ol>
</section3>
<section3 topic='Number of Notifications' anchor='notify-num'>
<ol start='1'>
<li><p>If a subscriber subscribed using a full JID (&FULLJID;), domain identifier (&DOMAIN;), or domain plus resource (&DOMAINRES;), a PEP service MUST send one notification only, addressed to the subscribed JID.</p></li>
<li><p>If a subscriber subscribed using a bare JID (&BAREJID;) and a PEP service does not have appropriate presence information about the subscriber, a PEP service MUST send at most one notification, addressed to the bare JID (&BAREJID;) of the subscriber, and MAY choose not to send any notification. (By "appropriate presence information" is meant an available presence stanza with non-negative priority and <cite>XEP-0115</cite> data that indicates interest in the relevant data format.)</p></li>
<li><p>If a subscriber subscribed using a bare JID (&BAREJID;) and a PEP service has appropriate presence information about the subscriber, the PEP service MUST send one notification to the full JID (&FULLJID;) of each of the subscriber's available resources that have specified non-negative presence priority and included <cite>XEP-0115</cite> information that indicates an interest in the data format.</p></li>
</ol>
</section3>
<section3 topic='When to Generate Notifications' anchor='notify-when'>
<ol start='1'>
<li><p>When an account owner publishes an item to a node, a PEP service MUST generate a notification and send it to all appropriate subscribers (where the number of notifications is determined by the foregoing rules).</p></li>
<li><p>When a PEP service receives initial presence information from a subscriber's resource with a non-negative priority and including <cite>XEP-0115</cite> information that indicates an interest in the data format, it MUST generate a notification containing the last published item for that node and send it to the newly-available resource.</p></li>
<li><p>As an exception to the foregoing MUST rules, a PEP service MUST NOT send notifications to a subscriber if the user has blocked the subscriber from receiving all or any kinds of stanza (presence, message, IQ, or any combination thereof) using communiations blocking as specified in <cite>XMPP IM</cite>.</p></li>
</ol>
</section3>
<section3 topic='Sending the Last Published Item' anchor='notify-last'>
<p>As mentioned, a PEP service MUST send the last published item to all new subscribers and to all newly-available resources for each subscriber. <note>That is, the default value of the "pubsub#send_last_published_item" node configuration field must be "on_sub_and_presence"; this behavior essentially mimics the functionality of presence as defined in <cite>XMPP IM</cite>.</note></p>
<example caption='Subscriber sends presence from newly-available resource'><![CDATA[
<presence from='romeo@montague.net/orchard'>
<c xmlns='http://jabber.org/protocol/caps'
node='http://www.chatopus.com/ec'
ver='2.1'
ext='foobar pres+'/>
ext='sendmeloc sendmetunes'/>
</presence>
]]></example>
<example caption='Subscriber&apos;s server sends presence from newly-available resource to publisher&apos;s bare JID (i.e., PEP service)'><![CDATA[
]]></example>
<example caption='Subscriber&apos;s server sends presence from newly-available resource to publisher&apos;s bare JID (i.e., PEP service)'><![CDATA[
<presence from='romeo@montague.net/orchard' to='juliet@capulet.com'>
<c xmlns='http://jabber.org/protocol/caps'
node='http://www.chatopus.com/ec'
ver='2.1'
ext='foobar pres+'/>
ext='sendmeloc sendmetunes'/>
</presence>
]]></example>
<example caption='PEP service sends last published item to newly-available resource'><![CDATA[
]]></example>
<example caption='PEP service sends last published item to newly-available resource'><![CDATA[
<message from='juliet@capulet.com'
to='romeo@montague.net/orchard'
type='headline'
@ -690,11 +656,9 @@
</event>
<x xmlns='jabber:x:delay' stamp='20031213T23:58:37'/>
</message>
]]></example>
</section1>
<section1 topic='Private Data Storage' anchor='privatedata'>
<p>As noted, PEP services may be used to implement private data storage, such as defined in &xep0049;. A future version of this document will specify this usage in more detail.</p>
]]></example>
</section3>
</section2>
</section1>
<section1 topic='Recommended Defaults' anchor='defaults'>
@ -712,7 +676,67 @@
<p>A PEP service MAY support other use cases, affiliations, access models, and features, but such support is OPTIONAL.</p>
</section1>
<section1 topic='Implementation Notes' anchor='imple'>
<section1 topic='Service Discovery' anchor='disco'>
<section2 topic='Account Owner Service Discovery' anchor='disco-owner'>
<p>Naturally, before an account owner attempts to complete any PEP use cases, its client SHOULD determine whether the account owner's server supports PEP; to do so, it MUST send a &xep0030; information request to the server:</p>
<example caption='Account owner queries server regarding protocol support'><![CDATA[
<iq from='juliet@capulet.com/balcony'
to='capulet.com'
id='disco1'
type='get'>
<query xmlns='http://jabber.org/protocol/disco#info'/>
</iq>
]]></example>
<p>If a server supports PEP, it MUST return an identity of "pubsub/pep" (as well as a list of the namespaces and other features it supports, including all supported <cite>XEP-0060</cite> features):</p>
<example caption='Server communicates protocol support'><![CDATA[
<iq from='capulet.com'
to='juliet@capulet.com/balcony'
id='disco1'
type='result'>
<query xmlns='http://jabber.org/protocol/disco#info'>
<identity category='server' type='im'/>
<identity category='pubsub' type='pep'/>
<feature var='http://jabber.org/protocol/pubsub#config-node'/>
<feature var='http://jabber.org/protocol/pubsub#create-and-configure'/>
<feature var='http://jabber.org/protocol/pubsub#create-nodes'/>
<feature var='http://jabber.org/protocol/pubsub#persistent-items'/>
<feature var='http://jabber.org/protocol/pubsub#publish'/>
<feature var='http://jabber.org/protocol/pubsub#retrieve-items'/>
<feature var='http://jabber.org/protocol/pubsub#subscribe'/>
...
</query>
</iq>
]]></example>
</section2>
<section2 topic='Contact Service Discovery' anchor='disco-contact'>
<p>A contact MAY send service discovery requests to the account owner's bare JID (&BAREJID;). If the contact already has a subscription to the account owner's presence, this is not necessary in order to receive notifications from the account owner via personal eventing. However, a user without a presence subscription needs to do so in order to discover if the account owner is a virtual pubsub service and to discover the account owner's eventing nodes. The relevant protocol flows are demonstrated in <cite>XEP-0060</cite>.</p>
<p>Note: When returning disco#info results, the account owner's server MUST check the access model for each of the account owner's PEP nodes and MUST return as service discovery items only those nodes to which the contact is allowed to subscribe or from which the contact is allowed to retrieve items without first subscribing.</p>
</section2>
</section1>
<section1 topic='Pubsub Features' anchor='features'>
<p>This subset of Publish-Subscribe defines and registers two additional pubsub features, as shown in the following table.</p>
<p>Note: The feature names are of the form "http://jabber.org/protocol/pubsub#name", where "name" is the text specified in the first column below.</p>
<table caption='Service Discovery Features'>
<tr>
<th>Name</th>
<th>Description</th>
<th>Support</th>
</tr>
<tr>
<td>auto-create</td>
<td>The service supports auto-creation of nodes on publish to a non-existent node.</td>
<td>REQUIRED for PEP services, OPTIONAL for generic pubsub services</td>
</tr>
<tr>
<td>publish-and-configure</td>
<td>The service supports specification of desired node configuration on publish.</td>
<td>REQUIRED for PEP services, OPTIONAL for generic pubsub services</td>
</tr>
</table>
</section1>
<section1 topic='Implementation Notes' anchor='impl'>
<section2 topic='Cancelling Subscriptions' anchor='impl-subscriptions'>
<p>In order to ensure appropriate access to information published at nodes of type "presence" and "roster", a PEP service MUST re-calculate access controls when:</p>
<ol start='1'>
@ -721,6 +745,9 @@
</ol>
<p>If the modification results in a loss of access, the service MUST cancel the entity's subscription. In addition, the service MAY send a message to the (former) subscriber informing it of the cancellation (for information about the format of messages sent to notify subscribers of subscription cancellation, see the "Notification of Subscription Denial or Cancellation" section of <cite>XEP-0060</cite>).</p>
</section2>
<section2 topic='Private Data Storage' anchor='impl-private'>
<p>A PEP node with an access model of "whitelist" and no entities on the whitelist effectively results in a node that enables private data storage, e.g. as defined in &xep0049;. A separate document will specify private data storage via PEP in more detail.</p>
</section2>
</section1>
<section1 topic='Security Considerations' anchor='security'>
@ -749,6 +776,21 @@
</category>
]]></code>
</section2>
<section2 topic='Service Discovery Features' anchor='registrar-features'>
<p>The XMPP Registrar maintains a registry of service discovery features (see &DISCOFEATURES;), which includes a number of features that may be returned by pubsub services. The following registry submission has been provided to the XMPP Registrar for that purpose.</p>
<code><![CDATA[
<var>
<name>http://jabber.org/protocol/pubsub#auto-create</name>
<desc>The service supports automatic creation of nodes on publish.</desc>
<doc>XEP-0163</doc>
</var>
<var>
<name>http://jabber.org/protocol/pubsub#publish-and-configure</name>
<desc>The service accepts node configuration forms on publish.</desc>
<doc>XEP-0163</doc>
</var>
]]></code>
</section2>
</section1>
<section1 topic='XML Schema' anchor='schema'>
@ -757,6 +799,7 @@
<section1 topic='Acknowledgements' anchor='ack'>
<p>The authors wish to thank the participants in the XMPP Interoperability Testing Event held July 24 and 25, 2006, who provided valuable feedback that resulted in radical simplification of the protocol.</p>
<p>Thanks also to the many members of the standards@xmpp.org discussion list who patiently suffered through seemingly endless discussion of the auto-create and publish-and-configure features.</p>
</section1>
</xep>