summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Beyer <mail@beyermatthias.de>2018-04-28 13:46:52 +0200
committerGitHub <noreply@github.com>2018-04-28 13:46:52 +0200
commit1dd5cb55658ffc536c5b55a0a72776b760bae2cb (patch)
treeb69e17673d1ec56cad85c2527ec74d46a5a5c0ff
parentbfd536d3fb374cd1c7c492a40cee64206a10de4f (diff)
parent713621337f7f71e583e5a3ab2dd3d5a83040486f (diff)
downloadimag-1dd5cb55658ffc536c5b55a0a72776b760bae2cb.zip
imag-1dd5cb55658ffc536c5b55a0a72776b760bae2cb.tar.gz
Merge pull request #1459 from matthiasbeyer/libimagcontact/email-properties
libimagcontact/imag-contact: Email properties
-rw-r--r--bin/domain/imag-contact/src/main.rs2
-rw-r--r--bin/domain/imag-contact/src/util.rs2
-rw-r--r--lib/domain/libimagcontact/Cargo.toml2
-rw-r--r--lib/domain/libimagcontact/src/deser.rs34
4 files changed, 30 insertions, 10 deletions
diff --git a/bin/domain/imag-contact/src/main.rs b/bin/domain/imag-contact/src/main.rs
index 86c9845..06488e7 100644
--- a/bin/domain/imag-contact/src/main.rs
+++ b/bin/domain/imag-contact/src/main.rs
@@ -277,7 +277,7 @@ fn find(rt: &Runtime) {
};
let take = card.adr().iter().any(|a| str_contains_any(a, &grepstring))
- || card.email().iter().any(|a| str_contains_any(a, &grepstring))
+ || card.email().iter().any(|a| str_contains_any(&a.address, &grepstring))
|| card.fullname().iter().any(|a| str_contains_any(a, &grepstring));
if take {
diff --git a/bin/domain/imag-contact/src/util.rs b/bin/domain/imag-contact/src/util.rs
index 91e0078..6140994 100644
--- a/bin/domain/imag-contact/src/util.rs
+++ b/bin/domain/imag-contact/src/util.rs
@@ -45,7 +45,7 @@ pub fn build_data_object_for_handlebars<'a>(i: usize, vcard: &DeserVcard) -> BTr
data.insert("BDAY" , process_opt(vcard.bday()));
data.insert("CATEGORIES" , process_list(vcard.categories()));
data.insert("CLIENTPIDMAP" , process_opt(vcard.clientpidmap()));
- data.insert("EMAIL" , process_list(vcard.email()));
+ data.insert("EMAIL" , process_list(&vcard.email().iter().map(|a| a.address.clone()).collect()));
data.insert("FN" , process_list(vcard.fullname()));
data.insert("GENDER" , process_opt(vcard.gender()));
data.insert("GEO" , process_list(vcard.geo()));
diff --git a/lib/domain/libimagcontact/Cargo.toml b/lib/domain/libimagcontact/Cargo.toml
index d295248..c45979d 100644
--- a/lib/domain/libimagcontact/Cargo.toml
+++ b/lib/domain/libimagcontact/Cargo.toml
@@ -24,7 +24,7 @@ error-chain = "0.11"
log = "0.3"
toml = "0.4"
toml-query = "0.6"
-vobject = "0.4"
+vobject = "0.5"
uuid = "0.6"
serde = "1"
serde_derive = "1"
diff --git a/lib/domain/libimagcontact/src/deser.rs b/lib/domain/libimagcontact/src/deser.rs
index aa1dc80..4404414 100644
--- a/lib/domain/libimagcontact/src/deser.rs
+++ b/lib/domain/libimagcontact/src/deser.rs
@@ -17,8 +17,28 @@
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
//
+use std::collections::BTreeMap;
+
use vobject::vcard::Vcard;
+#[derive(Serialize, Deserialize, Debug)]
+pub struct Email {
+ pub address: String,
+
+ #[serde(skip_serializing_if = "BTreeMap::is_empty")]
+ #[serde(default)]
+ pub properties: BTreeMap<String, String>,
+}
+
+impl From<::vobject::vcard::Email> for Email {
+ fn from(voemail: ::vobject::vcard::Email) -> Self {
+ let address = voemail.raw().clone();
+ let properties = voemail.params().clone();
+
+ Email { address, properties }
+ }
+}
+
/// A type which can be build from a Vcard and be serialized.
#[derive(Serialize, Deserialize, Debug)]
pub struct DeserVcard {
@@ -45,10 +65,6 @@ pub struct DeserVcard {
#[serde(skip_serializing_if = "Vec::is_empty")]
#[serde(default)]
- email : Vec<String>,
-
- #[serde(skip_serializing_if = "Vec::is_empty")]
- #[serde(default)]
fullname : Vec<String>,
#[serde(skip_serializing_if = "Option::is_none")]
@@ -141,7 +157,11 @@ pub struct DeserVcard {
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(default)]
- version : Option<String>
+ version : Option<String>,
+
+ #[serde(skip_serializing_if = "Vec::is_empty")]
+ #[serde(default)]
+ email : Vec<Email>,
}
impl From<Vcard> for DeserVcard {
@@ -163,7 +183,7 @@ impl From<Vcard> for DeserVcard {
bday : optstr!(card.bday()),
categories : arystr!(card.categories()),
clientpidmap : optstr!(card.clientpidmap()),
- email : arystr!(card.email()),
+ email : card.email().into_iter().map(Email::from).collect::<Vec<Email>>(),
fullname : arystr!(card.fullname()),
gender : optstr!(card.gender()),
geo : arystr!(card.geo()),
@@ -214,7 +234,7 @@ impl DeserVcard {
self.clientpidmap.as_ref()
}
- pub fn email(&self) -> &Vec<String> {
+ pub fn email(&self) -> &Vec<Email> {
&self.email
}