Skip to content
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

Merged
merged 6 commits into from
Feb 20, 2025
Merged

Simplify slur regex #5442

merged 6 commits into from
Feb 20, 2025

Conversation

Nutomic
Copy link
Member

@Nutomic Nutomic commented Feb 20, 2025

No description provided.

Copy link
Member

@dessalines dessalines left a 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,
Copy link
Member

@dessalines dessalines Feb 20, 2025

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.

Copy link
Member Author

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.

Copy link
Member

@dessalines dessalines left a 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.

@dessalines dessalines merged commit 544a4cc into main Feb 20, 2025
2 checks passed
@SleeplessOne1917 SleeplessOne1917 deleted the simplify-slur-regex branch February 21, 2025 14:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants