mirror of
https://github.com/stalwartlabs/mail-server.git
synced 2025-12-10 05:16:35 +08:00
JMAP: Fix ContactCard/CalendarEvent deletion (fixes #2308)
This commit is contained in:
parent
fec002cc00
commit
3338d16a24
5 changed files with 68 additions and 4 deletions
|
|
@ -430,7 +430,7 @@ impl CalendarEventSet for Server {
|
||||||
'destroy: for id in will_destroy {
|
'destroy: for id in will_destroy {
|
||||||
let document_id = id.document_id();
|
let document_id = id.document_id();
|
||||||
|
|
||||||
if !cache.has_container_id(&document_id) {
|
if !cache.has_item_id(&document_id) {
|
||||||
response.not_destroyed.append(id, SetError::not_found());
|
response.not_destroyed.append(id, SetError::not_found());
|
||||||
continue;
|
continue;
|
||||||
} else if id.is_synthetic() {
|
} else if id.is_synthetic() {
|
||||||
|
|
|
||||||
|
|
@ -275,7 +275,7 @@ impl ContactCardSet for Server {
|
||||||
'destroy: for id in will_destroy {
|
'destroy: for id in will_destroy {
|
||||||
let document_id = id.document_id();
|
let document_id = id.document_id();
|
||||||
|
|
||||||
if !cache.has_container_id(&document_id) {
|
if !cache.has_item_id(&document_id) {
|
||||||
response.not_destroyed.append(id, SetError::not_found());
|
response.not_destroyed.append(id, SetError::not_found());
|
||||||
continue;
|
continue;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -72,6 +72,10 @@ pub async fn test(params: &mut JMAPTest) {
|
||||||
JSCalendarProperty::<Id>::CalendarIds,
|
JSCalendarProperty::<Id>::CalendarIds,
|
||||||
[calendar1_id.as_str(), calendar2_id.as_str()].into_jmap_set(),
|
[calendar1_id.as_str(), calendar2_id.as_str()].into_jmap_set(),
|
||||||
);
|
);
|
||||||
|
let event_4 = test_jscalendar_4().with_property(
|
||||||
|
JSCalendarProperty::<Id>::CalendarIds,
|
||||||
|
[calendar1_id.as_str()].into_jmap_set(),
|
||||||
|
);
|
||||||
let response = account
|
let response = account
|
||||||
.jmap_create(
|
.jmap_create(
|
||||||
MethodObject::CalendarEvent,
|
MethodObject::CalendarEvent,
|
||||||
|
|
@ -86,6 +90,7 @@ pub async fn test(params: &mut JMAPTest) {
|
||||||
.clone()
|
.clone()
|
||||||
.with_property(JSCalendarProperty::<Id>::UseDefaultAlerts, true),
|
.with_property(JSCalendarProperty::<Id>::UseDefaultAlerts, true),
|
||||||
event_3.clone(),
|
event_3.clone(),
|
||||||
|
event_4,
|
||||||
],
|
],
|
||||||
Vec::<(&str, &str)>::new(),
|
Vec::<(&str, &str)>::new(),
|
||||||
)
|
)
|
||||||
|
|
@ -93,6 +98,21 @@ pub async fn test(params: &mut JMAPTest) {
|
||||||
let event_1_id = response.created(0).id().to_string();
|
let event_1_id = response.created(0).id().to_string();
|
||||||
let event_2_id = response.created(1).id().to_string();
|
let event_2_id = response.created(1).id().to_string();
|
||||||
let event_3_id = response.created(2).id().to_string();
|
let event_3_id = response.created(2).id().to_string();
|
||||||
|
let event_4_id = response.created(3).id().to_string();
|
||||||
|
|
||||||
|
// Destroy tmp event
|
||||||
|
assert_eq!(
|
||||||
|
account
|
||||||
|
.jmap_destroy(
|
||||||
|
MethodObject::CalendarEvent,
|
||||||
|
[event_4_id.as_str()],
|
||||||
|
Vec::<(&str, &str)>::new(),
|
||||||
|
)
|
||||||
|
.await
|
||||||
|
.destroyed()
|
||||||
|
.next(),
|
||||||
|
Some(event_4_id.as_str())
|
||||||
|
);
|
||||||
|
|
||||||
// Validate changes
|
// Validate changes
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
|
|
@ -771,6 +791,19 @@ pub fn test_jscalendar_3() -> Value {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn test_jscalendar_4() -> Value {
|
||||||
|
json!({
|
||||||
|
"duration": "PT1H",
|
||||||
|
"@type": "Event",
|
||||||
|
"description": "Tmp Event",
|
||||||
|
"updated": "2006-02-06T00:11:02Z",
|
||||||
|
"timeZone": "US/Eastern",
|
||||||
|
"start": "2006-01-02T10:00:00",
|
||||||
|
"title": "Tmp Event",
|
||||||
|
"uid": "tmp-event@example.com"
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
const TEST_ICAL_1: &str = r#"BEGIN:VCALENDAR
|
const TEST_ICAL_1: &str = r#"BEGIN:VCALENDAR
|
||||||
BEGIN:VEVENT
|
BEGIN:VEVENT
|
||||||
DTSTART;TZID=US/Eastern:20060102T100000
|
DTSTART;TZID=US/Eastern:20060102T100000
|
||||||
|
|
|
||||||
|
|
@ -62,6 +62,10 @@ pub async fn test(params: &mut JMAPTest) {
|
||||||
JSContactProperty::<Id>::AddressBookIds,
|
JSContactProperty::<Id>::AddressBookIds,
|
||||||
[book1_id.as_str(), book2_id.as_str()].into_jmap_set(),
|
[book1_id.as_str(), book2_id.as_str()].into_jmap_set(),
|
||||||
);
|
);
|
||||||
|
let tmp_contact = test_jscontact_4().with_property(
|
||||||
|
JSContactProperty::<Id>::AddressBookIds,
|
||||||
|
[book2_id.as_str()].into_jmap_set(),
|
||||||
|
);
|
||||||
let response = account
|
let response = account
|
||||||
.jmap_create(
|
.jmap_create(
|
||||||
MethodObject::ContactCard,
|
MethodObject::ContactCard,
|
||||||
|
|
@ -69,6 +73,7 @@ pub async fn test(params: &mut JMAPTest) {
|
||||||
sarah_contact.clone(),
|
sarah_contact.clone(),
|
||||||
carlos_contact.clone(),
|
carlos_contact.clone(),
|
||||||
acme_contact.clone(),
|
acme_contact.clone(),
|
||||||
|
tmp_contact,
|
||||||
],
|
],
|
||||||
Vec::<(&str, &str)>::new(),
|
Vec::<(&str, &str)>::new(),
|
||||||
)
|
)
|
||||||
|
|
@ -76,6 +81,21 @@ pub async fn test(params: &mut JMAPTest) {
|
||||||
let sarah_contact_id = response.created(0).id().to_string();
|
let sarah_contact_id = response.created(0).id().to_string();
|
||||||
let carlos_contact_id = response.created(1).id().to_string();
|
let carlos_contact_id = response.created(1).id().to_string();
|
||||||
let acme_contact_id = response.created(2).id().to_string();
|
let acme_contact_id = response.created(2).id().to_string();
|
||||||
|
let tmp_contact_id = response.created(3).id().to_string();
|
||||||
|
|
||||||
|
// Destroy tmp contact
|
||||||
|
assert_eq!(
|
||||||
|
account
|
||||||
|
.jmap_destroy(
|
||||||
|
MethodObject::ContactCard,
|
||||||
|
[tmp_contact_id.as_str()],
|
||||||
|
Vec::<(&str, &str)>::new(),
|
||||||
|
)
|
||||||
|
.await
|
||||||
|
.destroyed()
|
||||||
|
.next(),
|
||||||
|
Some(tmp_contact_id.as_str())
|
||||||
|
);
|
||||||
|
|
||||||
// Validate changes
|
// Validate changes
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
|
|
@ -1171,6 +1191,17 @@ fn test_jscontact_3() -> Value {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn test_jscontact_4() -> Value {
|
||||||
|
json!({
|
||||||
|
"@type": "Card",
|
||||||
|
"version": "1.0",
|
||||||
|
"kind": "individual",
|
||||||
|
"name": {
|
||||||
|
"@type": "Name",
|
||||||
|
"full": "Temporary Contact"
|
||||||
|
}})
|
||||||
|
}
|
||||||
|
|
||||||
const TEST_VCARD_1: &str = r#"BEGIN:VCARD
|
const TEST_VCARD_1: &str = r#"BEGIN:VCARD
|
||||||
VERSION:4.0
|
VERSION:4.0
|
||||||
UID:urn:uuid:f81d4fae-7dec-11d0-a765-00a0c91e6bf6
|
UID:urn:uuid:f81d4fae-7dec-11d0-a765-00a0c91e6bf6
|
||||||
|
|
|
||||||
|
|
@ -105,8 +105,8 @@ async fn jmap_tests() {
|
||||||
|
|
||||||
auth::limits::test(&mut params).await;
|
auth::limits::test(&mut params).await;
|
||||||
auth::oauth::test(&mut params).await;
|
auth::oauth::test(&mut params).await;
|
||||||
auth::quota::test(&mut params).await;*/
|
auth::quota::test(&mut params).await;
|
||||||
auth::permissions::test(¶ms).await;
|
auth::permissions::test(¶ms).await;*/
|
||||||
|
|
||||||
contacts::addressbook::test(&mut params).await;
|
contacts::addressbook::test(&mut params).await;
|
||||||
contacts::contact::test(&mut params).await;
|
contacts::contact::test(&mut params).await;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue