Merge pull request #1459 from matthiasbeyer/libimagcontact/email-properties
libimagcontact/imag-contact: Email properties
This commit is contained in:
commit
1dd5cb5565
4 changed files with 30 additions and 10 deletions
|
@ -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 {
|
||||
|
|
|
@ -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()));
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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 {
|
||||
|
@ -43,10 +63,6 @@ pub struct DeserVcard {
|
|||
#[serde(default)]
|
||||
clientpidmap : Option<String>,
|
||||
|
||||
#[serde(skip_serializing_if = "Vec::is_empty")]
|
||||
#[serde(default)]
|
||||
email : Vec<String>,
|
||||
|
||||
#[serde(skip_serializing_if = "Vec::is_empty")]
|
||||
#[serde(default)]
|
||||
fullname : Vec<String>,
|
||||
|
@ -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
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue