diff options
author | Victor Shyba <victor1984@riseup.net> | 2017-07-25 04:36:04 -0300 |
---|---|---|
committer | Victor Shyba <victor1984@riseup.net> | 2017-08-03 05:33:01 -0300 |
commit | 639d86626b8e519a966578b48b77c68f7076be35 (patch) | |
tree | 5d59b3fdb3b2251e35fa5d1655396623cba9be37 /src | |
parent | 2e490bf0887bbbd440497111981d7cb48bb6dae6 (diff) |
[bug] flag as PENDING during incoming creation
Clients will query for blobs flagged PENDING so they can start
processing. This commit adds flagging, but still in a hacky way as the
backend requires the flags as a json string inside a request. A refactor
to separate request handling from the backend itself will solve it in
the near future.
-- Related: #8874
Diffstat (limited to 'src')
-rw-r--r-- | src/leap/soledad/server/_incoming.py | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/leap/soledad/server/_incoming.py b/src/leap/soledad/server/_incoming.py index 187b6973..1d34f4f3 100644 --- a/src/leap/soledad/server/_incoming.py +++ b/src/leap/soledad/server/_incoming.py @@ -17,13 +17,16 @@ """ A twisted resource that saves externally delivered documents into user's db. """ +import json from twisted.web.server import NOT_DONE_YET from twisted.web.resource import Resource +from twisted.web.test.test_web import DummyRequest from ._config import get_config from io import BytesIO from leap.soledad.server._blobs import BlobsServerState from leap.soledad.common.couch.state import CouchServerState from leap.soledad.common.document import ServerDocument +from leap.soledad.common.blobs import Flags from leap.soledad.common.crypto import ENC_JSON_KEY from leap.soledad.common.crypto import ENC_SCHEME_KEY from leap.soledad.common.crypto import EncryptionSchemes @@ -65,6 +68,12 @@ class IncomingResource(Resource): preamble = self.formatter.preamble(raw_content, doc_id) request.content = BytesIO(preamble + raw_content) d = db.write_blob(uuid, doc_id, request, namespace='MX') + # FIXME: We really need to decouple request handling from the + # backend! This is very ugly, but will change when this refactor + # is done. + flagsReq = DummyRequest(['']) + flagsReq.content = BytesIO(json.dumps([Flags.PENDING])) + d.addCallback(lambda _: db.set_flags(uuid, doc_id, flagsReq, 'MX')) d.addCallback(lambda _: self._finish(request)) return NOT_DONE_YET |