diff --git a/Cargo.lock b/Cargo.lock index 55420011..4280d02b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1861,6 +1861,7 @@ dependencies = [ "serde", "serde_json", "store", + "tokio", "tracing", "utils", ] diff --git a/crates/jmap-proto/Cargo.toml b/crates/jmap-proto/Cargo.toml index 127601ce..598068a9 100644 --- a/crates/jmap-proto/Cargo.toml +++ b/crates/jmap-proto/Cargo.toml @@ -13,3 +13,6 @@ serde = { version = "1.0", features = ["derive"]} ahash = { version = "0.8.0", features = ["serde"] } serde_json = { version = "1.0", features = ["raw_value"] } tracing = "0.1" + +[dev-dependencies] +tokio = { version = "1.23", features = ["full"] } diff --git a/crates/jmap-proto/src/request/parser.rs b/crates/jmap-proto/src/request/parser.rs index 52249796..6cb6c669 100644 --- a/crates/jmap-proto/src/request/parser.rs +++ b/crates/jmap-proto/src/request/parser.rs @@ -252,8 +252,101 @@ mod tests { } "#; + const TEST2: &str = r##" + { + "using": [ + "urn:ietf:params:jmap:submission", + "urn:ietf:params:jmap:mail", + "urn:ietf:params:jmap:core" + ], + "methodCalls": [ + [ + "Email/set", + { + "accountId": "c", + "create": { + "c37ee58b-e224-4799-88e6-1d7484e3b782": { + "mailboxIds": { + "9": true + }, + "subject": "test", + "from": [ + { + "name": "Foo", + "email": "foo@bar.com" + } + ], + "to": [ + { + "name": null, + "email": "bar@foo.com" + } + ], + "cc": [], + "bcc": [], + "replyTo": [ + { + "name": null, + "email": "foo@bar.com" + } + ], + "htmlBody": [ + { + "partId": "c37ee58b-e224-4799-88e6-1d7484e3b782", + "type": "text/html" + } + ], + "bodyValues": { + "c37ee58b-e224-4799-88e6-1d7484e3b782": { + "value": "

test email

", + "isEncodingProblem": false, + "isTruncated": false + } + }, + "header:User-Agent:asText": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/113.0" + } + } + }, + "c0" + ], + [ + "EmailSubmission/set", + { + "accountId": "c", + "create": { + "c37ee58b-e224-4799-88e6-1d7484e3b782": { + "identityId": "a", + "emailId": "#c37ee58b-e224-4799-88e6-1d7484e3b782", + "envelope": { + "mailFrom": { + "email": "foo@bar.com" + }, + "rcptTo": [ + { + "email": "bar@foo.com" + } + ] + } + } + }, + "onSuccessUpdateEmail": { + "#c37ee58b-e224-4799-88e6-1d7484e3b782": { + "mailboxIds/d": true, + "mailboxIds/9": null, + "keywords/$seen": true, + "keywords/$draft": null + } + } + }, + "c1" + ] + ] + } + "##; + #[test] fn parse_request() { - println!("{:?}", Request::parse(TEST.as_bytes(), 10, 1024)); + println!("{:?}", Request::parse(TEST.as_bytes(), 10, 10240)); + println!("{:?}", Request::parse(TEST2.as_bytes(), 10, 10240)); } } diff --git a/crates/store/src/lib.rs b/crates/store/src/lib.rs index e3010128..cffa92a4 100644 --- a/crates/store/src/lib.rs +++ b/crates/store/src/lib.rs @@ -346,6 +346,10 @@ impl ReadTransaction<'_> { unimplemented!("No backend selected") } + pub(crate) async fn get_quota(&self, _account_id: u32) -> crate::Result { + unimplemented!("No backend selected") + } + pub async fn refresh_if_old(&mut self) -> crate::Result<()> { unimplemented!("No backend selected") }