diff sat/plugins/plugin_xep_0313.py @ 2760:3480d4fdf83a

plugins XEP-0060, XEP-0313: implemented Order-By protoXEP: new "order_by" key can be used in extra data, value can be, for now, "creation" or "modification".
author Goffi <goffi@goffi.org>
date Sun, 06 Jan 2019 17:36:51 +0100
parents bb6adaa580ee
children c4190d5340ab
line wrap: on
line diff
--- a/sat/plugins/plugin_xep_0313.py	Sun Jan 06 17:34:56 2019 +0100
+++ b/sat/plugins/plugin_xep_0313.py	Sun Jan 06 17:36:51 2019 +0100
@@ -162,6 +162,13 @@
         if form_args:
             mam_args["form"] = mam.buildForm(**form_args)
 
+        # we only set orderBy if we have other MAM args
+        # else we would make a MAM query while it's not expected
+        if u"order_by" in extra and mam_args:
+            order_by = extra.pop(u"order_by")
+            assert isinstance(order_by, list)
+            mam_args["orderBy"] = order_by
+
         return mam.MAMRequest(**mam_args) if mam_args else None
 
     def serialise(self, mam_response, data=None):