use super::*;
pub const DOC_MIME: &str = "application/msword";
pub const PPT_MIME: &str = "application/vnd.ms-powerpoint";
pub struct LegacyOfficeCanonicalizer;
impl Canonicalizer for LegacyOfficeCanonicalizer {
fn source_kind(&self) -> KbSourceKind {
KbSourceKind::Doc
}
fn supports_mime(&self, mime: &str) -> bool {
matches!(mime, DOC_MIME | PPT_MIME)
}
fn canonicalize(&self, input: CanonicalizeInput<'_>) -> Result<Option<CanonicalizedSource>> {
let (legacy, modern) = if input.mime == DOC_MIME {
(".doc", ".docx")
} else {
(".ppt", ".pptx")
};
anyhow::bail!(
"legacy {legacy} files are not supported — please open it and save as {modern}, then re-upload"
)
}
}