Add calendar color and description

This commit is contained in:
Lennart
2023-09-07 19:18:40 +02:00
parent 620dca2be2
commit f1112a3056
3 changed files with 37 additions and 12 deletions

View File

@@ -110,6 +110,7 @@ pub fn generate_propfind_calendar_response(
"getcontenttype",
"calendar-description",
"owner",
"calendar-color",
]
.iter(),
);
@@ -141,6 +142,22 @@ pub fn generate_propfind_calendar_response(
el.write_empty()?;
}
}
"calendar-color" => {
let el = writer.create_element("IC:calendar-color");
if let Some(color) = calendar.clone().color {
el.write_text_content(BytesText::new(&color))?;
} else {
el.write_empty()?;
}
}
"calendar-description" => {
let el = writer.create_element("C:calendar-description");
if let Some(description) = calendar.clone().description {
el.write_text_content(BytesText::new(&description))?;
} else {
el.write_empty()?;
}
}
"supported-calendar-component-set" => {
writer
.create_element("C:supported-calendar-component-set")
@@ -196,12 +213,15 @@ pub async fn route_propfind_calendar<A: CheckAuthentication, C: CalendarStore>(
)
.map_err(|_e| Error::InternalError)?;
let output = generate_multistatus(vec![Namespace::Dav, Namespace::CalDAV], |writer| {
writer.write_event(quick_xml::events::Event::Text(BytesText::from_escaped(
responses_string,
)))?;
Ok(())
})
let output = generate_multistatus(
vec![Namespace::Dav, Namespace::CalDAV, Namespace::ICal],
|writer| {
writer.write_event(quick_xml::events::Event::Text(BytesText::from_escaped(
responses_string,
)))?;
Ok(())
},
)
.map_err(|_e| Error::InternalError)?;
Ok(HttpResponse::MultiStatus()

View File

@@ -127,12 +127,15 @@ pub async fn route_propfind_principal<A: CheckAuthentication, C: CalendarStore>(
.map_err(|_e| Error::InternalError)?,
);
let output = generate_multistatus(vec![Namespace::Dav, Namespace::CalDAV], |writer| {
for response in responses {
writer.write_event(Event::Text(BytesText::from_escaped(response)))?;
}
Ok(())
})
let output = generate_multistatus(
vec![Namespace::Dav, Namespace::CalDAV, Namespace::ICal],
|writer| {
for response in responses {
writer.write_event(Event::Text(BytesText::from_escaped(response)))?;
}
Ok(())
},
)
.map_err(|_e| Error::InternalError)?;
println!("{}", &output);

View File

@@ -33,6 +33,8 @@ pub struct Calendar {
pub id: String,
pub name: Option<String>,
pub owner: String,
pub description: Option<String>,
pub color: Option<String>,
pub ics: String,
}