Mercurial > libervia-pubsub
comparison sat_pubsub/mam.py @ 325:8d939378f023
mam: removed requestor in favor of mam_request.sender and recipient + fixed bad use of requestor instead of recipient in getItemsData
author | Goffi <goffi@goffi.org> |
---|---|
date | Fri, 08 Jan 2016 20:47:52 +0100 |
parents | 54d90c73b8b5 |
children | 5580f08c7b91 |
comparison
equal
deleted
inserted
replaced
324:e73e42b4f6ff | 325:8d939378f023 |
---|---|
59 else: | 59 else: |
60 exc = error.StanzaError(condition, text=msg) | 60 exc = error.StanzaError(condition, text=msg) |
61 | 61 |
62 raise exc | 62 raise exc |
63 | 63 |
64 def onArchiveRequest(self, mam_request, requestor): | 64 def onArchiveRequest(self, mam_request): |
65 """ | 65 """ |
66 | 66 |
67 @param mam_request: The MAM archive request. | 67 @param mam_request: The MAM archive request. |
68 @type mam_request: L{MAMQueryReques<wokkel.mam.MAMRequest>} | 68 @type mam_request: L{MAMQueryReques<wokkel.mam.MAMRequest>} |
69 | |
70 @param requestor: JID of the requestor. | |
71 @type requestor: L{JID<twisted.words.protocols.jabber.jid.JID>} | |
72 | 69 |
73 @return: A tuple with list of message data (id, element, data) and RSM element | 70 @return: A tuple with list of message data (id, element, data) and RSM element |
74 @rtype: C{tuple} | 71 @rtype: C{tuple} |
75 """ | 72 """ |
76 # FIXME: bad result ordering | 73 # FIXME: bad result ordering |
86 log.msg("MAM request without RSM limited to {}".format(const.VAL_RSM_MAX_DEFAULT)) | 83 log.msg("MAM request without RSM limited to {}".format(const.VAL_RSM_MAX_DEFAULT)) |
87 ext_data['rsm'] = rsm.RSMRequest(const.VAL_RSM_MAX_DEFAULT) | 84 ext_data['rsm'] = rsm.RSMRequest(const.VAL_RSM_MAX_DEFAULT) |
88 else: | 85 else: |
89 ext_data['rsm'] = mam_request.rsm | 86 ext_data['rsm'] = mam_request.rsm |
90 | 87 |
91 d = self.backend.getItemsData(mam_request.node, requestor, None, None, ext_data) | 88 d = self.backend.getItemsData(mam_request.node, mam_request.recipient, None, None, ext_data) |
92 | 89 |
93 def make_message(elt): | 90 def make_message(elt): |
94 # XXX: http://xmpp.org/extensions/xep-0297.html#sect-idp629952 (rule 3) | 91 # XXX: http://xmpp.org/extensions/xep-0297.html#sect-idp629952 (rule 3) |
95 message = domish.Element((const.NS_CLIENT, "message")) | 92 message = domish.Element((const.NS_CLIENT, "message")) |
96 event = message.addElement((pubsub.NS_PUBSUB_EVENT, "event")) | 93 event = message.addElement((pubsub.NS_PUBSUB_EVENT, "event")) |
113 if pep: | 110 if pep: |
114 # we need to send privileged message | 111 # we need to send privileged message |
115 # so me manage the sending ourself, and return | 112 # so me manage the sending ourself, and return |
116 # an empty msg_data list to avoid double sending | 113 # an empty msg_data list to avoid double sending |
117 for data in msg_data: | 114 for data in msg_data: |
118 self.forwardPEPMessage(mam_request, requestor, *data) | 115 self.forwardPEPMessage(mam_request, *data) |
119 msg_data = [] | 116 msg_data = [] |
120 return (msg_data, rsm_elt) | 117 return (msg_data, rsm_elt) |
121 | 118 |
122 d.addErrback(self._mapErrors) | 119 d.addErrback(self._mapErrors) |
123 d.addCallback(cb) | 120 d.addCallback(cb) |
124 return d | 121 return d |
125 | 122 |
126 def forwardPEPMessage(self, mam_request, requestor, id_, elt, date): | 123 def forwardPEPMessage(self, mam_request, id_, elt, date): |
127 msg = domish.Element((None, 'message')) | 124 msg = domish.Element((None, 'message')) |
128 msg['from'] = self.backend.privilege.server_jid.full() | 125 msg['from'] = self.backend.privilege.server_jid.full() |
129 msg['to'] = requestor.full() | 126 msg['to'] = mam_request.sender.full() |
130 result = msg.addElement((mam.NS_MAM, 'result')) | 127 result = msg.addElement((mam.NS_MAM, 'result')) |
131 if mam_request.query_id is not None: | 128 if mam_request.query_id is not None: |
132 result['queryid'] = mam_request.query_id | 129 result['queryid'] = mam_request.query_id |
133 result['id'] = id_ | 130 result['id'] = id_ |
134 forward = result.addElement((const.NS_FORWARD, 'forwarded')) | 131 forward = result.addElement((const.NS_FORWARD, 'forwarded')) |