mirror of
https://github.com/lennart-k/rustical.git
synced 2025-12-14 05:52:19 +00:00
Add tracing and restructure the Cargo.tomls
This commit is contained in:
@@ -1,27 +1,24 @@
|
||||
[package]
|
||||
name = "rustical_caldav"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
version.workspace = true
|
||||
edition.workspace = true
|
||||
|
||||
[dependencies]
|
||||
actix-web = "4.9"
|
||||
actix-web-httpauth = "0.8"
|
||||
anyhow = { version = "1.0", features = ["backtrace"] }
|
||||
base64 = "0.22"
|
||||
futures-util = "0.3"
|
||||
quick-xml = { version = "0.36", features = [
|
||||
"serde",
|
||||
"serde-types",
|
||||
"serialize",
|
||||
] }
|
||||
roxmltree = "0.20"
|
||||
rustical_store = { path = "../store/" }
|
||||
rustical_dav = { path = "../dav/" }
|
||||
serde = { version = "1.0", features = ["serde_derive", "derive"] }
|
||||
serde_json = "1.0"
|
||||
tokio = { version = "1.40", features = ["sync", "full"] }
|
||||
async-trait = "0.1"
|
||||
thiserror = "1.0"
|
||||
strum = { version = "0.26", features = ["strum_macros", "derive"] }
|
||||
derive_more = { version = "1.0", features = ["from", "into"] }
|
||||
url = "2.5.2"
|
||||
anyhow = { workspace = true }
|
||||
actix-web = { workspace = true }
|
||||
async-trait = { workspace = true }
|
||||
thiserror = { workspace = true }
|
||||
quick-xml = { workspace = true }
|
||||
strum = { workspace = true }
|
||||
tracing = { workspace = true }
|
||||
tracing-actix-web = { workspace = true }
|
||||
futures-util = { workspace = true }
|
||||
derive_more = { workspace = true }
|
||||
actix-web-httpauth = { workspace = true }
|
||||
base64 = { workspace = true }
|
||||
serde = { workspace = true }
|
||||
tokio = { workspace = true }
|
||||
roxmltree = { workspace = true }
|
||||
url = { workspace = true }
|
||||
rustical_dav = { workspace = true }
|
||||
rustical_store = { workspace = true }
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
[package]
|
||||
name = "rustical_carddav"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
version.workspace = true
|
||||
edition.workspace = true
|
||||
|
||||
[dependencies]
|
||||
actix-web = "4.9"
|
||||
@@ -19,7 +19,7 @@ rustical_store = { path = "../store/" }
|
||||
rustical_dav = { path = "../dav/" }
|
||||
serde = { version = "1.0", features = ["serde_derive", "derive"] }
|
||||
serde_json = "1.0"
|
||||
tokio = { version = "1.40", features = ["sync", "full"] }
|
||||
tokio = { version = "1", features = ["sync", "full"] }
|
||||
async-trait = "0.1"
|
||||
thiserror = "1.0"
|
||||
strum = { version = "0.26", features = ["strum_macros", "derive"] }
|
||||
|
||||
@@ -1,23 +1,21 @@
|
||||
[package]
|
||||
name = "rustical_dav"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
version.workspace = true
|
||||
edition.workspace = true
|
||||
|
||||
[dependencies]
|
||||
actix-web = "4.9"
|
||||
anyhow = "1.0"
|
||||
async-trait = "0.1"
|
||||
futures-util = "0.3"
|
||||
quick-xml = { version = "0.36", features = [
|
||||
"serde",
|
||||
"serde-types",
|
||||
"serialize",
|
||||
] }
|
||||
rustical_store = { path = "../store/" }
|
||||
serde = { version = "1.0", features = ["derive"] }
|
||||
strum = "0.26"
|
||||
itertools = "0.13"
|
||||
thiserror = "1.0"
|
||||
roxmltree = "0.20"
|
||||
log = "0.4"
|
||||
derive_more = { version = "1.0.0", features = ["deref"] }
|
||||
actix-web = { workspace = true }
|
||||
anyhow = { workspace = true }
|
||||
async-trait = { workspace = true }
|
||||
futures-util = { workspace = true }
|
||||
quick-xml = { workspace = true }
|
||||
rustical_store = { workspace = true }
|
||||
serde = { workspace = true }
|
||||
strum = { workspace = true }
|
||||
thiserror = { workspace = true }
|
||||
roxmltree = { workspace = true }
|
||||
itertools = { workspace = true }
|
||||
log = { workspace = true }
|
||||
derive_more = { workspace = true }
|
||||
tracing = { workspace = true }
|
||||
tracing-actix-web = { workspace = true }
|
||||
|
||||
@@ -8,9 +8,10 @@ use crate::Error;
|
||||
use actix_web::web::Path;
|
||||
use actix_web::HttpRequest;
|
||||
use derive_more::derive::Deref;
|
||||
use log::debug;
|
||||
use rustical_store::auth::User;
|
||||
use serde::Deserialize;
|
||||
use tracing::instrument;
|
||||
use tracing_actix_web::RootSpan;
|
||||
|
||||
// This is not the final place for this struct
|
||||
#[derive(Deref)]
|
||||
@@ -38,12 +39,14 @@ struct PropfindElement {
|
||||
prop: PropfindType,
|
||||
}
|
||||
|
||||
#[instrument(parent = root_span.id(), skip(path_components, req, root_span))]
|
||||
pub async fn route_propfind<R: ResourceService>(
|
||||
path_components: Path<R::PathComponents>,
|
||||
body: String,
|
||||
req: HttpRequest,
|
||||
user: User,
|
||||
depth: Depth,
|
||||
root_span: RootSpan,
|
||||
) -> Result<
|
||||
MultistatusElement<
|
||||
PropstatWrapper<<R::Resource as Resource>::Prop>,
|
||||
@@ -51,8 +54,6 @@ pub async fn route_propfind<R: ResourceService>(
|
||||
>,
|
||||
R::Error,
|
||||
> {
|
||||
debug!("{body}");
|
||||
|
||||
let resource_service = R::new(&req, path_components.into_inner()).await?;
|
||||
|
||||
// A request body is optional. If empty we MUST return all props
|
||||
|
||||
@@ -94,7 +94,7 @@ impl<T1: Serialize, T2: Serialize> Responder for MultistatusElement<T1, T2> {
|
||||
if let Err(err) = self.serialize(ser) {
|
||||
return crate::Error::from(err).error_response();
|
||||
}
|
||||
debug!("Return multistatus:\n{output}");
|
||||
// debug!("Return multistatus:\n{output}");
|
||||
|
||||
HttpResponse::MultiStatus()
|
||||
.content_type(ContentType::xml())
|
||||
|
||||
@@ -1,30 +1,24 @@
|
||||
[package]
|
||||
name = "rustical_store"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
version.workspace = true
|
||||
edition.workspace = true
|
||||
|
||||
[dependencies]
|
||||
anyhow = { version = "1.0", features = ["backtrace"] }
|
||||
async-trait = "0.1"
|
||||
serde = { version = "1.0", features = ["derive", "rc"] }
|
||||
sha2 = "0.10"
|
||||
sqlx = { version = "0.8", features = [
|
||||
"sqlx-sqlite",
|
||||
"uuid",
|
||||
"chrono",
|
||||
"sqlite",
|
||||
"runtime-tokio",
|
||||
"migrate",
|
||||
] }
|
||||
tokio = { version = "1.40", features = ["sync", "full"] }
|
||||
toml = "0.8"
|
||||
ical = { version = "0.11", features = ["generator", "serde"] }
|
||||
chrono = { version = "0.4", features = ["serde"] }
|
||||
regex = "1.10"
|
||||
lazy_static = "1.5"
|
||||
rstest = "0.23"
|
||||
rstest_reuse = "0.7"
|
||||
thiserror = "1.0"
|
||||
password-auth = "1.0"
|
||||
actix-web = "4.9"
|
||||
actix-web-httpauth = "0.8"
|
||||
anyhow = { workspace = true }
|
||||
async-trait = { workspace = true }
|
||||
serde = { workspace = true }
|
||||
sha2 = { workspace = true }
|
||||
sqlx = { workspace = true }
|
||||
tokio = { workspace = true }
|
||||
toml = { workspace = true }
|
||||
ical = { workspace = true }
|
||||
chrono = { workspace = true }
|
||||
regex = { workspace = true }
|
||||
lazy_static = { workspace = true }
|
||||
rstest = { workspace = true }
|
||||
rstest_reuse = { workspace = true }
|
||||
thiserror = { workspace = true }
|
||||
password-auth = { workspace = true }
|
||||
actix-web = { workspace = true }
|
||||
actix-web-httpauth = { workspace = true }
|
||||
tracing = { workspace = true }
|
||||
|
||||
@@ -6,6 +6,7 @@ use async_trait::async_trait;
|
||||
use serde::Serialize;
|
||||
use sqlx::Transaction;
|
||||
use sqlx::{sqlite::SqliteConnectOptions, Pool, Sqlite, SqlitePool};
|
||||
use tracing::instrument;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct SqliteCalendarStore {
|
||||
@@ -77,6 +78,7 @@ async fn log_object_operation(
|
||||
|
||||
#[async_trait]
|
||||
impl CalendarStore for SqliteCalendarStore {
|
||||
#[instrument]
|
||||
async fn get_calendar(&self, principal: &str, id: &str) -> Result<Calendar, Error> {
|
||||
let cal = sqlx::query_as!(
|
||||
Calendar,
|
||||
@@ -91,6 +93,7 @@ impl CalendarStore for SqliteCalendarStore {
|
||||
Ok(cal)
|
||||
}
|
||||
|
||||
#[instrument]
|
||||
async fn get_calendars(&self, principal: &str) -> Result<Vec<Calendar>, Error> {
|
||||
let cals = sqlx::query_as!(
|
||||
Calendar,
|
||||
@@ -104,6 +107,7 @@ impl CalendarStore for SqliteCalendarStore {
|
||||
Ok(cals)
|
||||
}
|
||||
|
||||
#[instrument]
|
||||
async fn insert_calendar(&mut self, calendar: Calendar) -> Result<(), Error> {
|
||||
sqlx::query!(
|
||||
r#"INSERT INTO calendars (principal, id, displayname, description, "order", color, timezone)
|
||||
@@ -121,6 +125,7 @@ impl CalendarStore for SqliteCalendarStore {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[instrument]
|
||||
async fn update_calendar(
|
||||
&mut self,
|
||||
principal: String,
|
||||
@@ -147,6 +152,7 @@ impl CalendarStore for SqliteCalendarStore {
|
||||
}
|
||||
|
||||
// Does not actually delete the calendar but just disables it
|
||||
#[instrument]
|
||||
async fn delete_calendar(
|
||||
&mut self,
|
||||
principal: &str,
|
||||
@@ -175,6 +181,7 @@ impl CalendarStore for SqliteCalendarStore {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[instrument]
|
||||
async fn restore_calendar(&mut self, principal: &str, id: &str) -> Result<(), Error> {
|
||||
sqlx::query!(
|
||||
r"UPDATE calendars SET deleted_at = NULL WHERE (principal, id) = (?, ?)",
|
||||
@@ -186,6 +193,7 @@ impl CalendarStore for SqliteCalendarStore {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[instrument]
|
||||
async fn get_objects(&self, principal: &str, cid: &str) -> Result<Vec<CalendarObject>, Error> {
|
||||
sqlx::query_as!(
|
||||
CalendarObjectRow,
|
||||
@@ -200,6 +208,7 @@ impl CalendarStore for SqliteCalendarStore {
|
||||
.collect()
|
||||
}
|
||||
|
||||
#[instrument]
|
||||
async fn get_object(
|
||||
&self,
|
||||
principal: &str,
|
||||
@@ -218,6 +227,7 @@ impl CalendarStore for SqliteCalendarStore {
|
||||
.try_into()?)
|
||||
}
|
||||
|
||||
#[instrument]
|
||||
async fn put_object(
|
||||
&mut self,
|
||||
principal: String,
|
||||
@@ -244,6 +254,7 @@ impl CalendarStore for SqliteCalendarStore {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[instrument]
|
||||
async fn delete_object(
|
||||
&mut self,
|
||||
principal: &str,
|
||||
@@ -286,6 +297,7 @@ impl CalendarStore for SqliteCalendarStore {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[instrument]
|
||||
async fn restore_object(&mut self, principal: &str, cid: &str, uid: &str) -> Result<(), Error> {
|
||||
let mut tx = self.db.begin().await?;
|
||||
|
||||
@@ -310,6 +322,7 @@ impl CalendarStore for SqliteCalendarStore {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[instrument]
|
||||
async fn sync_changes(
|
||||
&self,
|
||||
principal: &str,
|
||||
|
||||
Reference in New Issue
Block a user