From 7f7f602785305cbd1ec6ada70af59933443663a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Poisson?= Date: Sat, 5 Jan 2019 18:13:07 +0100 Subject: [PATCH] ProtoXEP Order-By: Changing items ordering in Pubsub and MAM --- xep-proto-order-by.xml | 251 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 251 insertions(+) create mode 100644 xep-proto-order-by.xml diff --git a/xep-proto-order-by.xml b/xep-proto-order-by.xml new file mode 100644 index 00000000..b11497a0 --- /dev/null +++ b/xep-proto-order-by.xml @@ -0,0 +1,251 @@ + + +%ents; +]> + + +
+ Order-By + This specification allows to change order of items retrieval in a Pubsub or MAM query + &LEGALNOTICE; + xxxx + ProtoXEP + Standards Track + Standards + Council + + XMPP Core + XEP-0060 + XEP-0313 + + + + NOT_YET_ASSIGNED + + Jérôme + Poisson + goffi@goffi.org + goffi@jabber.fr + + + 0.0.1 + 2019-01-05 + jp +

First draft.

+
+
+ + +

&xep0060; §6.5.7 allows to retrieve the "most recent items" and &xep0313; state in §3.1 that archives are ordered in "chrnological order". While this order is straighforward in general use cases, it is sometimes desirable to use a different order, for instance while using &xep0277;: a spell mistake correction should not bring an old blog post to the top of retrieved items.

+

This specification allows to explicitly change business logic to retrieve the items in a different order, in a similar way as the "ORDER BY" clause in SQL.

+
+ +
    +
  • an entity should be able to retrieve items by date of creation or by date of last modification (see below for definitions)
  • +
  • the specification should be extensible to allow new ordering
  • +
  • in case of conflict, a 2nd, 3rd, etc. level of ordering should be possible
  • +
+
+ +

In XEP-0060, there is no such thing as "updated item". This XEP changes the business logic as follow:

+
    +
  • Date of creation — date when the item has been published ONLY if the item has a new id (i.e. an id which was not already present in the node at the time of publication). If an item re-use an existing id, it overwrites the original item and the date of creation stay the date of creation of the original item
  • +
  • Date of modification — date when the item has been overwritten by a new item of the same id. If the item has never been overwritten, it is equal to the date of creation defined above.
  • +
+
+ + + +

Juliet wants to retrieve plays of his favorite writer, William Shakespeare. She wants to retrieve the 3 most recent ones by date of creation.

+

To do so, her client do a regular Pubsub request, but add the <order> element as a children of the <pubsub> element with a namespace of "urn:xmpp:order-by:0" and with a 'by' attribute equal to "creation".

+ + + + + + + ]]> +

Pubsub service then returns the 3 plays created the most recently, first one being the most recent

+ + + + + + Henry VIII + + + + + Tempest + + + + + Wintter's Tale + + + + + +]]> +
+ +

Juliet realize that there is a spelling mistake, it's "Winter's Tale" and not "Wintter's Tale". She fixes it by overwritting the item:

+ + + + + + Winter's Tale + + + + + +]]> +

To check that everything is alright, she request again the last 3 items, but this time by date of modification. To do so, he client proceed the same way as for date of creation, except that it uses the value "modification" for the 'by' attribute

+ + + + + + + ]]> +

Pubsub service returns again the 3 plays but the "Winter Tales" item has been overwritten recently, while the 2 others have never been overwritten, so it returns the items in the following order, with most recently modified item on top:

+ + + + + + Winter's Tale + + + + + Henry VIII + + + + + Tempest + + + + + +]]> +
+ +

With &xep0313; the logic is the same, but the <order> element is added as a child of the <query> element:

+ + + + + +]]> +

This way, filters can be used with specific ordering

+
+ +

The ordering can be reversed by using the mechanisms already provided by &xep0059;

+
+ +

This specification can be extended by further XEPs, proposing other kind of ordering in the 'by' attribute (e.g. ordering by filename for a file sharing service). But this is beyond the scope of this XEPs, and a client should not assume that other ordering than "creation" and "modification" are available without negociation.

+

In a similar way, the semantic described here could be re-used in other use cases as for Pubsub or MAM, but this would need to be detailed in a separate specification.

+
+
+ + +

If a server supports the "order by" protocol, it MUST report that fact by including a service discovery feature of "urn:xmpp:order-by:0" &NSNOTE; in response to a &xep0030; information request:

+ + + +]]> + + + ... + + ... + + +]]> +
+ + +

Several ordering elements may be used, this allow to solve next levels of ordering in case of conflicts. In this case, the first ordering (i.e. the top most <order> element) is the main one, the the second <order> element is used in case of conflict, then the next one if a new conflict happen and so on.

+

In case of conflict, if no new <order> element is specified, the item order is not guarented and is up to the implementation

+
+ + +

For implementations based on SQL databases, the "ORDER BY" clause can be used to easily implement this specification. Other kind of databases should have similar mechanisms

+
+ + +

+ This document introduces no additional security considerations above and + beyond those defined in the documents on which it depends. +

+
+ +

This document requires no interaction with &IANA;.

+
+ + +

This specification defines the following XML namespace:

+
    +
  • 'urn:xmpp:order-by:0'
  • +
+
+ + &NSVER; + +
+ + + + + + + + + + + + +]]> + +