From fdb96da58174b41548992b3dcaba40a01b10ecf9 Mon Sep 17 00:00:00 2001 From: Darius Clark Date: Fri, 13 Dec 2024 09:10:33 -0600 Subject: [PATCH] fix: filter out and skip message if empty within attachment (#646) --- .../warp-ipfs/src/store/message/attachment.rs | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) diff --git a/extensions/warp-ipfs/src/store/message/attachment.rs b/extensions/warp-ipfs/src/store/message/attachment.rs index 0c51f70f2..a6604050c 100644 --- a/extensions/warp-ipfs/src/store/message/attachment.rs +++ b/extensions/warp-ipfs/src/store/message/attachment.rs @@ -84,10 +84,6 @@ impl AttachmentStream { } pub fn set_lines(mut self, lines: Vec) -> Result { - if lines.is_empty() { - return Ok(self); - } - let lines_value_length: usize = lines .iter() .filter(|s| !s.is_empty()) @@ -95,18 +91,8 @@ impl AttachmentStream { .map(|s| s.chars().count()) .sum(); - if lines_value_length < MIN_MESSAGE_SIZE { - tracing::error!( - current_size = lines_value_length, - min = MIN_MESSAGE_SIZE, - "length of message is invalid" - ); - return Err(Error::InvalidLength { - context: "message".into(), - current: lines_value_length, - minimum: None, - maximum: Some(MIN_MESSAGE_SIZE), - }); + if lines.is_empty() || lines_value_length < MIN_MESSAGE_SIZE { + return Ok(self); } if lines_value_length > MAX_MESSAGE_SIZE {