From 95ac7647ac0c2549f82604aa5884f412cb4efb1e Mon Sep 17 00:00:00 2001 From: Hocuri Date: Thu, 21 Nov 2024 14:57:35 +0100 Subject: [PATCH] test: Mark `receive_imf()` as only for tests and "internals" feature (#6235) `receive_imf() is only used in tests and the REPL, which enables the "internals" feature. This PR marks it as such, so that it's clear not only from the comment that this function is not used for anything else. --- src/receive_imf.rs | 6 ++++-- src/securejoin.rs | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/receive_imf.rs b/src/receive_imf.rs index 37ffc7f296..9b722c702e 100644 --- a/src/receive_imf.rs +++ b/src/receive_imf.rs @@ -6,7 +6,7 @@ use std::str::FromStr; use anyhow::{Context as _, Result}; use deltachat_contact_tools::{addr_cmp, may_be_valid_addr, sanitize_single_line, ContactAddress}; use iroh_gossip::proto::TopicId; -use mailparse::{parse_mail, SingleInfo}; +use mailparse::SingleInfo; use num_traits::FromPrimitive; use once_cell::sync::Lazy; use regex::Regex; @@ -73,12 +73,13 @@ pub struct ReceivedMsg { /// /// This method returns errors on a failure to parse the mail or extract Message-ID. It's only used /// for tests and REPL tool, not actual message reception pipeline. +#[cfg(any(test, feature = "internals"))] pub async fn receive_imf( context: &Context, imf_raw: &[u8], seen: bool, ) -> Result> { - let mail = parse_mail(imf_raw).context("can't parse mail")?; + let mail = mailparse::parse_mail(imf_raw).context("can't parse mail")?; let rfc724_mid = imap::prefetch_get_message_id(&mail.headers).unwrap_or_else(imap::create_message_id); if let Some(download_limit) = context.download_limit().await? { @@ -105,6 +106,7 @@ pub async fn receive_imf( /// Emulates reception of a message from "INBOX". /// /// Only used for tests and REPL tool, not actual message reception pipeline. +#[cfg(any(test, feature = "internals"))] pub(crate) async fn receive_imf_from_inbox( context: &Context, rfc724_mid: &str, diff --git a/src/securejoin.rs b/src/securejoin.rs index 6691ba92a9..f9ebd00d98 100644 --- a/src/securejoin.rs +++ b/src/securejoin.rs @@ -244,10 +244,10 @@ async fn verify_sender_by_fingerprint( /// What to do with a Secure-Join handshake message after it was handled. /// -/// This status is returned to [`receive_imf`] which will use it to decide what to do +/// This status is returned to [`receive_imf_inner`] which will use it to decide what to do /// next with this incoming setup-contact/secure-join handshake message. /// -/// [`receive_imf`]: crate::receive_imf::receive_imf +/// [`receive_imf_inner`]: crate::receive_imf::receive_imf_inner #[derive(Debug, PartialEq, Eq)] pub(crate) enum HandshakeMessage { /// The message has been fully handled and should be removed/delete.