RFC9698 - JMAPACCESS Extension for IMAP

This commit is contained in:
mdecimus 2025-05-16 16:44:37 +02:00
parent 10bb4e5661
commit cee4149ef4
15 changed files with 18 additions and 24 deletions

View file

@ -1019,9 +1019,7 @@ impl Iterator for Mailbox {
internal_date: m.internal_date(),
contents: m.unwrap_contents(),
})
.map_err(|_| {
io::Error::new(io::ErrorKind::Other, "Failed to parse from mbox file.")
})
.map_err(|_| std::io::Error::other("Failed to parse from mbox file."))
}),
Mailbox::Maildir(it) => it.next().map(|r| {
r.map(|m| Message {

View file

@ -347,7 +347,7 @@ async fn https(
}
fn get_header(response: &Response, header: &'static str) -> trc::Result<String> {
match response.headers().get_all(header).iter().last() {
match response.headers().get_all(header).iter().next_back() {
Some(value) => Ok(value
.to_str()
.map_err(|err| trc::EventType::Acme(trc::AcmeEvent::Error).from_http_str_error(err))?

View file

@ -258,8 +258,7 @@ impl Subscriber {
#[cfg(all(unix, not(target_os = "linux")))]
fn send_large_payload(&self, _payload: &[u8]) -> io::Result<usize> {
Err(io::Error::new(
io::ErrorKind::Other,
Err(std::io::Error::other(
"Large payloads not supported on non-Linux OS",
))
}

View file

@ -602,7 +602,7 @@ impl PrincipalSet {
pub fn has_int_value(&self, key: PrincipalField, value: u64) -> bool {
self.fields.get(&key).is_some_and(|v| match v {
PrincipalValue::Integer(v) => *v == value,
PrincipalValue::IntegerList(l) => l.iter().any(|v| *v == value),
PrincipalValue::IntegerList(l) => l.contains(&value),
PrincipalValue::String(_) | PrincipalValue::StringList(_) => false,
})
}

View file

@ -52,6 +52,7 @@ pub enum Capability {
Quota,
QuotaResource(QuotaResourceName),
QuotaSet,
JmapAccess,
}
/*
@ -126,6 +127,7 @@ impl Capability {
return;
}
Capability::QuotaSet => b"QUOTA=SET",
Capability::JmapAccess => b"JMAPACCESS",
});
}
@ -138,6 +140,7 @@ impl Capability {
Capability::LiteralPlus,
Capability::Id,
Capability::Utf8Accept,
Capability::JmapAccess,
];
if is_authenticated {

View file

@ -500,12 +500,12 @@ impl<T: SessionStream> SessionData<T> {
}
Attribute::EmailId => {
items.push(DataItem::EmailId {
email_id: Id::from_parts(account_id, id).to_string(),
email_id: Id::from_parts(data.thread_id, id).to_string(),
});
}
Attribute::ThreadId => {
items.push(DataItem::ThreadId {
thread_id: Id::from_parts(account_id, data.thread_id).to_string(),
thread_id: Id::from_parts(0, data.thread_id).to_string(),
});
}
}

View file

@ -192,8 +192,7 @@ impl<T: SessionStream> SessionData<T> {
items_response.push((
*item,
StatusItemType::String(
Id::from_parts(mailbox.account_id, mailbox.mailbox_id)
.to_string(),
Id::from_parts(0, mailbox.mailbox_id).to_string(),
),
));
}

View file

@ -85,8 +85,7 @@ impl BlobOperations for Server {
} else {
range_to
};
let bytes_range = bytes.get(range_from..range_to).unwrap_or_default();
bytes_range
bytes.get(range_from..range_to).unwrap_or_default()
};
for property in &properties {

View file

@ -392,11 +392,7 @@ impl<T: SessionStream> Session<T> {
let now = SystemTime::now()
.duration_since(SystemTime::UNIX_EPOCH)
.map_or(0, |d| d.as_secs());
if from.hold_until > now {
from.hold_until - now
} else {
0
}
from.hold_until.saturating_sub(now)
};
if hold_for <= max_hold {
self.data.future_release = hold_for;

View file

@ -604,6 +604,7 @@ impl SmtpClient<TlsStream<TcpStream>> {
}
}
#[allow(clippy::large_enum_variant)]
pub enum StartTlsResult {
Success {
smtp_client: SmtpClient<TlsStream<TcpStream>>,

View file

@ -321,7 +321,7 @@ impl io::Write for SerializedSize {
self.bytes_left -= buf_len;
Ok(buf_len)
} else {
Err(io::Error::new(io::ErrorKind::Other, "Size exceeded"))
Err(io::Error::other("Size exceeded"))
}
}

View file

@ -193,7 +193,7 @@ impl AzureStore {
fn build_key(&self, key: &[u8]) -> String {
if let Some(prefix) = &self.prefix {
let mut writer =
Base32Writer::with_raw_capacity(prefix.len() + ((key.len() + 3) / 4 * 5));
Base32Writer::with_raw_capacity(prefix.len() + (key.len().div_ceil(4) * 5));
writer.push_string(prefix);
writer.write_all(key).unwrap();
writer.finalize()

View file

@ -174,8 +174,7 @@ impl MysqlStore {
result.push_counter_id(
trx.exec_first::<i64, _, _>(&s, ()).await?.ok_or_else(|| {
mysql_async::Error::Io(mysql_async::IoError::Io(
std::io::Error::new(
std::io::ErrorKind::Other,
std::io::Error::other(
"LAST_INSERT_ID() did not return a value",
),
))

View file

@ -179,7 +179,7 @@ impl S3Store {
fn build_key(&self, key: &[u8]) -> String {
if let Some(prefix) = &self.prefix {
let mut writer =
Base32Writer::with_raw_capacity(prefix.len() + ((key.len() + 3) / 4 * 5));
Base32Writer::with_raw_capacity(prefix.len() + (key.len().div_ceil(4) * 5));
writer.push_string(prefix);
writer.write_all(key).unwrap();
writer.finalize()

View file

@ -40,7 +40,7 @@ impl Base32Writer {
}
pub fn with_capacity(capacity: usize) -> Self {
Self::with_raw_capacity((capacity + 3) / 4 * 5)
Self::with_raw_capacity(capacity.div_ceil(4) * 5)
}
pub fn with_raw_capacity(capacity: usize) -> Self {