]> Untitled Git - lemmy.git/blobdiff - crates/api_crud/src/comment/create.rs
Moving settings and secrets to context.
[lemmy.git] / crates / api_crud / src / comment / create.rs
index 7669870039affd31db74dec10d43b182a67e6da4..fb175179a6e0a2ca485b6918ad080bbcdbcab24d 100644 (file)
@@ -40,9 +40,11 @@ impl PerformCrud for CreateComment {
     websocket_id: Option<ConnectionId>,
   ) -> Result<CommentResponse, LemmyError> {
     let data: &CreateComment = self;
-    let local_user_view = get_local_user_view_from_jwt(&data.auth, context.pool()).await?;
+    let local_user_view =
+      get_local_user_view_from_jwt(&data.auth, context.pool(), context.secret()).await?;
 
-    let content_slurs_removed = remove_slurs(&data.content.to_owned());
+    let content_slurs_removed =
+      remove_slurs(&data.content.to_owned(), &context.settings().slur_regex());
 
     // Check for a community ban
     let post_id = data.post_id;
@@ -91,10 +93,15 @@ impl PerformCrud for CreateComment {
 
     // Necessary to update the ap_id
     let inserted_comment_id = inserted_comment.id;
+    let protocol_and_hostname = context.settings().get_protocol_and_hostname();
+
     let updated_comment: Comment =
       blocking(context.pool(), move |conn| -> Result<Comment, LemmyError> {
-        let apub_id =
-          generate_apub_endpoint(EndpointType::Comment, &inserted_comment_id.to_string())?;
+        let apub_id = generate_apub_endpoint(
+          EndpointType::Comment,
+          &inserted_comment_id.to_string(),
+          &protocol_and_hostname,
+        )?;
         Ok(Comment::update_ap_id(conn, inserted_comment_id, apub_id)?)
       })
       .await?
@@ -118,6 +125,7 @@ impl PerformCrud for CreateComment {
       post,
       context.pool(),
       true,
+      &context.settings(),
     )
     .await?;