aerogramme/src/imap/command/selected.rs

50 lines
1.4 KiB
Rust
Raw Normal View History

2022-06-22 15:26:52 +00:00
use anyhow::{Error, Result};
2022-06-29 10:50:44 +00:00
use boitalettres::proto::Request;
2022-06-20 16:09:20 +00:00
use boitalettres::proto::Response;
use imap_codec::types::command::CommandBody;
use imap_codec::types::core::Tag;
use imap_codec::types::fetch_attributes::MacroOrFetchAttributes;
use imap_codec::types::response::{Response as ImapRes, Status};
use imap_codec::types::sequence::SequenceSet;
use crate::imap::command::authenticated;
2022-06-22 15:25:04 +00:00
use crate::imap::flow;
2022-06-22 15:26:52 +00:00
use crate::imap::session::InnerContext;
2022-06-27 14:56:20 +00:00
use crate::mail::Mailbox;
2022-06-20 16:09:20 +00:00
2022-06-29 10:50:44 +00:00
pub struct SelectedContext<'a> {
pub req: &'a Request,
pub user: &'a flow::User,
pub mailbox: &'a mut Mailbox,
}
2022-06-22 15:25:04 +00:00
2022-06-29 10:50:44 +00:00
pub async fn dispatch<'a>(ctx: SelectedContext<'a>) -> Result<(Response, flow::Transition)> {
match &ctx.req.command.body {
2022-06-22 15:26:52 +00:00
CommandBody::Fetch {
sequence_set,
attributes,
uid,
} => ctx.fetch(sequence_set, attributes, uid).await,
2022-06-29 10:50:44 +00:00
_ => {
let ctx = authenticated::AuthenticatedContext {
req: ctx.req,
user: ctx.user,
};
authenticated::dispatch(ctx).await
}
2022-06-20 16:09:20 +00:00
}
}
2022-06-22 15:25:04 +00:00
2022-06-20 16:09:20 +00:00
// --- PRIVATE ---
2022-06-29 10:50:44 +00:00
impl<'a> SelectedContext<'a> {
2022-06-17 16:39:36 +00:00
pub async fn fetch(
2022-06-29 10:50:44 +00:00
self,
2022-06-22 15:25:04 +00:00
sequence_set: &SequenceSet,
attributes: &MacroOrFetchAttributes,
uid: &bool,
2022-06-22 15:26:52 +00:00
) -> Result<(Response, flow::Transition)> {
2022-06-29 10:50:44 +00:00
Ok((Response::bad("Not implemented")?, flow::Transition::None))
2022-06-17 16:39:36 +00:00
}
2022-06-20 16:09:20 +00:00
}