Fix outputting tzid and alarm trigger
This commit is contained in:
parent
096db12c74
commit
77404d1642
7 changed files with 117 additions and 78 deletions
|
@ -10,8 +10,8 @@ where
|
|||
{
|
||||
for url in urls {
|
||||
let response = api_client
|
||||
.rest
|
||||
.post(api_client.base_url.join("apps/cookbook/import")?)
|
||||
.rest()
|
||||
.post(api_client.base_url().join("apps/cookbook/import")?)
|
||||
.json(&serde_json::json!({
|
||||
"url": url.as_ref(),
|
||||
}))
|
||||
|
|
|
@ -5,8 +5,8 @@ use {crate::api_client::ApiClient, crate::recipe, anyhow::Result};
|
|||
|
||||
pub async fn with(api_client: &ApiClient) -> Result<()> {
|
||||
let recipes = api_client
|
||||
.rest
|
||||
.get(api_client.base_url.join("apps/cookbook/api/recipes")?)
|
||||
.rest()
|
||||
.get(api_client.base_url().join("apps/cookbook/api/recipes")?)
|
||||
.send()
|
||||
.await?;
|
||||
println!("{:#?}", recipes.json::<Vec<recipe::Metadata>>().await?);
|
||||
|
|
|
@ -71,8 +71,8 @@ where
|
|||
|
||||
async fn get_all_recipes(api_client: &ApiClient) -> Result<HashMap<String, Rc<recipe::Recipe>>> {
|
||||
let metadata = api_client
|
||||
.rest
|
||||
.get(api_client.base_url.join("apps/cookbook/api/recipes")?)
|
||||
.rest()
|
||||
.get(api_client.base_url().join("apps/cookbook/api/recipes")?)
|
||||
.send()
|
||||
.await?
|
||||
.json::<Vec<recipe::Metadata>>()
|
||||
|
@ -80,10 +80,10 @@ async fn get_all_recipes(api_client: &ApiClient) -> Result<HashMap<String, Rc<re
|
|||
|
||||
let recipes = metadata.iter().map(|rm| async {
|
||||
let response = api_client
|
||||
.rest
|
||||
.rest()
|
||||
.get(
|
||||
api_client
|
||||
.base_url
|
||||
.base_url()
|
||||
.join(&format!("apps/cookbook/api/recipes/{id}", id = rm.id))
|
||||
.unwrap(),
|
||||
)
|
||||
|
@ -113,21 +113,22 @@ where
|
|||
let calendar_prototype: ics::ICalendar = ics::ICalendar::new(
|
||||
"2.0",
|
||||
format!(
|
||||
"-//{}//NONSGML {}//EN",
|
||||
"-//IDN {}//{} {}//EN",
|
||||
constants::VENDOR,
|
||||
env!("CARGO_PKG_NAME")
|
||||
env!("CARGO_PKG_NAME"),
|
||||
env!("CARGO_PKG_VERSION")
|
||||
),
|
||||
);
|
||||
|
||||
let dav_base = api_client
|
||||
.rest
|
||||
.head(api_client.base_url.join("/.well-known/caldav")?)
|
||||
.rest()
|
||||
.head(api_client.base_url().join("/.well-known/caldav")?)
|
||||
.send()
|
||||
.await?;
|
||||
|
||||
let calendar_url = dav_base.url().join(&format!(
|
||||
"calendars/{}/{}/",
|
||||
&api_client.username,
|
||||
&api_client.username(),
|
||||
calendar.to_lowercase().as_str().replace(" ", "-")
|
||||
))?;
|
||||
|
||||
|
@ -139,7 +140,7 @@ where
|
|||
cal.add_event(ev.into());
|
||||
|
||||
api_client
|
||||
.rest
|
||||
.rest()
|
||||
.put(url)
|
||||
.header("Content-Type", "text/calendar; charset=utf-8")
|
||||
.body(cal.to_string())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue