summaryrefslogtreecommitdiff
path: root/users/app/models
diff options
context:
space:
mode:
authorAzul <azul@leap.se>2013-07-19 09:50:02 +0200
committerAzul <azul@leap.se>2013-07-24 10:55:51 +0200
commitdcaf6232dbd1131cdbd12ac5c2ef997979fd01ff (patch)
tree7b39b0bb5ab27989ee5d90ca29bd73ef3f47e203 /users/app/models
parent495c97fbf400ed44a1e64692f2c04d2155a326e7 (diff)
add keys to identity
Diffstat (limited to 'users/app/models')
-rw-r--r--users/app/models/identity.rb11
-rw-r--r--users/app/models/user.rb3
2 files changed, 13 insertions, 1 deletions
diff --git a/users/app/models/identity.rb b/users/app/models/identity.rb
index 4dff93a..b862590 100644
--- a/users/app/models/identity.rb
+++ b/users/app/models/identity.rb
@@ -6,6 +6,7 @@ class Identity < CouchRest::Model::Base
property :address, LocalEmail
property :destination, Email
+ property :keys, Hash
validate :unique_forward
validate :alias_available
@@ -14,6 +15,16 @@ class Identity < CouchRest::Model::Base
view :by_user_id
view :by_address_and_destination
view :by_address
+ view :pgp_key_by_email,
+ map: <<-EOJS
+ function(doc) {
+ if (doc.type != 'Identity') {
+ return;
+ }
+ emit(doc.address, doc.keys["pgp"]);
+ }
+ EOJS
+
end
protected
diff --git a/users/app/models/user.rb b/users/app/models/user.rb
index 62fb7ec..fb7f0aa 100644
--- a/users/app/models/user.rb
+++ b/users/app/models/user.rb
@@ -62,7 +62,8 @@ class User < CouchRest::Model::Base
def build_identity(attribs = {}, &block)
attribs.reverse_merge! user_id: self.id,
address: self.email_address,
- destination: self.email_address
+ destination: self.email_address,
+ keys: {}
Identity.new(attribs, &block)
end