WIP notmuch-fcc-dirs

Signed-off-by: Manos Pitsidianakis <manos@pitsidianak.is>
notmuch-fcc-dirs
Manos Pitsidianakis 2 months ago
parent 4e7b665672
commit 77956807b2
No known key found for this signature in database
GPG Key ID: 7729C7707F7E09D0

@ -0,0 +1,63 @@
//
// melib
//
// Copyright 2024 Emmanouil Pitsidianakis <manos@pitsidianak.is>
//
// This file is part of melib.
//
// melib is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// melib is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with melib. If not, see <http://www.gnu.org/licenses/>.
//
// SPDX-License-Identifier: EUPL-1.2 OR GPL-3.0-or-later
use crate::{email::Address, SpecialUsageMailbox};
use indexmap::IndexMap;
use regex::bytes::Regex;
use std::path::PathBuf;
#[derive(Serialize, Deserialize)]
pub struct FccDirEntry {
pattern: Box<str>,
folder: Option<Box<str>>,
//tags: Vec<FlagOp>,
}
impl FccDirEntry {
pub fn matches<'fcc>(&'fcc self, from: &Address) -> Option<&'fcc str> {
let reg = Regex::new(&self.pattern).ok()?;
if reg.is_match(from.raw()) {
return self.folder.as_ref().map(|s| s.as_ref());
}
None
}
}
#[derive(Serialize, Deserialize)]
pub enum FccDirs {
None,
Folder(Box<str>),
SpecialFolder(SpecialUsageMailbox),
Map(Vec<FccDirEntry>),
}
impl Default for FccDirs {
fn default() -> Self {
Self::SpecialFolder(SpecialUsageMailbox::Sent)
}
}
#[derive(Default, Serialize, Deserialize)]
pub struct Configuration {
pub library_file_path: Option<PathBuf>,
pub fcc_dirs: FccDirs,
}

@ -72,6 +72,7 @@ macro_rules! try_call {
}};
}
pub mod config;
pub mod query;
use query::{MelibQueryToNotmuchQuery, Query};
pub mod mailbox;

Loading…
Cancel
Save