diff --git a/xep-0313.xml b/xep-0313.xml index 29958428..8a6ddb2c 100644 --- a/xep-0313.xml +++ b/xep-0313.xml @@ -10,7 +10,7 @@ This document defines a protocol to query and control an archive of messages stored on a server. &LEGALNOTICE; 0313 - Deferred + Experimental 2017-11-15 Standards Track Standards @@ -28,6 +28,16 @@ &mwild; &ksmith; + + 0.7.0 + 2020-03-20 + mw + +

Add 'before-id' and 'after-id' fields, flipped pages, single-item retrieval and a new mandatory disco feature

+

Split preferences protocol into a separate document

+

Split the details of pubsub archives into a separate document

+
+
0.6.3 2018-07-16 @@ -176,9 +186,9 @@
  • The remote JID that the stanza is to (for an outgoing message) or from (for an incoming message).
  • A server-assigned UID that MUST be unpredictable and unique within the archive.
  • -
  • The message stanza itself. The entire original stanza SHOULD be stored, but at a - minimum only the &BODY; tag MUST be preserved (ie. the server might, at its - discretion, strip certain extensions from messages before storage).
  • +
  • The message stanza itself. The entire original stanza SHOULD be stored, but at a minimum only the &BODY; tag MUST + be preserved (ie. the server might, at its discretion, strip certain extensions from messages before storage), in + addition to all standard attributes of the stanza (e.g. to, from, type, id).
  • Note that 'incoming' and 'outgoing' messages are viewed within the context of the archived JID, rather than the system as a whole. For example, if romeo@montegue.lit sent a message to juliet@capulet.lit, it would be an outgoing message in the context of archiving for Romeo, and an incoming message in the context of archiving for Juliet.

    @@ -200,7 +210,7 @@ or cache that clients may keep.

    -

    There is no restriction on which services can expose archives, although only user, MUC and pubsub node archives are discussed here.

    +

    There is no restriction on which services can expose archives, although only user and MUC archives are discussed here.

    The most typical address is that of a user's own bare JID, within which those messages sent to or from that user's account would generally automatically be stored by the server. The collection @@ -211,9 +221,6 @@

    A MUC service allowing MAM queries for a room MUST expose the MAM archive on the room's bare JID

    - -

    A pubsub service allowing MAM queries for a node's data MUST expose this for queries addressed to the pubsub service

    -

    While this document talks about 'clients' and 'servers', as these are the common cases, the querying entity (referred to as a 'client') need not be an XMPP client as defined by RFC6120, but could potentially be any type of entity, and the queried entity (referred to as a 'server') need not be an XMPP server as defined by RFC6120, although access controls might prohibit any given entity from being able to access an archive.

    @@ -272,30 +279,36 @@ ]]>

    To ensure that the client knows when the results are complete, the server MUST send the &IQ; result after last query result has been sent to the client. The client can optionally include a 'queryid' attribute in their query, which allows the client to match results to their initiating query.

    -

    When querying a pubsub node's archive, the 'node' attribute is added to the <query> element.

    - - + ]]>

    By default all messages match a query, and filters are used to request a subset of the archived messages. Filters are specified in a &xep0004; data form included with the query. The hidden FORM_TYPE field - MUST be set to this protocol's namespace, 'urn:xmpp:mam:2'. Three further fields are defined by this + MUST be set to this protocol's namespace, 'urn:xmpp:mam:2'. Six further fields are defined by this XEP and MUST be supported by servers, though all of them are optional for the client. These fields are:

    • start
    • end
    • with
    • +
    • before-id (*)
    • +
    • after-id (*)
    • +
    • ids (*)
    + +

    Servers supporting fields marked with an asterisk (*) MUST advertise the disco feature 'urn:xmpp:mam:2#extended' and clients + that depend on these fields MUST verify that the server advertises this feature before attempting to use them.

    +

    Other fields may be used, but are not defined in this document - the naming of new fields MUST be consistent with the format defined in &xep0068;. Servers MUST NOT mark any fields in the form as being required (i.e. with the data forms <required/> element), regardless of whether they are defined in this document or elsewhere.

    If a 'with' field is present in the form, it contains a JID against which to match messages. The - server MUST only return messages if they match the supplied JID. A message in a user's archive matches if the JID matches either the to or from of the message. An item in a pubsub or MUC archive matches if the publisher of the item matches the JID; note that this should only be available to entities that would already have been allowed to know the publisher of the events (e.g. this could not be used by a visitor to a semi-anonymous MUC).

    -

    If the 'with' field's value is the bare JID of the archive, the server must only return results where both the 'to' and 'from' match the bare JID (either as bare or by ignoring the resource), as otherwise every message in the archive would match

    + server MUST only return messages if they match the supplied JID. A message in a user's archive matches if the JID matches either the to or from of the message. An item in a MUC archive matches if the publisher of the item matches the JID; note that this should only be available to entities that would already have been allowed to know the publisher of the events (e.g. this could not be used by a visitor to a semi-anonymous MUC).

    +

    To allow querying for messages the user sent to themselves, the client needs to set the 'with' attribute to the account JID. In that case, the server MUST only return results where both the 'to' and 'from' match the bare JID (either as bare or by ignoring the resource), as otherwise every message in the archive would match.

    If 'with' is omitted, the server MUST match all messages in the selected timespan with the query, regardless of the to/from addresses on each message.

    ]]>
    - -

    Finally, in order for the client or server to limit the number of results transmitted at - a time a server MUST support &xep0059; and MUST support the paging mechanism defined therein. - A client MAY include a <set/> element in its query.

    -

    For the purposes of this protocol, the UIDs used by RSM correspond with the UIDs of the - stanzas stored in the archive.

    - + +

    If the client has already seen some messages, it may choose to restrict its query to + before and/or after messages it already knows about. This may be done through the 'before-id' + and 'after-id' fields.

    + urn:xmpp:mam:2 - - 2010-08-07T00:00:00Z + + 09af3-cc343-b409f - - 10 - ]]> -

    To conserve resources, a server MAY place a reasonable limit on how many stanzas may be - pushed to a client in one request. Whether or not the client query included a <set/> element, the server MAY simply return - its limited results, modifying the <set/> element it returns appropriately.

    - - - - - 28482-98726-73623 - 09af3-cc343-b409f - 20 - - - - ]]> -

    The <first> and <last> elements specify the UID of the first and last returned - results (not necessarily of all the messages that matched the query, if the results have been limited).

    -

    The RSM <count> element and the 'index' attribute on the RSM <first> element are optional, - but servers SHOULD include them. Please refer to the RSM specification for more information - surrounding their meaning and use.

    -
    - -

    Having previously made a query that returned results limited by the server (as described above), a client - can re-send the same request and receive the next 'page' of results. It does this by including a <set> - element with its request, containing an <after/> with the UID of the last message it received - from the previous query.

    - + - - urn:xmpp:mam:2 - 2010-08-07T00:00:00Z - - - 10 - 09af3-cc343-b409f - + + + urn:xmpp:mam:2 + + + 28482-98726-73623 + + + 09af3-cc343-b409f + + ]]> -

    Note: There is no concept of an "open query", and servers MUST be prepared to receive arbitrary page requests at any time.

    -

    If the UID contained within an <after> or <before> element is not present in the archive, the server MUST return an item-not-found error in response to the query.

    -

    When the results returned by the server are complete (that is: when they have not been limited by the maximum size of the result page (either as specified or enforced by the server)), the server MUST include a 'complete' attribute on the <fin> element, with a value of 'true'; this informs the client that it doesn't need to perform further paging to retreive the requested data. If it is not the last page of the result set, the server MUST either omit the 'complete' attribute, or give it a value of 'false'.

    - - - - - 23452-4534-1 - 390-2342-22 - 16 - - + +

    If the client already knows the UID of one or more messages it wants to fetch, it can use + the 'ids' field:

    + + + + + + urn:xmpp:mam:2 + + + 28482-98726-73623 + + +
    ]]>
    -

    Sometimes (e.g. due to network or storage partitioning, or other transient errors) the server might return results to a client that are unstable (e.g. they might later change in sequence or content). In such a situation the server MUST stamp the <fin> element with a 'stable' attribute with a value of 'false'. If the server knows that the data it's serving are stable it MUST either stamp a 'stable' attribute with a value of 'true', or no such attribute. An example of when unstable might legitimately be returned is if the MAM service uses a clustered data store and a query covers a time period for which the data store has not yet converged; it the server could return best-guess results and tell the client that they may be unstable. A client SHOULD NOT cache unstable results long-term without later confirming (by reissuing appropriate queries) that they have become stable.

    + +

    If any UID requested by the client in any of the 'before-id', 'after-id' or 'ids' form fields, the server MUST return an item-not-found error in response to the query.

    +
    - -

    In order for the client find out about additional fields the server might support, it can send an iq stanza of type 'get' addressed to the archive like this:

    - +

    In order for the client find out about additional fields the server might support, it can send an iq stanza of type 'get' addressed to the archive like this:

    + ]]> -

    The server replies with all the form fields it supports in queries, which MUST include the mandatory fields specified in this document.

    - The server replies with all the form fields it supports in queries, which MUST include the mandatory fields specified in this document.

    + @@ -461,14 +451,23 @@ - - + + + + + + + + + ]]> -

    If the client understands any of the additional fields it MAY proceed to include any of them in subsequent queries. It is not required to include any or all of the supported fields in queries.

    - If the client understands any of the additional fields it MAY proceed to include any of them in subsequent queries. It is not required to include any or all of the supported fields in queries.

    +

    A special note about the 'ids' field: this field is of type 'list-multi' which typically is used to allow the client to select from a provided list of options. In this case the list of all possible ids MUST NOT be provided by the server, as it is likely to be extremely large. Instead the server MUST include a &xep0122; <validate/> element that signals the list is open to arbitrary values provided by the client.

    +

    As specified in &xep0068;, names of custom fields SHOULD use Clark notation to avoid conflicts with other extensions.

    + @@ -485,9 +484,11 @@ ]]> -

    Note that as the 'with', 'start' and 'end' fields MUST be implemented by servers, clients are able to submit forms using combinations of only these fields without needing to first fetch the form from the server and the types of these fields MUST be 'jid-single', 'text-single' and 'text-single' respectively. A server MUST NOT rely on a client having first requested the form before submitting queries

    -
    +

    Note that as the 'with', 'start' and 'end' fields MUST be implemented by servers, clients are able to submit forms using combinations of only these fields without needing to first fetch the form from the server and the types of these fields MUST be 'jid-single', 'text-single' and 'text-single' respectively. A server MUST NOT rely on a client having first requested the form before submitting queries

    +

    If a client includes a form field that the server does not recognise, the server MUST respond with a 'feature-not-implemented' error.

    +
    +

    The server responds to the archive query by transmitting to the client all the messages that match the criteria the client requested, subject to implementation limits. The results are sent as individual stanzas, @@ -534,6 +535,167 @@ ]]> + + + +

    A client or server will typically want to limit the number of results transmitted at + a time, thereby breaking the result stream into smaller 'pages'. For this purpose a + server MUST support &xep0059; and MUST support the paging mechanism defined therein. + A client MAY include a <set/> element in its query.

    +

    For the purposes of this protocol, the UIDs used by RSM correspond with the UIDs of the + stanzas stored in the archive.

    + + + + + urn:xmpp:mam:2 + + + 2010-08-07T00:00:00Z + + + + 10 + + + + ]]> +

    To conserve resources, a server MAY place a reasonable limit on how many stanzas may be + pushed to a client in one request. Whether or not the client query included a <set/> element, the server MAY simply return + its limited results, modifying the <set/> element it returns appropriately.

    + + + + + 28482-98726-73623 + 09af3-cc343-b409f + 20 + + + + ]]> + + +

    The <first> and <last> elements specify the UID of the first and last returned + results (not necessarily of all the messages that matched the query, if the results have been limited).

    + +

    The RSM <count> element and the 'index' attribute on the RSM <first> element are optional, + a server MAY include them, but a client MUST NOT depend on them being present. Please refer to the RSM + specification for more information surrounding their meaning and use.

    +

    Having previously made a query that returned results limited by the server (as described above), a client + can re-send the same request and receive the next 'page' of results. It does this by including a <set> + element with its request, containing an <after/> with the UID of the last message it received + from the previous query.

    + + + + urn:xmpp:mam:2 + 2010-08-07T00:00:00Z + + + 10 + 09af3-cc343-b409f + + + + ]]> +

    Note: There is no concept of an "open query", and servers MUST be prepared to receive arbitrary page requests at any time.

    +

    RSM does not define the behaviour of including both <before> and <after> in the same request. To retrieve a range of items between two known ids, use before-id and after-id in the query form instead.

    +

    If the UID contained within an <after> or <before> element is not present in the archive, the server MUST return an item-not-found error in response to the query.

    + + + + + + ]]> +

    When the results returned by the server are complete (that is: when they have not been limited by the maximum size of the result page (either as specified or enforced by the server)), the server MUST include a 'complete' attribute on the <fin> element, with a value of 'true'; this informs the client that it doesn't need to perform further paging to retreive the requested data. If it is not the last page of the result set, the server MUST either omit the 'complete' attribute, or give it a value of 'false'.

    + + + + + 23452-4534-1 + 390-2342-22 + 16 + + + + ]]> +

    Sometimes (e.g. due to network or storage partitioning, or other transient errors) the server might return results to a client that are unstable (e.g. they might later change in sequence or content). In such a situation the server MUST stamp the <fin> element with a 'stable' attribute with a value of 'false'. If the server knows that the data it's serving are stable it MUST either stamp a 'stable' attribute with a value of 'true', or no such attribute. An example of when unstable might legitimately be returned is if the MAM service uses a clustered data store and a query covers a time period for which the data store has not yet converged; it the server could return best-guess results and tell the client that they may be unstable. A client SHOULD NOT cache unstable results long-term without later confirming (by reissuing appropriate queries) that they have become stable.

    +
    + +

    To request the page at the end of the archive (i.e. the most recent messages), include just an empty <before/> element in the RSM part of the query. As defined by RSM, this will return the last page of the archive.

    + + + + urn:xmpp:mam:2 + 2010-08-07T00:00:00Z + + + 10 + + + + + ]]> +

    Within the returned page, all results are still in chronological order, that is, the first result you receive will be the oldest item in the page, and the last result you receive will be the last item in the archive.

    +
    + +

    When fetching a page, the client may prefer for the server to send the results within that page in reverse order. + For example, if a client implements a user interface that automatically fetches older messages as a user scrolls backward, + it may want to receive and display the newest messages first, instead of waiting for the whole page to be received.

    +

    A client wishing for a reversed page should include the <flip-page/> element in its query, like so:

    + + + + urn:xmpp:mam:2 + 2010-08-07T00:00:00Z + + + 10 + 09af3-cc343-b409f + + + + + ]]> +

    It is important to note that flipping a page does not affect what results are returned in response to the query. It only affects the + order in which they are transmitted from the server to the client.

    +

    A client that wishes to use flipped pages MUST ensure that the server advertises the 'urn:xmpp:mam:2#extended' feature.

    +
    +
    + + + + +

    When planning a query, a client may wish to learn the current state of the archive. This includes information about the first/last entries in the archive.

    + +

    When the archive advertises support for 'urn:xmpp:mam:2#extended' then the archive supports queries for this metadata via an iq of type 'get' to the + archive's address, with a <metadata/> payload in the 'urn:xmpp:mam:2' namespace.

    + + + + + ]]> + + + + + + + + ]]> + +

    The server response includes a <metadata/> element containing information about the archive. This element MUST include <start/> and <end/> + elements, which each have an 'id' and XEP-0082 formatted 'timestamp of the first and last messages in the archive respectively.

    @@ -592,42 +754,11 @@ ]]> - - -

    A PubSub service offering MAM SHOULD store each of the items published to each node. When responding to MAM requests it MUST construct the message stanza within the <forwarded> element in the same manner as the notifications sent to subscribers for the item, except that specifying the 'from' 'to' and 'id' attributes are OPTIONAL. Pubsub items must be returned one per message stanza (i.e. there MUST NOT be multiple <item> elements within the <items> element).

    - - - - - - - - - - Soliloquy - - To be, or not to be: that is the question: - Whether 'tis nobler in the mind to suffer - The slings and arrows of outrageous fortune, - Or to take arms against a sea of troubles, - And by opposing end them? - - - tag:denmark.lit,2003:entry-32397 - 2003-12-13T18:30:02Z - 2003-12-13T18:30:02Z - - - - - - - -]]>
    - + +

    This specification reserves the 'node' attribute of the <query> element for use with pubsub archives. Full details of using + this protocol to query pubsub node archives are documented in [FIXME: number to be assigned to xep-pubsub-mam].

    +

    The IDs used within an archive MUST be unique per item stored and MUST NOT be reused, even if the original item with a given ID has since been removed from the archive. If a server provides multiple archives (e.g. many user archives, or many MUC archives), the IDs do not need to be unique across all of these archives unless the server also allows a single query to be run across multiple archives (e.g. searching of all MUC rooms), discussion of which is beyond the scope of this document. These IDs are strings that servers may construct in any manner, and clients must treat as opaque strings (e.g. there is no requirement for them to be numeric, sequenced or GUIDs).

    @@ -640,160 +771,10 @@
    - -

    Depending on implementation and deployment policies, a server MAY allow the user to have control - over the server's archiving behaviour. This specification defines a basic protocol for this, and - also allows a server to offer more advanced configuration to a user.

    - -

    If the server supports and allows configuration of the preferences described below then it SHOULD implement the protocol defined - in this section. This allows the user to retrieve and configure the following preferences:

    -
      -
    • A list of JIDs that should always have messages to/from archived in the user's store.
    • -
    • A list of JIDs that should never have messages to/from archived in the user's store.
    • -
    • The default archiving behaviour (for JIDs in neither of the above lists).
    • -
    - - - -]]> - -

    The server replies with the user's current archiving preferences. The <prefs> element - MUST be present and contain the current default archiving policy. The <always> and <never> - MUST also be present (even if empty), and contain a list of JIDs enclosed in <jid> elements.

    - - - - - - - -]]> - -

    It is also possible that the server may respond with a stanza error, for example the standard - 'feature-not-implemented' (server does not support MAM configuration) defined in &rfc6120;.

    - - - - - - -]]> - -

    To update the preferences, the client can simply send an iq stanza with a type of 'set':

    - - - - - romeo@montague.lit - - - montague@montague.lit - - - -]]> -

    The server then replies with the applied preferences (note that due to server policies these - MAY be different to the preferences sent by the client):

    - - - - romeo@montague.lit - - - montague@montague.lit - - - -]]> - -

    It is also possible for the server to respond with an error, for example (but not limited to) - the standard 'feature-not-implemented' (the server does not support configuration of preferences), - 'forbidden' (the user is not authorized to change their preferences) or 'not-allowed' (the server - generally does not allow changing of configuration preferences).

    - - -

    If a JID is in neither the 'always archive' nor the 'never archive' list then whether it - is archived depends on this setting, the default. -

    -

    The 'default' attribute of the 'prefs' element MUST be one of the following values:

    -
      -
    • 'always' - all messages are archived by default.
    • -
    • 'never' - messages are never archived by default.
    • -
    • 'roster' - messages are archived only if the contact's bare JID is in the user's roster.
    • -
    -
    - -

    The <prefs/> element MAY contain an <always/> child element. If present, it - contains a list of <jid/> elements, each containing a single JID. The server SHOULD - archive any messages to/from this JID (see 'JID matching'). -

    -

    If missing from the preferences, <always/> SHOULD be assumed by the server to be an - empty list. -

    -
    - -

    The <prefs/> element MAY contain an <never/> child element. If present, it - contains a list of <jid/> elements, each containing a single JID. The server SHOULD - NOT archive any messages to/from this JID (see 'JID matching'). -

    -

    If missing from the preferences, <never/> SHOULD be assumed by the server to be an - empty list. -

    -
    -
    - -

    In addition to this protocol, a server MAY offer more advanced configuration to the user - through &xep0050;. Such an interface might, for example, allow the user to configure what - types of messages to store, or set a limit on how long messages should remain in the - archive.

    -

    If supported, such a configuration command SHOULD be presented on the well-defined - command node of "urn:xmpp:mam#configure".

    -
    - - -

    When comparing the message target JID against the user's roster (ie. when the user has - set default='roster') the comparison MUST use the bare target JID (that is, stripped of - any resource). -

    -

    For matching against entries in either the 'allow' or 'never' lists, for each listed - JID: -

    -
      -
    • If the listed JID contains a resource, compare against the target JID as-is.
    • -
    • If the listed JID has no resource (it is a bare JID) then first strip any resource - from the target JID prior to comparison. -
    • -
    -
    - -

    For outgoing messages, the server MUST use the value of the 'to' attribute as the target JID. -

    -
    - -

    For incoming messages, the server MUST use the value of the 'from' attribute as the target JID. -

    -
    -
    - -

    Clients can use &xep0334; for signaling that they do not wish some messages to be stored in the archive.

    - - V unir avtug'f pybnx gb uvqr zr sebz gurve fvtug - - - ]]> -
    -
    -

    If a server or other entity hosts archives and supports MAM queries, it MUST advertise - the 'urn:xmpp:mam:2' feature in response to &xep0030; requests made to archiving JIDs - (i.e. JIDs hosting an archive, such as users' bare JIDs): + the 'urn:xmpp:mam:2' and 'urn:xmpp:mam:2#extended' features in response to &xep0030; requests + made to archiving JIDs (i.e. JIDs hosting an archive, such as users' bare JIDs):

    @@ -806,10 +787,49 @@ ... + ... ]]> + +

    Servers advertising the 'urn:xmpp:mam:2#extended' feature MUST implement the 'before-id' and 'after-id' fields, as well as support for + flipped pages and single-item retrieval. The 'urn:xmpp:mam:2#extended' feature MUST NOT be advertised by a server without also advertising + 'urn:xmpp:mam:2'.

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Featureurn:xmpp:mam:2urn:xmpp:mam:2#extended
    Queries using 'with', 'start' and 'end'RequiredRequired
    Error responses for missing UIDsRequiredRequired
    Queries using 'before-id', 'after-id' or 'ids'-Required
    Page flipping-Required
    Archive metadata query-Required
    +
    @@ -843,7 +863,7 @@

    Many thanks to Dave Cridland, Kim Alvefur, Yann Leboulanger, Evgeny Khramtsov, Florian Schmaus, Lance Stout, - Waqas Hussain and Daniel Gultsch for their input and feedback on this specification.

    + Waqas Hussain, Daniel Gultsch, Philipp Hörist, Jonas Schäfer and Georg Lukas for their input and feedback on this specification.