<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type='text/xsl' href='xep.xsl'?>
<xep xmlns="">
<header>
  <title>Best Practices for Roster and Subscription Management</title>
  <abstract>This document specifies best practices for roster and subscription management in Jabber/XMPP clients.</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>0162</number>
  <status>Deferred</status>
  <type>Informational</type>
  <sig>Standards</sig>
  <dependencies/>
  <supersedes/>
  <supersededby/>
  <shortname>N/A</shortname>
  <author>
    <firstname>Lucas</firstname>
    <surname>Nussbaum</surname>
    <email>lucas@lucas-nussbaum.net</email>
    <jid>lucas@nussbaum.fr</jid>
  </author>
  <revision>
    <version>0.2.1</version>
    <date>2020-06-25</date>
    <initials>ps</initials>
    <remark>Fixed small typos</remark>
  </revision>
  <revision>
    <version>0.2</version>
    <date>2005-12-06</date>
    <initials>lnu</initials>
    <remark>Added a note about the name of the Hidden group. Clarified which items should be displayed.</remark>
  </revision>
  <revision>
    <version>0.1</version>
    <date>2005-10-19</date>
    <initials>lnu</initials>
    <remark>Initial version.</remark>
  </revision>
  <revision>
    <version>0.0.3</version>
    <date>2005-10-18</date>
    <initials>lnu</initials>
    <remark>Added a remark about "Remove" vs "Block" in other IM systems.</remark>
  </revision>
  <revision>
    <version>0.0.2</version>
    <date>2005-10-07</date>
    <initials>lnu</initials>
    <remark>Integrated some feedback from Standards list discussion.</remark>
  </revision>
  <revision>
    <version>0.0.1</version>
    <date>2005-10-04</date>
    <initials>lnu</initials>
    <remark>First draft.</remark>
  </revision>
</header>

<section1 topic="Introduction" anchor="intro">
  <section2 topic="Motivation" anchor="intro-motive">

    <p><span class="ref"><link url="http://tools.ietf.org/html/rfc3921">RFC 3921</link></span> <note>RFC 3921: Extensible Messaging and Presence Protocol (XMPP): Instant Messaging and Presence &lt;<link url="http://tools.ietf.org/html/rfc3921">http://tools.ietf.org/html/rfc3921</link>&gt;.</note> explains how subscriptions and rosters integrate. However,
    several points are left to the client author's discretion, and this can lead
    to some confusion among client developers. This document specifies best practices
    that enable all Jabber clients to manage subscriptions and roster in a coherent
    way, thus making sure that such clients will not surprise end users with
    unexpected behavior.</p>

  </section2>

  <section2 topic="Overview of subscription states" anchor="intro-oversub">

    <p>As defined in RFC 3921 (sections 6, 7, 8), a roster item can have one
    of the following subscription states:</p>

    <ul>

      <li><em>subscription='none'</em>: you aren't interested in the item's
      presence, and neither is the item interested in yours.</li>

      <li><em>subscription='from'</em>: the item is interested in your
    presence information, but you don't care about the contact. (You must
    be somebody important! ;)</li>

      <li><em>subscription='to'</em>: You are interested in the item's
    presence information, but the contact is not interested in
    yours.</li>

      <li><em>subscription='both'</em>: You and the contact are interested in each other's presence information.</li>

    </ul>

   <p>Additionally, if <em>subscription='from'</em> or
   <em>subscription='none'</em>, you can have <em>ask='subscribe'</em>, which
   means you sent a subscription request to the item but haven't received an
   answer yet.</p>

  </section2>

</section1>

