No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

xep-0303.xml 21KB

  1. <?xml version='1.0' encoding='UTF-8'?>
  2. <!DOCTYPE xep SYSTEM 'xep.dtd' [
  3. <!ENTITY % ents SYSTEM 'xep.ent'>
  4. %ents;
  5. ]>
  6. <?xml-stylesheet type='text/xsl' href='xep.xsl'?>
  7. <xep>
  8. <header>
  9. <title>Commenting</title>
  10. <abstract>This specification defines a method for commenting.</abstract>
  12. <number>0303</number>
  13. <status>Deferred</status>
  14. <type>Standards Track</type>
  15. <sig>Standards</sig>
  16. <dependencies>
  17. <spec>XMPP Core</spec>
  18. </dependencies>
  19. <supersedes/>
  20. <supersededby/>
  21. <shortname>NOT_YET_ASSIGNED</shortname>
  22. &infiniti;
  23. <revision>
  24. <version>0.1</version>
  25. <date>2011-07-28</date>
  26. <initials>psa</initials>
  27. <remark><p>Initial published version.</p></remark>
  28. </revision>
  29. <revision>
  30. <version>0.0.1</version>
  31. <date>2011-07-07</date>
  32. <initials>jk</initials>
  33. <remark><p>First draft.</p></remark>
  34. </revision>
  35. </header>
  36. <section1 topic='Introduction' anchor='intro'>
  37. <p>Commenting is a popular activity on the Internet. Users leave comments on just about anything: blog posts, news articles, product reviews, photos, status updates, etc. Existing commenting solutions often involve proprietary access methods and authentication, and are silo'd off from other services. This specification proposes an open and federated way of commenting. A conversation exists as a set of &xep0060; nodes, containing comment items or other activity, and any user with a JID may leave a comment there (per conversation access rules). The protocol is designed to be modern, social, and extensible. Additionally, while the protocol is described in XMPP terms, the core concept is meant to translate easily to the HTTP-based Social Web.</p>
  38. </section1>
  39. <section1 topic='Requirements' anchor='reqs'>
  40. <p>The following features are required:</p>
  41. <ul>
  42. <li>A client MUST be able to efficiently request the most recent portion of a conversation (as well as "page" to further portions) without having to fetch every comment.</li>
  43. <li>A client MUST be able to efficiently receive updates to a conversation as they happen.</li>
  44. <li>It MUST be possible to nest comments (comments as replies to other comments) for rendering the conversation as a tree.</li>
  45. <li>A user MUST be able to mention another user in a comment, and have that user be notified about it.</li>
  46. <li>A user MUST be able to efficiently track its own history in a conversation using a third-party service. For example, such a service might maintain a web page of the user's activity, or send an SMS message to the user if a reply is discovered.</li>
  47. <li>To enable future expansion, consideration must be made for allowing non-comment activity in the conversation, even if this specification does not define those activity types.</li>
  48. </ul>
  49. </section1>
  50. <section1 topic='Result Set Management' anchor='pubsub-rsm'>
  51. <p>&xep0060; contains an example of how to retrieve items with &xep0059;, but the specification is light on details. This section gives a more complete description of how RSM is used in conjunction with PubSub.</p>
  52. <p>Clients MAY provide an RSM section in the iq request:</p>
  53. <example caption="Requesting items with a maximum of 20 in the result set"><![CDATA[
  54. <iq type="get" from="" to="" id="1">
  55. <pubsub xmlns="">
  56. <items node="activity"/>
  57. <set xmlns="">
  58. <max>20</max>
  59. </set>
  60. </pubsub>
  61. </iq>]]></example>
  62. <p>The server MAY provide an RSM section in the response. This is already documented in XEP-0060. The server can do this regardless of whether or not the client has made the request with RSM.</p>
  63. <p>Use of RSM implies that there is a natural ordering of the items at a node. The criteria used for ordering is to be determined by the node.</p>
  64. <p>RSM and max_items do not mix. If the client provides both, then the server MUST prefer RSM. If the server does not support RSM, then it may honor max_items and return items ordered by newest first (which may not necessarily be the same as the ordering used by RSM).</p>
  65. </section1>
  66. <section1 topic='How It Works' anchor='protocol'>
  67. <section2 topic='Conversation Nodes' anchor='nodes'>
  68. <p>A conversation exists across a set of PubSub nodes, some of which are dynamic:</p>
  69. <table caption='Conversation Nodes and their Descriptions'>
  70. <tr>
  71. <th>Node</th>
  72. <th>Natural Sort Order</th>
  73. <th>Description</th>
  74. </tr>
  75. <tr>
  76. <td>"info"</td>
  77. <td>N/A</td>
  78. <td>Singleton node containing information about the conversation.</td>
  79. </tr>
  80. <tr>
  81. <td>"comments" (dynamic)</td>
  82. <td>modified-ascending</td>
  83. <td>Contains comment items only. This node is primarily used for presenting conversations to the user. It is essentially a subset of the activity node.</td>
  84. </tr>
  85. <tr>
  86. <td>"activity" (dynamic)</td>
  87. <td>modified-ascending</td>
  88. <td>Contains all activity items in the conversation, including comments. This node is primarily used for submitting comments and receiving mention events. Item persistence is OPTIONAL. Advanced implementations may choose to maintain full activity history of a conversation and expose it in this node.</td>
  89. </tr>
  90. </table>
  91. <p>The comments and activity nodes share item data. Comments are added to the conversation by publishing to the activity node, yet the comment will also appear in the comments node as a result. In fact, since the activity node is not required to offer item persistence, it is possible that the comment might <em>only</em> be retrievable through the comments node. Implementations of this protocol will therefore require tight association between the comments and activity nodes. It is not possible to implement this protocol using a "generic" PubSub service.</p>
  92. <p>A dynamic node accepts additional parameters by appending the parameters to the node name using a "query"-like notation. Parameters and values in the query string MUST be percent-encoded.</p>
  93. <table caption='Dynamic Node Parameters'>
  94. <tr>
  95. <th>Name</th>
  96. <th>Allowed Values</th>
  97. <th>Applies To</th>
  98. <th>Example</th>
  99. </tr>
  100. <tr>
  101. <td>"order"</td>
  102. <td>"-created" (sort items by created time, descending)</td>
  103. <td>comments</td>
  104. <td>Node name "comments?order=-created" would present comments in created-descending order.</td>
  105. </tr>
  106. <tr>
  107. <td>"parent_ids"</td>
  108. <td>Comma-separated list of parent comment IDs to filter by. An empty value means to include top-level comments.</td>
  109. <td>comments</td>
  110. <td>Node name "comments?order=-created&amp;parent_ids=1%2C5a%2Co19g%2C" (note last value is empty) would present items in created-descending order, filtered to only include comments that have parent ID "1", "5a", "o19g", or are top-level.</td>
  111. </tr>
  112. </table>
  113. <p>The "activity" node is defined as dynamic to allow for future expansion, even though no dynamic node parameters are defined in this document that apply to it.</p>
  114. <p>Before utilizing additional nodes or parameters not defined in this document, the client SHOULD first determine support via &xep0030; or other discovery mechanism. If the server does not support or understand a parameter or value, it SHOULD reject the request. Attempting to service a request by ignoring unsupported parameters will most likely result in incorrect or undesired behavior.</p>
  115. <p>A conversation is accessible through a JID and optionally a node prefix. The prefix is prepended to the desired node name, separated by a '/' character. For example, if the "Coffee Talk" conversation is said to be accessible at the JID "" without a node prefix, then PubSub interactions are made using the node names defined above (i.e. "info", "comments", etc). If that conversation is instead said to be accessible at the JID "" with node prefix "coffeetalk", then PubSub interactions are made using node names like "coffeetalk/info", "coffeetalk/comments", etc. This allows conversations to be provisioned as either one per JID or many per JID.</p>
  116. </section2>
  117. <section2 topic='Retrieving Information About the Conversation' anchor='retrieve-info'>
  118. <p>Information about a conversation can be obtained by requesting the item from the info node.</p>
  119. <example caption="Retrieve conversation info"><![CDATA[
  120. <iq type="get" from="" to="" id="2">
  121. <pubsub xmlns="">
  122. <items node="coffeetalk/info"/>
  123. </pubsub>
  124. </iq>]]></example>
  125. <example caption="Server responds"><![CDATA[
  126. <iq type="result" from="" to="" id="2">
  127. <pubsub xmlns="">
  128. <items node="coffeetalk/info">
  129. <item id="current">
  130. <entry xmlns="">
  131. <title>Coffee Talk</title>
  132. <summary>A great place to talk about your day.</summary>
  133. <id>,2011:coffeetalk</id>
  134. <published>2011-07-01T10:15:00Z</published>
  135. <updated>2011-07-01T10:15:00Z</updated>
  136. </entry>
  137. </item>
  138. </items>
  139. </pubsub>
  140. </iq>]]></example>
  141. <p>It is also possible to subscribe to the info node to track changes to the conversation information.</p>
  142. </section2>
  143. <section2 topic='Retrieving Comments in a Conversation' anchor='retrieve-comments'>
  144. <p>The process for retrieving the first "page" of a conversation and listening for further updates can be summarized as follows:</p>
  145. <ol>
  146. <li>Subscribe to the "comments" node.</li>
  147. <li>Retrieve items from the "comments?order=-created" node. Multiple retrieval requests may be required depending on the client display needs (parent_ids can be used to reduce trips, see the <link url='#impl'>Implementation Notes</link>)</li>
  148. <li>Updates are pushed via the subscription.</li>
  149. </ol>
  150. <p>First, the client subscribes to the comments node. A temporary subscription is recommended, so that it is removed if the client goes offline.</p>
  151. <example caption="Subscribe to comments node"><![CDATA[
  152. <iq type="set" from="" to="" id="1">
  153. <pubsub xmlns="">
  154. <subscribe node="coffeetalk/comments" jid=""/>
  155. <options>
  156. <x xmlns="jabber:x:data" type="submit">
  157. <field var="FORM_TYPE" type="hidden">
  158. <value></value>
  159. </field>
  160. <field var="pubsub#expire"><value>presence</value></field>
  161. </x>
  162. </options>
  163. </pubsub>
  164. </iq>]]></example>
  165. <p>Next, the client retrieves past comments. For simplicity, the example below will fetch the 50 most recently created comments. This would be useful for displaying the comments in a flat list.</p>
  166. <example caption="Retrieve the most recent comments"><![CDATA[
  167. <iq type="get" from="" to="" id="2">
  168. <pubsub xmlns="">
  169. <items node="coffeetalk/comments?order=-created"/>
  170. <set xmlns="">
  171. <max>50</max>
  172. </set>
  173. </pubsub>
  174. </iq>]]></example>
  175. <example caption="Server responds"><![CDATA[
  176. <iq type="result" from="" to="" id="2">
  177. <pubsub xmlns="">
  178. <items node="coffeetalk/comments?order=-created">
  179. <item id="39267824-cdc8-11df-b1a7-0024bed71c0a">
  180. <entry xmlns="" xmlns:activity="">
  181. <id>1</id>
  182. <title>Bob posted a comment in the Coffee Talk conversation.</title>
  183. <summary>Bob posted a comment in the Coffee Talk conversation.</summary>
  184. <published>2011-07-01T12:00:00Z</published>
  185. <updated>2011-07-01T12:00:00Z</updated>
  186. <author>
  187. <name>Bob</name>
  188. <uri></uri>
  189. <activity:object-type>person</activity:object-type>
  190. </author>
  191. <activity:object>
  192. <id>1</id>
  193. <title>This is a nice comment.</title>
  194. <content type="text/html">This is a nice comment.</summary>
  195. <activity:object-type>comment</activity:object-type>
  196. </activity:object>
  197. </entry>
  198. </item>
  199. ...
  200. </items>
  201. <set xmlns="">
  202. <first index="0">39267824-cdc8-11df-b1a7-0024bed71c0a</first>
  203. <last>ac277776-cdd5-11df-92c4-0024bed71c0a</last>
  204. <count>5</count>
  205. </set>
  206. </pubsub>
  207. </iq>]]></example>
  208. <p>Comments are stored as Activity Streams items in Atom format.</p>
  209. </section2>
  210. <section2 topic='Submitting a Comment' anchor='submit'>
  211. <p>Comments are submitted by publishing the comment to the activity node.</p>
  212. <example caption="Publishing a comment"><![CDATA[
  213. <iq type="set" from="" to="" id="3">
  214. <pubsub xmlns="">
  215. <publish node="activity">
  216. <item>
  217. <entry xmlns="" xmlns:activity="">
  218. <id>2</id>
  219. <title>Alice posted a comment in the Coffee Talk conversation.</title>
  220. <summary>Alice posted a comment in the Coffee Talk conversation.</summary>
  221. <published>2011-07-01T13:00:00Z</published>
  222. <updated>2011-07-01T13:00:00Z</updated>
  223. <activity:object>
  224. <id>2</id>
  225. <title>This is another nice comment.</title>
  226. <content type="text/html">This is another nice comment.</summary>
  227. <activity:object-type>comment</activity:object-type>
  228. </activity:object>
  229. </entry>
  230. </item>
  231. </publish>
  232. </pubsub>
  233. </iq>]]></example>
  234. <p>Upon receiving the request, the server MUST sanitize the item as necessary before accepting it. In particular, the author information MUST be confirmed or replaced with the information of the user that submitted the comment. If the item is not formatted as a valid Activity Streams Comment, then the request MUST be rejected.</p>
  235. <example caption="Rejecting invalid comment"><![CDATA[
  236. <iq type="error" from="" to="" id="3">
  237. <error type="modify">
  238. <bad-request xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"/>
  239. </error>
  240. </iq>]]></example>
  241. <p>Next, the server SHOULD ensure it has the submitter's user information. This is so when the comment is served to other clients, name and avatar information can be provided as well. This is done by requesting the VCard of the submitter's bare JID using &xep0054;. If the server skips this step, the author name SHOULD be the bare JID of the submitter.</p>
  242. <example caption="Server responds with success"><![CDATA[
  243. <iq type="result" from="" to="" id="3">
  244. <pubsub xmlns="">
  245. <publish node="activity">
  246. <item id="0f72afbe-a9d4-11e0-b0bc-0024bed71c0a"/>
  247. </publish>
  248. </pubsub>
  249. </iq>]]></example>
  250. <example caption="Server relays comment to subscribers"><![CDATA[
  251. <message type="headline" from="" to="">
  252. <event xmlns="">
  253. <items node="comments">
  254. <item id="0f72afbe-a9d4-11e0-b0bc-0024bed71c0a">
  255. <entry xmlns="" xmlns:activity="">
  256. <id>0f72afbe-a9d4-11e0-b0bc-0024bed71c0a</id>
  257. <title>Alice posted a comment in the Coffee Talk conversation.</title>
  258. <summary>Alice posted a comment in the Coffee Talk conversation.</summary>
  259. <published>2011-07-01T13:00:00Z</published>
  260. <updated>2011-07-01T13:00:00Z</updated>
  261. <author>
  262. <name>Alice</name>
  263. <uri></uri>
  264. <activity:object-type>person</activity:object-type>
  265. </author>
  266. <activity:object>
  267. <id>0f72afbe-a9d4-11e0-b0bc-0024bed71c0a</id>
  268. <title>This is another nice comment.</title>
  269. <content type="text/html">This is another nice comment.</summary>
  270. <activity:object-type>comment</activity:object-type>
  271. </activity:object>
  272. </entry>
  273. </item>
  274. </items>
  275. </event>
  276. </message>]]></example>
  277. </section2>
  278. <section2 topic='Other Activity' anchor='submit-other'>
  279. <p>Conversations MAY support submission of activity items other than comments. A client SHOULD first determine support for other item types before attempting to submit them. If a server does not support an item type, it should reject it:</p>
  280. <example caption="Rejecting unsupported activity type"><![CDATA[
  281. <iq type="error" from="" to="" id="3">
  282. <error type="modify">
  283. <bad-request xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"/>
  284. </error>
  285. </iq>]]></example>
  286. </section2>
  287. <section2 topic='Mentions' anchor='mentions'>
  288. <p>If the server deems a submitted comment to be relevant to a user who is not subscribed to the activity node, it SHOULD send an unsolicited event to that user anyway. This way, users can "tag" or "mention" users not involved in a conversation, so that they may be notified about it.</p>
  289. <p>A comment is considered relevant to a user if one the following are true:</p>
  290. <ul>
  291. <li>The user is the one that submitted the comment. This is to allow a user service to automatically pick up on conversations that the user has commented in, without the user's client to have to explicitly inform the user service.</li>
  292. <li>The comment is a reply to one of the user's comments, or it affects one of the user's comments in some way (for example, modification by an admin).</li>
  293. <li>The comment body contains an HTML Microdata object of type "", where the itemid value is the user's account URI.</li>
  294. </ul>
  295. </section2>
  296. <section2 topic='Deleted Comments' anchor='deleted'>
  297. <p>If a comment is deleted, it SHOULD remain in the past items of the node(s), but with its content cleared out and replaced with bogus author data and no activity:object. This change should also cause the comment item to be pushed out again to subscribers and relevant users. This way, entities that are tracking the conversation for changes can be informed of deletes. Even after a network failure, the deleted items can be discovered by retrieving past items.</p>
  298. </section2>
  299. </section1>
  300. <section1 topic='Implementation Notes' anchor='impl'>
  301. <p>In order for the user information that gets saved with comments to not become stale over time, servers SHOULD have ways of refreshing this information by refetching user vcards.</p>
  302. <p>To load a conversation intended for display with nesting, the following algorithm is RECOMMENDED:</p>
  303. <ol>
  304. <li>Let C be the desired number of total comments to display.</li>
  305. <li>Request the C newest top-level comments (set parent_ids to an empty value).</li>
  306. <li>Request the C newest comments at depth 1, by setting parent_ids to the list of comments in the previous request that had a reply count greater than 0.</li>
  307. <li>Repeat previous step for every depth until the full depth has been traversed.</li>
  308. <li>Truncate resulting tree to C items.</li>
  309. </ol>
  310. </section1>
  311. <section1 topic='Security Considerations' anchor='security'>
  312. <p>As noted when handling comment submission above, the server MUST replace author information with that of the user performing the submission. This is essential to prevent author spoofing.</p>
  313. <p>Care SHOULD be taken to prevent "mention spam." If the server determines a user is acting maliciously, then it MUST NOT send unsolicited events as a result of a submission. If a user service receives a mention event from a comment author that it has determined to be malicious, then it MUST NOT process the event further.</p>
  314. </section1>
  315. <section1 topic='IANA Considerations' anchor='iana'>
  316. <p>No interaction with &IANA; is required as a result of this document.</p>
  317. </section1>
  318. <section1 topic='XMPP Registrar Considerations' anchor='registrar'>
  319. <section2 topic='Protocol Namespaces' anchor='registrar-ns'>
  320. <p>This specification defines the following XML namespace:</p>
  321. <ul>
  322. <li>urn:xmpp:tmp:comments:0</li>
  323. </ul>
  324. <p>Upon advancement of this specification from a status of Experimental to a status of Draft, the &REGISTRAR; shall add the foregoing namespace to the registry located at &NAMESPACES;, as described in Section 4 of &xep0053;.</p>
  325. </section2>
  326. <section2 topic='Namespace Versioning' anchor='registrar-versioning'>
  327. &NSVER;
  328. </section2>
  329. </section1>
  330. </xep>