//! The writer half of "email photos are captured too" (schema v41) — the //! counting half, with the byte-reading half left as a HOOK. //! //! HOOK FOR 2f (the media rail). `packages/server/src/mcp/emailPhotos.ts` //! fetches each image attachment's bytes from the object store, sha256s them //! and writes a `cotton_photos` row plus an `email` sighting; the dedupe IS //! the hash, because no sha256 for an attachment exists anywhere else. This //! server has no blocking object-store seam on `ToolServices` yet, so there //! are no bytes to hash — and the TypeScript's own answer for a server with no //! store (`ctx.media` absent) is to SKIP every attachment, counted, never //! thrown, because the email itself is a fact regardless. That is exactly what //! this reproduces, so the tool's answer is identical today and gains the //! `photos` block on the day the rail lands. //! //! When it does: `cotton_core::rules::email_photos` already carries the //! decisions (`email_photo_candidate`, `email_photo_rows`, //! `is_above_email_photo_floor`) — this file needs only the fetch, the hash //! and the two writes. use super::validate::IngestEmailAttachmentArg; use crate::mcp::dispatch::Ctx; /// What one email's attachments did. #[derive(Debug, Clone, Copy, Default, PartialEq, Eq)] pub struct EmailPhotosOutcome { /// New `cotton_photos` rows. pub photos: i64, /// Sightings written on a photo the file already had. pub merged: i64, /// Attachments judged not to be a photo, or already sighted on this email. pub skipped: i64, /// Attachments that should have become a photo and could not. pub failed: i64, } impl EmailPhotosOutcome { pub fn add(&mut self, from: EmailPhotosOutcome) { self.photos += from.photos; self.merged += from.merged; self.skipped += from.skipped; self.failed += from.failed; } } /// File the pictures attached to one email. /// /// A server with no object store has no bytes to hash and skips every /// attachment — counted, not thrown. See the module note for what fills this /// in. pub fn record_email_photos( _ctx: &mut Ctx<'_>, attachments: &[IngestEmailAttachmentArg], ) -> EmailPhotosOutcome { EmailPhotosOutcome { skipped: attachments.len() as i64, ..EmailPhotosOutcome::default() } }