Legacy vCard 2.1 and 3.0 serialization support
This commit is contained in:
@@ -7,7 +7,7 @@ edition = "2021"
|
||||
trc = { path = "../trc" }
|
||||
hashify = "0.2.6"
|
||||
quick-xml = "0.37.2"
|
||||
calcard = { version = "0.1", features = ["rkyv"] }
|
||||
calcard = { version = "0.1.1", features = ["rkyv"] }
|
||||
mail-parser = { version = "0.11", features = ["full_encoding", "rkyv"] }
|
||||
hyper = "1.6.0"
|
||||
rkyv = { version = "0.8.10", features = ["little_endian"] }
|
||||
@@ -15,7 +15,7 @@ chrono = { version = "0.4.40", features = ["serde"], optional = true }
|
||||
compact_str = "0.9.0"
|
||||
|
||||
[dev-dependencies]
|
||||
calcard = { version = "0.1", features = ["serde", "rkyv"] }
|
||||
calcard = { version = "0.1.1", features = ["serde", "rkyv"] }
|
||||
serde = { version = "1.0.217", features = ["derive"] }
|
||||
serde_json = "1.0.138"
|
||||
chrono = { version = "0.4.40", features = ["serde"] }
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
* SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-SEL
|
||||
*/
|
||||
|
||||
use calcard::vcard::VCardVersion;
|
||||
use compact_str::{CompactString, ToCompactString};
|
||||
use trc::Value;
|
||||
|
||||
@@ -40,6 +41,7 @@ pub struct RequestHeaders<'x> {
|
||||
pub content_type: Option<&'x str>,
|
||||
pub destination: Option<&'x str>,
|
||||
pub lock_token: Option<&'x str>,
|
||||
pub max_vcard_version: Option<VCardVersion>,
|
||||
pub overwrite_fail: bool,
|
||||
pub no_timezones: bool,
|
||||
pub ret: Return,
|
||||
|
||||
@@ -4,6 +4,8 @@
|
||||
* SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-SEL
|
||||
*/
|
||||
|
||||
use calcard::vcard::VCardVersion;
|
||||
|
||||
use crate::{Condition, Depth, If, RequestHeaders, ResourceState, Return, Timeout};
|
||||
|
||||
impl<'x> RequestHeaders<'x> {
|
||||
@@ -82,6 +84,23 @@ impl<'x> RequestHeaders<'x> {
|
||||
}
|
||||
return true;
|
||||
},
|
||||
"Accept" => {
|
||||
for value in value.split(',') {
|
||||
if value.trim().starts_with("text/vcard") {
|
||||
if let Some(version) = value.split_once("version=")
|
||||
.and_then(|(_, version)| VCardVersion::try_parse(version.trim())) {
|
||||
if let Some(max_vcard_version) = &mut self.max_vcard_version {
|
||||
if version > *max_vcard_version {
|
||||
*max_vcard_version = version;
|
||||
}
|
||||
} else {
|
||||
self.max_vcard_version = Some(version);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
},
|
||||
_ => {}
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user