mirror of
https://github.com/lennart-k/rustical.git
synced 2025-12-13 19:22:26 +00:00
calendar import: Enable import to existing calendars (if no objects are overwritten)
This commit is contained in:
@@ -9,6 +9,7 @@ use ical::{
|
|||||||
generator::Emitter,
|
generator::Emitter,
|
||||||
parser::{Component, ComponentMut},
|
parser::{Component, ComponentMut},
|
||||||
};
|
};
|
||||||
|
use rustical_dav::header::Overwrite;
|
||||||
use rustical_ical::{CalendarObject, CalendarObjectType};
|
use rustical_ical::{CalendarObject, CalendarObjectType};
|
||||||
use rustical_store::{
|
use rustical_store::{
|
||||||
Calendar, CalendarMetadata, CalendarStore, SubscriptionStore, auth::Principal,
|
Calendar, CalendarMetadata, CalendarStore, SubscriptionStore, auth::Principal,
|
||||||
@@ -21,6 +22,7 @@ pub async fn route_import<C: CalendarStore, S: SubscriptionStore>(
|
|||||||
Path((principal, cal_id)): Path<(String, String)>,
|
Path((principal, cal_id)): Path<(String, String)>,
|
||||||
user: Principal,
|
user: Principal,
|
||||||
State(resource_service): State<CalendarResourceService<C, S>>,
|
State(resource_service): State<CalendarResourceService<C, S>>,
|
||||||
|
overwrite: Overwrite,
|
||||||
body: String,
|
body: String,
|
||||||
) -> Result<Response, Error> {
|
) -> Result<Response, Error> {
|
||||||
if !user.is_principal(&principal) {
|
if !user.is_principal(&principal) {
|
||||||
@@ -100,7 +102,9 @@ pub async fn route_import<C: CalendarStore, S: SubscriptionStore>(
|
|||||||
};
|
};
|
||||||
|
|
||||||
let cal_store = resource_service.cal_store;
|
let cal_store = resource_service.cal_store;
|
||||||
cal_store.import_calendar(new_cal, objects, false).await?;
|
cal_store
|
||||||
|
.import_calendar(new_cal, objects, overwrite.is_true())
|
||||||
|
.await?;
|
||||||
|
|
||||||
Ok(StatusCode::OK.into_response())
|
Ok(StatusCode::OK.into_response())
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user