summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--service/pixelated/config/app_factory.py3
-rw-r--r--service/pixelated/resources/keys_resource.py27
-rw-r--r--service/pixelated/resources/root_resource.py4
-rw-r--r--web-ui/app/js/mail_view/ui/recipients/recipient.js19
4 files changed, 51 insertions, 2 deletions
diff --git a/service/pixelated/config/app_factory.py b/service/pixelated/config/app_factory.py
index 8281ea97..8671eaa6 100644
--- a/service/pixelated/config/app_factory.py
+++ b/service/pixelated/config/app_factory.py
@@ -96,6 +96,7 @@ def stop_incoming_mail_fetcher(reactor_stop_function, leap_session):
def init_app(app, leap_home, leap_session):
leap_session.start_background_jobs()
+ keymanager = leap_session.nicknym.keymanager
soledad_querier = SoledadQuerier(soledad=leap_session.account._soledad)
@@ -110,7 +111,7 @@ def init_app(app, leap_home, leap_session):
MailboxIndexerListener.SEARCH_ENGINE = search_engine
InputMail.FROM_EMAIL_ADDRESS = leap_session.account_email()
- app.resource.initialize(soledad_querier, search_engine, mail_service, draft_service)
+ app.resource.initialize(soledad_querier, keymanager, search_engine, mail_service, draft_service)
register(signal=proto.SOLEDAD_DONE_DATA_SYNC,
callback=init_index_and_remove_dupes(querier=soledad_querier,
diff --git a/service/pixelated/resources/keys_resource.py b/service/pixelated/resources/keys_resource.py
new file mode 100644
index 00000000..f8affb73
--- /dev/null
+++ b/service/pixelated/resources/keys_resource.py
@@ -0,0 +1,27 @@
+from email.utils import parseaddr
+from leap.keymanager import OpenPGPKey
+from pixelated.resources import respond_json_deferred
+from twisted.internet.threads import deferToThread
+from twisted.web import server
+from twisted.web.resource import Resource
+
+
+class KeysResource(Resource):
+
+ def __init__(self, keymanager):
+ Resource.__init__(self)
+ self._keymanager = keymanager
+
+ def render_GET(self, request):
+ def finish_request(key):
+ respond_json_deferred(key.get_json(), request)
+
+ def key_not_found(_):
+ respond_json_deferred(None, request, status_code=404)
+
+ _, key_to_find = parseaddr(request.args.get('search')[0])
+ d = deferToThread(lambda: self._keymanager.get_key_from_cache(key_to_find, OpenPGPKey))
+ d.addCallback(finish_request)
+ d.addErrback(key_not_found)
+
+ return server.NOT_DONE_YET
diff --git a/service/pixelated/resources/root_resource.py b/service/pixelated/resources/root_resource.py
index 71fe1fce..b45bd00f 100644
--- a/service/pixelated/resources/root_resource.py
+++ b/service/pixelated/resources/root_resource.py
@@ -6,6 +6,7 @@ from pixelated.resources.mail_resource import MailResource
from pixelated.resources.mails_resource import MailsResource
from pixelated.resources.sync_info_resource import SyncInfoResource
from pixelated.resources.tags_resource import TagsResource
+from pixelated.resources.keys_resource import KeysResource
from twisted.web.resource import Resource
from twisted.web.static import File
@@ -21,8 +22,9 @@ class RootResource(Resource):
return self
return Resource.getChild(self, path, request)
- def initialize(self, querier, search_engine, mail_service, draft_service):
+ def initialize(self, querier, keymanager, search_engine, mail_service, draft_service):
self.putChild('assets', File(self._static_folder))
+ self.putChild('keys', KeysResource(keymanager))
self.putChild('attachment', AttachmentsResource(querier))
self.putChild('contacts', ContactsResource(search_engine))
self.putChild('features', FeaturesResource())
diff --git a/web-ui/app/js/mail_view/ui/recipients/recipient.js b/web-ui/app/js/mail_view/ui/recipients/recipient.js
index 004b9247..c14f36b2 100644
--- a/web-ui/app/js/mail_view/ui/recipients/recipient.js
+++ b/web-ui/app/js/mail_view/ui/recipients/recipient.js
@@ -32,6 +32,7 @@ define(
html.insertBefore(nodeToPrependTo.children().last());
var component = new this.constructor();
component.initialize(html, recipient);
+ component.attr.recipient = recipient;
return component;
};
@@ -47,6 +48,24 @@ define(
this.doUnselect = function () {
this.$node.find('.recipient-value').removeClass('selected');
};
+
+ this.discoverEncryption = function () {
+ this.$node.addClass('discorver-encryption');
+ var p = $.getJSON('/keys?search=' + this.attr.address).promise();
+ p.done(function () {
+ this.$node.addClass('encrypted');
+ this.$node.removeClass('discorver-encryption')
+ }.bind(this));
+ p.fail(function () {
+ this.$node.addClass('not-encrypted');
+ this.$node.removeClass('discorver-encryption')
+ }.bind(this));
+
+ };
+
+ this.after('initialize', function () {
+ this.discoverEncryption();
+ });
}
}
);