summaryrefslogtreecommitdiff
path: root/src/leap/mx
diff options
context:
space:
mode:
Diffstat (limited to 'src/leap/mx')
-rw-r--r--src/leap/mx/couchdbhelper.py11
-rw-r--r--src/leap/mx/mail_receiver.py12
2 files changed, 12 insertions, 11 deletions
diff --git a/src/leap/mx/couchdbhelper.py b/src/leap/mx/couchdbhelper.py
index b26a0d8..115ecbe 100644
--- a/src/leap/mx/couchdbhelper.py
+++ b/src/leap/mx/couchdbhelper.py
@@ -52,10 +52,10 @@ class ConnectedCouchDB(client.CouchDB):
:param str password: (optional) The password for authorization.
:type password: str
"""
- self.mail_couch_url = "http://%s:%s@%s:%s" % (username,
- password,
- host,
- port)
+ self._mail_couch_url = "http://%s:%s@%s:%s" % (username,
+ password,
+ host,
+ port)
client.CouchDB.__init__(self,
host,
port=port,
@@ -156,8 +156,9 @@ class ConnectedCouchDB(client.CouchDB):
which fails with CouchDBError if there was any error.
"""
# TODO: that should be implemented with paisley
+ url = self._mail_couch_url + "/user-%s" % (uuid,)
try:
- db = CouchDatabase(self._mail_couch_url, "user-%s" % (uuid,))
+ db = CouchDatabase.open_database(url, create=False)
return defer.succeed(db.put_doc(doc))
except Exception as e:
return defer.fail(CouchDBError(e.message))
diff --git a/src/leap/mx/mail_receiver.py b/src/leap/mx/mail_receiver.py
index 4554624..a9344c3 100644
--- a/src/leap/mx/mail_receiver.py
+++ b/src/leap/mx/mail_receiver.py
@@ -51,7 +51,7 @@ from zope.interface import implements
from leap.soledad.common.crypto import EncryptionSchemes
from leap.soledad.common.crypto import ENC_JSON_KEY
from leap.soledad.common.crypto import ENC_SCHEME_KEY
-from leap.soledad.common.couch import CouchDocument
+from leap.soledad.common.document import ServerDocument
from leap.keymanager import openpgp
@@ -170,7 +170,7 @@ class MailReceiver(Service):
:return: doc to sync with Soledad or None, None if something
went wrong.
- :rtype: CouchDocument
+ :rtype: ServerDocument
"""
if pubkey is None or len(pubkey) == 0:
log.msg("_encrypt_message: Something went wrong, here's all "
@@ -180,7 +180,7 @@ class MailReceiver(Service):
# find message's encoding
message_as_string = message.as_string()
- doc = CouchDocument(doc_id=str(pyuuid.uuid4()))
+ doc = ServerDocument(doc_id=str(pyuuid.uuid4()))
# store plain text if pubkey is not available
data = {'incoming': True, 'content': message_as_string}
@@ -213,14 +213,14 @@ class MailReceiver(Service):
@defer.inlineCallbacks
def _export_message(self, uuid, doc):
"""
- Given a UUID and a CouchDocument, it saves it directly in the
+ Given a UUID and a ServerDocument, it saves it directly in the
couchdb that serves as a backend for Soledad, in a db
accessible to the recipient of the mail.
:param uuid: the mail owner's uuid
:type uuid: str
- :param doc: CouchDocument that represents the email
- :type doc: CouchDocument
+ :param doc: ServerDocument that represents the email
+ :type doc: ServerDocument
:return: A Deferred which fires if it's ok to remove the message,
or fails otherwise