# HG changeset patch # User Goffi # Date 1664721964 -7200 # Node ID c41f37f1b51c85d0f2963f92e6c18444e5724154 # Parent 7a23db86ee65d5e01eef590e5a7d7e9cdfd02c40 mam: fix `complete` attribute setting in `onArchiveRequest` diff -r 7a23db86ee65 -r c41f37f1b51c sat_pubsub/mam.py --- a/sat_pubsub/mam.py Sun Oct 02 16:26:48 2022 +0200 +++ b/sat_pubsub/mam.py Sun Oct 02 16:46:04 2022 +0200 @@ -106,27 +106,21 @@ def cb(items_data_tuple): items_data, rsm_response = items_data_tuple msg_data = [] - rsm_elt = None attributes = {} + if rsm_response: + rsm_elt = rsm_response.toElement() + # XXX: we check if it is the last page using initial request data + # and RSM element data. In this case, we must have the "complete" + # attribute set to "true". + page_max = rsm_response.index + mam_request.rsm.max + if page_max >= rsm_response.count: + # the maximum items which can be displayed is equal to or above the + # total number of items, which means we are complete + attributes['complete'] = "true" + else: + rsm_elt = None for item_data in items_data: - if item_data.item.name == 'set' and item_data.item.uri == rsm.NS_RSM: - assert rsm_elt is None - rsm_elt = item_data.item - if rsm_elt.first: - # XXX: we check if it is the last page using initial request data - # and RSM element data. In this case, we must have the - # "complete" - # attribute set to "true". - page_max = int(rsm_elt.first['index']) + mam_request.rsm.max - count = int(str(rsm_elt.count)) - if page_max >= count: - # the maximum items which can be displayed is equal to or - # above the total number of items, which means we are complete - attributes['complete'] = "true" - else: - log.msg("WARNING: no element in RSM request: {xml}".format( - xml = rsm_elt.toXml().encode('utf-8'))) - elif item_data.item.name == 'item': + if item_data.item.name == 'item': msg_data.append([item_data.item['id'], make_message(item_data.item), item_data.created]) else: