CardDAV GET + PUT

This commit is contained in:
mdecimus
2025-03-29 19:46:05 +01:00
parent 372f2bec70
commit 76f085ab7c
36 changed files with 1203 additions and 501 deletions

View File

@@ -18,13 +18,13 @@ use super::{ArchivedMailbox, Mailbox};
impl IndexableObject for Mailbox {
fn index_values(&self) -> impl Iterator<Item = IndexValue<'_>> {
[
IndexValue::Text {
IndexValue::Index {
field: Property::Name.into(),
value: self.name.to_lowercase().into(),
},
IndexValue::Text {
IndexValue::Index {
field: Property::Role.into(),
value: self.role.as_str().unwrap_or_default().into(),
value: self.role.as_str().into(),
},
IndexValue::Tag {
field: Property::Role.into(),
@@ -34,17 +34,17 @@ impl IndexableObject for Mailbox {
vec![]
},
},
IndexValue::U32 {
IndexValue::Index {
field: Property::ParentId.into(),
value: self.parent_id.into(),
},
IndexValue::U32 {
IndexValue::Index {
field: Property::SortOrder.into(),
value: self.sort_order,
value: self.sort_order.into(),
},
IndexValue::U32List {
IndexValue::IndexList {
field: Property::IsSubscribed.into(),
value: (&self.subscribers).into(),
value: self.subscribers.iter().map(Into::into).collect::<Vec<_>>(),
},
IndexValue::Acl {
value: (&self.acls).into(),
@@ -57,13 +57,13 @@ impl IndexableObject for Mailbox {
impl IndexableObject for &ArchivedMailbox {
fn index_values(&self) -> impl Iterator<Item = IndexValue<'_>> {
[
IndexValue::Text {
IndexValue::Index {
field: Property::Name.into(),
value: self.name.to_lowercase().into(),
},
IndexValue::Text {
IndexValue::Index {
field: Property::Role.into(),
value: self.role.as_str().unwrap_or_default().into(),
value: self.role.as_str().into(),
},
IndexValue::Tag {
field: Property::Role.into(),
@@ -73,22 +73,17 @@ impl IndexableObject for &ArchivedMailbox {
vec![]
},
},
IndexValue::U32 {
IndexValue::Index {
field: Property::ParentId.into(),
value: u32::from(self.parent_id).into(),
value: self.parent_id.into(),
},
IndexValue::U32 {
IndexValue::Index {
field: Property::SortOrder.into(),
value: self.sort_order.as_ref().map(u32::from),
value: self.sort_order.into(),
},
IndexValue::U32List {
IndexValue::IndexList {
field: Property::IsSubscribed.into(),
value: self
.subscribers
.iter()
.map(u32::from)
.collect::<Vec<_>>()
.into(),
value: self.subscribers.iter().map(Into::into).collect::<Vec<_>>(),
},
IndexValue::Acl {
value: self

View File

@@ -7,7 +7,6 @@
use common::{Server, storage::index::ObjectIndexBuilder};
use jmap_proto::types::{collection::Collection, property::Property};
use store::{
SerializeInfallible,
query::Filter,
write::{AlignedBytes, Archive, BatchBuilder},
};
@@ -36,7 +35,7 @@ impl SieveScriptActivate for Server {
.filter(
account_id,
Collection::SieveScript,
vec![Filter::eq(Property::IsActive, 1u32.serialize())],
vec![Filter::eq(Property::IsActive, vec![1u8])],
)
.await?
.results;

View File

@@ -12,13 +12,15 @@ use super::{ArchivedSieveScript, SieveScript};
impl IndexableObject for SieveScript {
fn index_values(&self) -> impl Iterator<Item = IndexValue<'_>> {
[
IndexValue::Text {
IndexValue::Index {
field: Property::Name.into(),
value: self.name.to_lowercase().into(),
},
IndexValue::U32 {
IndexValue::Index {
field: Property::IsActive.into(),
value: Some(self.is_active as u32),
value: if self.is_active { &[1u8] } else { &[0u8] }
.as_slice()
.into(),
},
IndexValue::Blob {
value: self.blob_hash.clone(),
@@ -34,13 +36,15 @@ impl IndexableAndSerializableObject for SieveScript {}
impl IndexableObject for &ArchivedSieveScript {
fn index_values(&self) -> impl Iterator<Item = IndexValue<'_>> {
[
IndexValue::Text {
IndexValue::Index {
field: Property::Name.into(),
value: self.name.to_lowercase().into(),
},
IndexValue::U32 {
IndexValue::Index {
field: Property::IsActive.into(),
value: Some(self.is_active as u32),
value: if self.is_active { &[1u8] } else { &[0u8] }
.as_slice()
.into(),
},
IndexValue::Blob {
value: (&self.blob_hash).into(),

View File

@@ -559,7 +559,7 @@ impl SieveScriptIngest for Server {
.filter(
account_id,
Collection::SieveScript,
vec![Filter::eq(Property::IsActive, 1u32.serialize())],
vec![Filter::eq(Property::IsActive, vec![1u8])],
)
.await
.caused_by(trc::location!())?

View File

@@ -12,25 +12,25 @@ use super::{ArchivedEmailSubmission, EmailSubmission};
impl IndexableObject for EmailSubmission {
fn index_values(&self) -> impl Iterator<Item = IndexValue<'_>> {
[
IndexValue::Text {
IndexValue::Index {
field: Property::UndoStatus.into(),
value: self.undo_status.as_index().into(),
},
IndexValue::U32 {
IndexValue::Index {
field: Property::EmailId.into(),
value: Some(self.email_id),
value: self.email_id.into(),
},
IndexValue::U32 {
IndexValue::Index {
field: Property::ThreadId.into(),
value: Some(self.thread_id),
value: self.thread_id.into(),
},
IndexValue::U32 {
IndexValue::Index {
field: Property::IdentityId.into(),
value: Some(self.identity_id),
value: self.identity_id.into(),
},
IndexValue::U64 {
IndexValue::Index {
field: Property::SendAt.into(),
value: Some(self.send_at),
value: self.send_at.into(),
},
]
.into_iter()
@@ -40,25 +40,25 @@ impl IndexableObject for EmailSubmission {
impl IndexableObject for &ArchivedEmailSubmission {
fn index_values(&self) -> impl Iterator<Item = IndexValue<'_>> {
[
IndexValue::Text {
IndexValue::Index {
field: Property::UndoStatus.into(),
value: self.undo_status.as_index().into(),
},
IndexValue::U32 {
IndexValue::Index {
field: Property::EmailId.into(),
value: Some(u32::from(self.email_id)),
value: self.email_id.into(),
},
IndexValue::U32 {
IndexValue::Index {
field: Property::ThreadId.into(),
value: Some(u32::from(self.thread_id)),
value: self.thread_id.into(),
},
IndexValue::U32 {
IndexValue::Index {
field: Property::IdentityId.into(),
value: Some(u32::from(self.identity_id)),
value: self.identity_id.into(),
},
IndexValue::U64 {
IndexValue::Index {
field: Property::SendAt.into(),
value: Some(u64::from(self.send_at)),
value: self.send_at.into(),
},
]
.into_iter()