mirror of
https://github.com/lennart-k/rustical.git
synced 2025-12-18 09:59:22 +00:00
Refactor: Rename uid to object_id
This commit is contained in:
@@ -22,8 +22,8 @@ pub async fn get_event<C: CalendarStore + ?Sized>(
|
||||
) -> Result<HttpResponse, Error> {
|
||||
let CalendarObjectPathComponents {
|
||||
principal,
|
||||
cid,
|
||||
uid,
|
||||
cal_id,
|
||||
object_id,
|
||||
} = path.into_inner();
|
||||
|
||||
if user.id != principal {
|
||||
@@ -34,7 +34,7 @@ pub async fn get_event<C: CalendarStore + ?Sized>(
|
||||
.store
|
||||
.read()
|
||||
.await
|
||||
.get_calendar(&principal, &cid)
|
||||
.get_calendar(&principal, &cal_id)
|
||||
.await?;
|
||||
if user.id != calendar.principal {
|
||||
return Ok(HttpResponse::Unauthorized().body(""));
|
||||
@@ -44,7 +44,7 @@ pub async fn get_event<C: CalendarStore + ?Sized>(
|
||||
.store
|
||||
.read()
|
||||
.await
|
||||
.get_object(&principal, &cid, &uid)
|
||||
.get_object(&principal, &cal_id, &object_id)
|
||||
.await?;
|
||||
|
||||
Ok(HttpResponse::Ok()
|
||||
@@ -64,8 +64,8 @@ pub async fn put_event<C: CalendarStore + ?Sized>(
|
||||
) -> Result<HttpResponse, Error> {
|
||||
let CalendarObjectPathComponents {
|
||||
principal,
|
||||
cid,
|
||||
uid,
|
||||
cal_id,
|
||||
object_id,
|
||||
} = path.into_inner();
|
||||
|
||||
if user.id != principal {
|
||||
@@ -76,7 +76,7 @@ pub async fn put_event<C: CalendarStore + ?Sized>(
|
||||
.store
|
||||
.read()
|
||||
.await
|
||||
.get_calendar(&principal, &cid)
|
||||
.get_calendar(&principal, &cal_id)
|
||||
.await?;
|
||||
if user.id != calendar.principal {
|
||||
return Ok(HttpResponse::Unauthorized().body(""));
|
||||
@@ -89,7 +89,7 @@ pub async fn put_event<C: CalendarStore + ?Sized>(
|
||||
|
||||
if Some(&HeaderValue::from_static("*")) == req.headers().get(header::IF_NONE_MATCH) {
|
||||
// Only write if not existing
|
||||
match store.get_object(&principal, &cid, &uid).await {
|
||||
match store.get_object(&principal, &cal_id, &object_id).await {
|
||||
Ok(_) => {
|
||||
// Conflict
|
||||
return Ok(HttpResponse::Conflict().body("Resource with this URI already exists"));
|
||||
@@ -104,8 +104,8 @@ pub async fn put_event<C: CalendarStore + ?Sized>(
|
||||
}
|
||||
}
|
||||
|
||||
let object = CalendarObject::from_ics(uid, body)?;
|
||||
store.put_object(principal, cid, object).await?;
|
||||
let object = CalendarObject::from_ics(object_id, body)?;
|
||||
store.put_object(principal, cal_id, object).await?;
|
||||
|
||||
Ok(HttpResponse::Created().body(""))
|
||||
}
|
||||
|
||||
@@ -16,8 +16,8 @@ pub struct CalendarObjectResourceService<C: CalendarStore + ?Sized> {
|
||||
pub cal_store: Arc<RwLock<C>>,
|
||||
pub path: String,
|
||||
pub principal: String,
|
||||
pub cid: String,
|
||||
pub uid: String,
|
||||
pub cal_id: String,
|
||||
pub object_id: String,
|
||||
}
|
||||
|
||||
#[derive(EnumString, Debug, VariantNames, Clone)]
|
||||
@@ -78,8 +78,8 @@ impl Resource for CalendarObjectResource {
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct CalendarObjectPathComponents {
|
||||
pub principal: String,
|
||||
pub cid: String,
|
||||
pub uid: String,
|
||||
pub cal_id: String,
|
||||
pub object_id: String,
|
||||
}
|
||||
|
||||
impl<'de> Deserialize<'de> for CalendarObjectPathComponents {
|
||||
@@ -94,8 +94,8 @@ impl<'de> Deserialize<'de> for CalendarObjectPathComponents {
|
||||
}
|
||||
Ok(Self {
|
||||
principal,
|
||||
cid: calendar,
|
||||
uid: object,
|
||||
cal_id: calendar,
|
||||
object_id: object,
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -113,8 +113,8 @@ impl<C: CalendarStore + ?Sized> ResourceService for CalendarObjectResourceServic
|
||||
) -> Result<Self, Self::Error> {
|
||||
let CalendarObjectPathComponents {
|
||||
principal,
|
||||
cid,
|
||||
uid,
|
||||
cal_id,
|
||||
object_id,
|
||||
} = path_components;
|
||||
|
||||
let cal_store = req
|
||||
@@ -126,8 +126,8 @@ impl<C: CalendarStore + ?Sized> ResourceService for CalendarObjectResourceServic
|
||||
Ok(Self {
|
||||
cal_store,
|
||||
principal,
|
||||
cid,
|
||||
uid,
|
||||
cal_id,
|
||||
object_id,
|
||||
path: req.path().to_string(),
|
||||
})
|
||||
}
|
||||
@@ -140,7 +140,7 @@ impl<C: CalendarStore + ?Sized> ResourceService for CalendarObjectResourceServic
|
||||
.cal_store
|
||||
.read()
|
||||
.await
|
||||
.get_object(&self.principal, &self.cid, &self.uid)
|
||||
.get_object(&self.principal, &self.cal_id, &self.object_id)
|
||||
.await?;
|
||||
Ok(event.into())
|
||||
}
|
||||
@@ -153,7 +153,7 @@ impl<C: CalendarStore + ?Sized> ResourceService for CalendarObjectResourceServic
|
||||
self.cal_store
|
||||
.write()
|
||||
.await
|
||||
.delete_object(&self.principal, &self.cid, &self.uid, use_trashbin)
|
||||
.delete_object(&self.principal, &self.cal_id, &self.object_id, use_trashbin)
|
||||
.await?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user