fix: check muted phrases while creating questions

This commit is contained in:
trisua 2025-07-18 12:22:50 -04:00
parent 22aea48cc5
commit e393221b4f

View file

@ -387,23 +387,8 @@ impl DataManager {
// inherit nsfw status // inherit nsfw status
data.context.is_nsfw = community.context.is_nsfw; data.context.is_nsfw = community.context.is_nsfw;
} else { } else {
let receiver = self.get_user_by_id(data.receiver).await?; // this should be unreachable
return Err(Error::Unknown);
if !receiver.settings.enable_questions {
return Err(Error::QuestionsDisabled);
}
// check for ip block
if self
.get_ipblock_by_initiator_receiver(
receiver.id,
&RemoteAddr::from(data.ip.as_str()),
)
.await
.is_ok()
{
return Err(Error::NotAllowed);
}
} }
} else { } else {
// single // single
@ -421,6 +406,14 @@ impl DataManager {
return Err(Error::DrawingsDisabled); return Err(Error::DrawingsDisabled);
} }
// check muted phrases
for phrase in receiver.settings.muted {
if data.content.contains(&phrase) {
// act like the question was created so theyre less likely to try and send it again or bypass
return Ok(0);
}
}
// check for ip block // check for ip block
if self if self
.get_ipblock_by_initiator_receiver(receiver.id, &RemoteAddr::from(data.ip.as_str())) .get_ipblock_by_initiator_receiver(receiver.id, &RemoteAddr::from(data.ip.as_str()))