plugins XEP-0059, XEP-0060, XEP-0277, XEP-0313: better serialisation:
`data_format.serialise` is now used for `mbGet`, and RSM/MAM values are not transtyped to strings anymore. A serialised dict is now used, items are put in the `items` key. Comments handling has been refactored to use a list for the potentially multiple comments nodes. `rsm` data are now in a `rsm` key of the dict, and `mam` data are merged with other metadata.
This commit is contained in:
parent
282d2a93d9
commit
e03eb5bfcc
1 changed files with 153 additions and 166 deletions
|
|
@ -216,24 +216,6 @@ class XEP_0313(object):
|
|||
|
||||
return mam.MAMRequest(**mam_args) if mam_args else None
|
||||
|
||||
def serialise(self, mam_response, data=None):
|
||||
"""Serialise data for MAM
|
||||
|
||||
Key set in data can be:
|
||||
- mam_complete: a bool const indicating if all items have been received
|
||||
- mam_stable: a bool const which is False if items order may be changed
|
||||
All values are set as strings.
|
||||
@param mam_response(dict): response data to serialise
|
||||
@param data(dict, None): dict to update with mam_* data.
|
||||
If None, a new dict is created
|
||||
@return (dict): data dict
|
||||
"""
|
||||
if data is None:
|
||||
data = {}
|
||||
data["mam_complete"] = C.boolConst(mam_response['complete'])
|
||||
data["mam_stable"] = C.boolConst(mam_response['stable'])
|
||||
return data
|
||||
|
||||
def getMessageFromResult(self, client, mess_elt, mam_req, service=None):
|
||||
"""Extract usable <message/> from MAM query result
|
||||
|
||||
|
|
@ -345,8 +327,10 @@ class XEP_0313(object):
|
|||
service=service)
|
||||
mess_data = client.messageProt.parseMessage(fwd_message_elt)
|
||||
mess_list.append(client.messageGetBridgeArgs(mess_data))
|
||||
metadata = self._rsm.serialise(rsm_response)
|
||||
self.serialise(mam_response, metadata)
|
||||
metadata = {
|
||||
'rsm': self._rsm.response2dict(rsm_response),
|
||||
'mam': mam_response
|
||||
}
|
||||
return mess_list, metadata, client.profile
|
||||
|
||||
def _getArchives(self, service, extra_ser, profile_key):
|
||||
|
|
@ -354,8 +338,8 @@ class XEP_0313(object):
|
|||
@return: tuple with:
|
||||
- list of message with same data as in bridge.messageNew
|
||||
- response metadata with:
|
||||
- rsm data (rsm_first, rsm_last, rsm_count, rsm_index)
|
||||
- mam data (mam_complete, mam_stable)
|
||||
- rsm data (first, last, count, index)
|
||||
- mam data (complete, stable)
|
||||
- profile
|
||||
"""
|
||||
client = self.host.getClient(profile_key)
|
||||
|
|
|
|||
Loading…
Reference in a new issue