From bedb749acc1259fecdfe6cd0490cf724c0a57847 Mon Sep 17 00:00:00 2001 From: Astro Date: Sun, 11 Jun 2023 02:57:48 +0200 Subject: [PATCH] cave/store: avoid spam by keeping images only from posts with less than 3 tags --- cave/src/store.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/cave/src/store.rs b/cave/src/store.rs index f96857c..4087827 100644 --- a/cave/src/store.rs +++ b/cave/src/store.rs @@ -203,7 +203,8 @@ impl Store { .ignore(); } }; - let images = if !tagged_unsafe { + let tags = post.tags_set(); + let images = if !tagged_unsafe && tags.len() < 3 { post.media_attachments.iter() .filter(|a| a.media_type == "image") .filter_map(|a| a.remote_url.as_ref()) @@ -211,12 +212,12 @@ impl Store { .take(2) .collect::>() } else { - tracing::warn!("unsafe: {:?}/{:?}", post.sensitive, post.tags_set().keys()); + tracing::warn!("unsafe: {:?}/{:?}", post.sensitive, tags.keys()); // ignore disturbing porn images from sensitive posts vec![] }; let mut image_keys = vec![]; - for (name, spellings) in post.tags_set() { + for (name, spellings) in tags.into_iter() { // global store_tags(&mut cmd, spellings.clone(),