-
-
Notifications
You must be signed in to change notification settings - Fork 902
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Simplify slur regex #5442
Simplify slur regex #5442
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since regex changes pretty infrequently, regex checking should probably make use of caching anyway, instead of reading the site from the DB every time, via https://github.com/LemmyNet/lemmy/blob/main/crates/api_crud/src/site/read.rs#L26
@@ -1037,7 +1031,7 @@ pub fn check_conflicting_like_filters( | |||
|
|||
pub async fn process_markdown( | |||
text: &str, | |||
slur_regex: &Option<LemmyResult<Regex>>, | |||
slur_regex: &Regex, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now that this is no longer an option, isn't it going to throw the new lemmyerror you created? Or maybe since it matches nothing it should be ok.
I feel like Option<Regex
(which is the reality in the DB) is probably better and more explicit than a missing regex that default matches nothing, but its up to you I spose.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The error would only be thrown if the regex is invalid, and that shouldnt happen as its checked before create/update.
Option<Regex>
also works, but this way the code is a bit simpler.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In that case this is probably fine then, as long as the no match regex doesn't throw errors.
No description provided.