changeset 2819:fd45089b3a92

jp (message/mam): added missing RSM options
author Goffi <goffi@goffi.org>
date Fri, 01 Mar 2019 12:11:16 +0100
parents 9a7cb32836c6
children 7ab8684784c6
files sat_frontends/jp/cmd_message.py
diffstat 1 files changed, 15 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/sat_frontends/jp/cmd_message.py	Thu Feb 28 18:57:28 2019 +0100
+++ b/sat_frontends/jp/cmd_message.py	Fri Mar 01 12:11:16 2019 +0100
@@ -224,6 +224,16 @@
         self.parser.add_argument(
             "-m", "--max", dest="rsm_max", type=int, default=20,
             help=_(u"maximum number of items to retrieve, using RSM (default: 20))"))
+        rsm_page_group = self.parser.add_mutually_exclusive_group()
+        rsm_page_group.add_argument(
+            "-a", "--after", dest="rsm_after", type=base.unicode_decoder,
+            help=_(u"find page after this item"), metavar='ITEM_ID')
+        rsm_page_group.add_argument(
+            "-b", "--before", dest="rsm_before", type=base.unicode_decoder,
+            help=_(u"find page before this item"), metavar='ITEM_ID')
+        rsm_page_group.add_argument(
+            "--index", dest="rsm_index", type=int,
+            help=_(u"index of the page to retrieve"))
 
     def _sessionInfosGetCb(self, session_info, data, metadata):
         self.host.own_jid = jid.JID(session_info[u"jid"])
@@ -256,8 +266,11 @@
             extra[u"mam_end"] = float(self.args.mam_end)
         if self.args.mam_with is not None:
             extra[u"mam_with"] = self.args.mam_with
-        if self.args.rsm_max is not None:
-            extra[u"rsm_max"] = self.args.rsm_max
+        for suff in ('max', 'after', 'before', 'index'):
+            key = u'rsm_' + suff
+            value = getattr(self.args,key)
+            if value is not None:
+                extra[key] = unicode(value)
         self.host.bridge.MAMGet(
             self.args.service, data_format.serialise(extra), self.profile,
             callback=self._MAMGetCb, errback=self.errback)