Files
inbuxa-server/crates/imap/src/op/mod.rs
T
jcoffey-dev 6a53d47106 Mark the files this fork changed (AGPL section 5(a))
The AGPL asks a modified version to carry prominent notices saying it was
modified, and giving a date. Publishing the source is the conveyance that
asks for it, so it wants doing before the repository is public rather than
at the release.

Every upstream file the fork changed now says so in its header, beneath the
notice it came with: 164 files, found by diffing against the upstream
snapshot branch rather than by guessing, so the list is what actually
differs. Files the fork wrote itself already carry their own copyright and
need nothing. Upstream's notices are untouched, which its licence requires
and which was already true.

The README says the same thing in prose, since the obligation is on the
work as a whole and not only its Rust files.

Builds unchanged: the server and the test binary both compile.
2026-09-19 23:48:35 -07:00

104 lines
2.3 KiB
Rust

/*
* SPDX-FileCopyrightText: 2020 Stalwart Labs LLC <[email protected]>
*
* SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-SEL
*
* Modified by Coffey Labs in 2026 for INBUXA.
*/
use ::store::query::log::Query;
use imap_proto::ResponseCode;
pub mod acl;
pub mod append;
pub mod authenticate;
pub mod capability;
pub mod close;
pub mod copy_move;
pub mod create;
pub mod delete;
pub mod enable;
pub mod expunge;
pub mod fetch;
pub mod idle;
pub mod list;
pub mod login;
pub mod logout;
pub mod namespace;
pub mod noop;
pub mod quota;
pub mod rename;
pub mod search;
pub mod select;
pub mod status;
pub mod store;
pub mod subscribe;
pub mod thread;
pub mod uidbatches;
trait FromModSeq {
fn from_modseq(modseq: u64) -> Self;
}
trait ToModSeq {
fn to_modseq(&self) -> u64;
}
impl FromModSeq for Query {
fn from_modseq(modseq: u64) -> Self {
if modseq > 0 {
Query::Since(modseq - 1)
} else {
Query::All
}
}
}
impl ToModSeq for u64 {
fn to_modseq(&self) -> u64 {
if *self > 0 { *self + 1 } else { 0 }
}
}
#[macro_export]
macro_rules! spawn_op {
($data:expr, $($code:tt)*) => {
{
// inbuxa: ST-6: the operation keeps its read scope
tokio::spawn(store::backend::scaleout::replica::carry(async move {
let data = &($data);
if let Err(err) = (async {
$($code)*
})
.await
{
let _ = data.write_error(err).await;
}
}));
Ok(())}
};
}
pub trait ImapContext<T> {
fn imap_ctx(self, tag: &str, location: &'static str) -> trc::Result<T>;
}
impl<T> ImapContext<T> for trc::Result<T> {
fn imap_ctx(self, tag: &str, location: &'static str) -> trc::Result<T> {
match self {
Ok(value) => Ok(value),
Err(err) => Err(
if !err.matches(trc::EventType::Imap(trc::ImapEvent::Error)) {
err.ctx(trc::Key::Id, tag.to_string())
.ctx(trc::Key::Details, "Internal Server Error")
.ctx(trc::Key::Code, ResponseCode::ContactAdmin)
.ctx(trc::Key::CausedBy, location)
} else {
err.ctx(trc::Key::Id, tag.to_string())
},
),
}
}
}