plugin XEP-0277: add encryption flag to MB data:
MB data are individually flagged with the new `encryption` key if they were e2ee, the key contain encryption metadata (for now, just the algorithm used). rel 380
This commit is contained in:
parent
7b9e785c13
commit
836a621a0b
1 changed files with 21 additions and 6 deletions
|
|
@ -20,7 +20,7 @@ import time
|
|||
import dateutil
|
||||
import calendar
|
||||
from secrets import token_urlsafe
|
||||
from typing import Optional, Dict, Union, Any
|
||||
from typing import List, Optional, Dict, Tuple, Union, Any, Dict
|
||||
from functools import partial
|
||||
|
||||
import shortuuid
|
||||
|
|
@ -33,7 +33,7 @@ from twisted.python import failure
|
|||
|
||||
# XXX: sat_tmp.wokkel.pubsub is actually used instead of wokkel version
|
||||
from wokkel import pubsub
|
||||
from wokkel import disco, iwokkel
|
||||
from wokkel import disco, iwokkel, rsm
|
||||
from zope.interface import implementer
|
||||
|
||||
from sat.core.i18n import _
|
||||
|
|
@ -1142,8 +1142,16 @@ class XEP_0277(object):
|
|||
d.addCallback(self._mbGetSerialise)
|
||||
return d
|
||||
|
||||
async def mbGet(self, client, service=None, node=None, max_items=10, item_ids=None,
|
||||
rsm_request=None, extra=None):
|
||||
async def mbGet(
|
||||
self,
|
||||
client: SatXMPPEntity,
|
||||
service: Optional[jid.JID] = None,
|
||||
node: Optional[str] = None,
|
||||
max_items: Optional[int] = 10,
|
||||
item_ids: Optional[List[str]] = None,
|
||||
rsm_request: Optional[rsm.RSMRequest] = None,
|
||||
extra: Optional[Dict[str, Any]] = None
|
||||
) -> Tuple[List[Dict[str, Any]], Dict[str, Any]]:
|
||||
"""Get some microblogs
|
||||
|
||||
@param service(jid.JID, None): jid of the publisher
|
||||
|
|
@ -1170,9 +1178,16 @@ class XEP_0277(object):
|
|||
rsm_request=rsm_request,
|
||||
extra=extra,
|
||||
)
|
||||
mb_data = await self._p.transItemsDataD(
|
||||
mb_data_list, metadata = await self._p.transItemsDataD(
|
||||
items_data, partial(self.item2mbdata, client, service=service, node=node))
|
||||
return mb_data
|
||||
encrypted = metadata.pop("encrypted", None)
|
||||
if encrypted is not None:
|
||||
for mb_data in mb_data_list:
|
||||
try:
|
||||
mb_data["encrypted"] = encrypted[mb_data["id"]]
|
||||
except KeyError:
|
||||
pass
|
||||
return (mb_data_list, metadata)
|
||||
|
||||
def _mbRename(self, service, node, item_id, new_id, profile_key):
|
||||
return defer.ensureDeferred(self.mbRename(
|
||||
|
|
|
|||
Loading…
Reference in a new issue