<section1 topic="Removal of Contacts" anchor="removal">
  <p>It is necessary to distinguish two things:</p>
  <ul>
  <li>Removal from the user's roster (does the user's roster include an entry
  for this JID?) ;</li>
  <li>Removal of presence subscription (cancellation of subscription).</li>
  </ul>
  <p>Three problems have to be taken into consideration here:</p>
  <ul>

  <li>Removing an item from your roster (i.e., performing a roster set with <em>subscription='remove'</em>) cancels all subscriptions (both from
  the item and to the item).</li>

  <li>The fact that a user is no longer interested in the contact's
  presence doesn't mean that the contact is no longer interested in the
  user's presence.</li>

  <li>This is complex, and should be presented in a simple way to the
  user.</li>

  </ul>

  <p>Therefore, the following behavior is RECOMMENDED for Jabber clients:</p>

  <ol>
    <li><p>When the user asks for the removal of an item with
  <em>subscription='both'</em>, the Jabber client SHOULD ask the user whether
  he wants to revoke the contact's authorization to see the user's presence
  too. This action SHOULD be called "Remove" since this is the convention used
  by other IM systems.</p></li>
    <li>
      <p>The Jabber client SHOULD NOT remove the contact from the roster. There
  are two exceptions:</p>
      <ol style="list-style-type: lower-alpha">
        <li><p>The Jabber client MAY remove the contact from the roster if the user
  explicitely asked (so the user has to be informed he might remove both
  presence subscriptions).</p></li>
        <li><p>The jabber client MAY transparently remove the contact from the roster if
  the user asked to, and if <em>subscription='none'</em> or
  <em>subscription='to'</em>.</p></li>
      </ol>
    </li>
  </ol>

  <p>In addition to the "Remove" action described above, the client MAY
  provide a way to revoke the contact's subscription to the user's presence.
  This action, if provided, SHOULD be called "Block" since this is the
  convention used by other IM networks.</p>

</section1>
<section1 topic="Display of Contacts in the Roster" anchor="contacts">

  <p>Defining a sensible roster policy is difficult, because many users have different, special needs. We have to ensure that:</p>
  <ul>
  <li>Most contacts that everybody wants to hide are hidden.</li>
  <li>No contact that someone wants to see is hidden.</li>
  </ul>

  <p>The user's roster contains both contacts of interest for the user
  (contacts with <em>subscription='both'</em> or <em>subscription='to'</em>) and contacts which
  are only interested in receiving the user's presence information. Also, the
  user might be interested in having some contacts even with
  <em>subscription='none'</em>, because he often sends messages to them but isn't
  interested in their presence.</p>


  <p>Therefore, the following types of contacts SHOULD be displayed by clients:</p>
  <ul>
  <li>items with <em>subscription='both'</em> or <em>subscription='to'</em> ;</li>
  <li>items with <em>subscription='none'</em> or <em>subscription='from'</em> and <em>ask='subscribe'</em>. It is ((subscription='none' or subscription='from') and ask='subscribe') ;</li>
  <li>items with <em>subscription='none'</em> or <em>subscription='from'</em> which have a 'name' attribute or a 'group' child set. It is ((subscription='none' or subscription='from') and (name attribute or group child)).</li>
  </ul>

  <p>The client MAY display contacts with subscription='from' which don't match
  one of the above cases in an additional 'Observers' group. If no 'Observers' group is
  used, the client SHOULD NOT display contacts which don't match one of the
  above rules.</p>

  <p>Some users give nicknames to contacts they do not want to see, to be able to remember who they are when cleaning the roster. An additional 'Hidden' group MAY be used to handle such contacts. The client SHOULD NOT display contacts if one of their groups is the 'Hidden' group. (This mean that if contact 'C' is in groups 'G' and 'Hidden', 'C' should never be displayed, even in group 'G'.)</p>

  <section2 topic="Name of the Hidden group" anchor="hiddenname">

  <p>The name of the 'Hidden' group can be managed in two different ways :</p>
  <ul>
  <li>It could always be named 'Hidden' but be displayed translated by the client ;</li>
  <li>It could be named as the user wants. Its name could then be stored using jabber:iq:private, like the delimiter for nested groups in <span class="ref"><link url="https://xmpp.org/extensions/xep-0083.html">Nested Roster Groups (XEP-0083)</link></span> <note>XEP-0083: Nested Roster Groups &lt;<link url="https://xmpp.org/extensions/xep-0083.html">https://xmpp.org/extensions/xep-0083.html</link>&gt;.</note>.</li>
  </ul>
  <p>This is left as an open issue since no clients (to the author's knowledge) implement this 'Hidden' group. But the preference should go to the first solution, which avoids relying on <span class="ref"><link url="https://xmpp.org/extensions/xep-0049.html">Private XML Storage (XEP-0049)</link></span> <note>XEP-0049: Private XML Storage &lt;<link url="https://xmpp.org/extensions/xep-0049.html">https://xmpp.org/extensions/xep-0049.html</link>&gt;.</note>.</p>

</section2>
</section1>
</xep>
