- // Do the update
- let content_slurs_removed =
- remove_slurs(&data.content.to_owned(), &context.settings().slur_regex());
- let comment_id = data.comment_id;
- let updated_comment = blocking(context.pool(), move |conn| {
- Comment::update_content(conn, comment_id, &content_slurs_removed)
- })
- .await?
- .map_err(|e| LemmyError::from_error_message(e, "couldnt_update_comment"))?;
+ if let Some(distinguished) = data.distinguished {
+ // Verify that only a mod or admin can distinguish a comment
+ is_mod_or_admin(
+ context.pool(),
+ local_user_view.person.id,
+ orig_comment.community.id,
+ )
+ .await?;
+
+ updated_comment = blocking(context.pool(), move |conn| {
+ Comment::update_distinguished(conn, comment_id, distinguished)
+ })
+ .await?
+ .map_err(|e| LemmyError::from_error_message(e, "couldnt_update_comment"))?;
+ }
+
+ // Update the Content
+ if let Some(content) = &data.content {
+ let content_slurs_removed = remove_slurs(content, &context.settings().slur_regex());
+ let comment_id = data.comment_id;
+ updated_comment = blocking(context.pool(), move |conn| {
+ Comment::update_content(conn, comment_id, &content_slurs_removed)
+ })
+ .await?
+ .map_err(|e| LemmyError::from_error_message(e, "couldnt_update_comment"))?;
+ };