fix: respect muted phrases in reposts
This commit is contained in:
parent
6fcbb1fe00
commit
5844d23399
3 changed files with 103 additions and 100 deletions
|
@ -470,15 +470,17 @@ impl DataManager {
|
|||
/// Update posts which contain a muted phrase.
|
||||
pub fn posts_muted_phrase_filter(
|
||||
&self,
|
||||
posts: &Vec<Post>,
|
||||
posts: &Vec<FullPost>,
|
||||
muted: Option<&Vec<String>>,
|
||||
) -> Vec<Post> {
|
||||
) -> Vec<FullPost> {
|
||||
// this shit is actually ass bro it has to clone
|
||||
// very useless
|
||||
let muted = match muted {
|
||||
Some(m) => m,
|
||||
None => return posts.to_owned(),
|
||||
};
|
||||
|
||||
let mut out: Vec<Post> = Vec::new();
|
||||
let mut out: Vec<FullPost> = Vec::new();
|
||||
|
||||
for mut post in posts.clone() {
|
||||
for phrase in muted {
|
||||
|
@ -486,10 +488,27 @@ impl DataManager {
|
|||
continue;
|
||||
}
|
||||
|
||||
if post.content.to_lowercase().contains(&phrase.to_lowercase()) {
|
||||
post.context.content_warning = "Contains muted phrase".to_string();
|
||||
if post
|
||||
.0
|
||||
.content
|
||||
.to_lowercase()
|
||||
.contains(&phrase.to_lowercase())
|
||||
{
|
||||
post.0.context.content_warning = "Contains muted phrase".to_string();
|
||||
break;
|
||||
}
|
||||
|
||||
if let Some(ref mut reposting) = post.3 {
|
||||
if reposting
|
||||
.1
|
||||
.content
|
||||
.to_lowercase()
|
||||
.contains(&phrase.to_lowercase())
|
||||
{
|
||||
reposting.1.context.content_warning = "Contains muted phrase".to_string();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
out.push(post);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue