cave/store: avoid spam by keeping images only from posts with less than 3 tags

This commit is contained in:
Astro 2023-06-11 02:57:48 +02:00
parent 0618afb640
commit bedb749acc
1 changed files with 4 additions and 3 deletions

View File

@ -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::<Vec<&String>>()
} 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(),