v1.0.4
This commit is contained in:
+2
-1
@@ -14,6 +14,7 @@ use serde_json::{Value, json};
|
||||
|
||||
const CORE: &str = "urn:ietf:params:jmap:core";
|
||||
const MAIL: &str = "urn:ietf:params:jmap:mail";
|
||||
const SUBMISSION: &str = "urn:ietf:params:jmap:submission";
|
||||
const SIEVE: &str = "urn:ietf:params:jmap:sieve";
|
||||
const CONTACTS: &str = "urn:ietf:params:jmap:contacts";
|
||||
const CALENDARS: &str = "urn:ietf:params:jmap:calendars";
|
||||
@@ -110,7 +111,7 @@ fn verify_account(label: &str, user: &Jmap, account_id: &str, s: &SeedStats) {
|
||||
|
||||
let identities = user
|
||||
.call(
|
||||
&[CORE, MAIL],
|
||||
&[CORE, SUBMISSION],
|
||||
"Identity/get",
|
||||
account_id,
|
||||
json!({ "properties": ["id", "name"] }),
|
||||
|
||||
+26
-4
@@ -35,10 +35,11 @@ pub fn load_mbox(limit: usize) -> SeedResult<Vec<MboxMessage>> {
|
||||
for item in MessageIterator::new(reader) {
|
||||
let message = item.map_err(|e| SeedError::Resource(format!("mbox parse: {e}")))?;
|
||||
let received_at = message.internal_date() as i64;
|
||||
out.push(MboxMessage {
|
||||
raw: message.unwrap_contents(),
|
||||
received_at,
|
||||
});
|
||||
let raw = message.unwrap_contents();
|
||||
if !starts_with_header(&raw) {
|
||||
continue;
|
||||
}
|
||||
out.push(MboxMessage { raw, received_at });
|
||||
if out.len() >= limit {
|
||||
break;
|
||||
}
|
||||
@@ -49,6 +50,27 @@ pub fn load_mbox(limit: usize) -> SeedResult<Vec<MboxMessage>> {
|
||||
Ok(out)
|
||||
}
|
||||
|
||||
fn starts_with_header(raw: &[u8]) -> bool {
|
||||
let mut rest = raw;
|
||||
if rest.starts_with(b"From ") {
|
||||
match rest.iter().position(|b| *b == b'\n') {
|
||||
Some(nl) => rest = &rest[nl + 1..],
|
||||
None => return false,
|
||||
}
|
||||
}
|
||||
let line_end = rest.iter().position(|b| *b == b'\n').unwrap_or(rest.len());
|
||||
let line = &rest[..line_end];
|
||||
let Some(colon) = line.iter().position(|b| *b == b':') else {
|
||||
return false;
|
||||
};
|
||||
if colon == 0 {
|
||||
return false;
|
||||
}
|
||||
line[..colon]
|
||||
.iter()
|
||||
.all(|b| b.is_ascii_graphic() && *b != b':')
|
||||
}
|
||||
|
||||
fn read_dir_sorted(sub: &str, ext: &str) -> SeedResult<Vec<PathBuf>> {
|
||||
let dir = resources_dir().join(sub);
|
||||
let mut paths: Vec<PathBuf> = std::fs::read_dir(&dir)?
|
||||
|
||||
Reference in New Issue
Block a user