lemmy/crates/api_crud/src/comment/read.rs
Nutomic f858d8cbce
Remove explicit auth params (#3946)
* Remove explicit auth params (ref #3725)

Only take auth via header or cookie. This requires a new version
of lemmy-js-client for api tests to pass.

* rework api_crud

* remove remaining auth params, move logic to session middleware

* fmt, fix test

* update js client

* remove auth param from api tests

* Pass auth as header

* add !

* url vars, setHeader

* cleanup

* fmt

* update

* Updating for new lemmy-js-client.

---------

Co-authored-by: Dessalines <tyhou13@gmx.com>
Co-authored-by: Dessalines <dessalines@users.noreply.github.com>
2023-09-21 06:42:28 -04:00

26 lines
777 B
Rust

use actix_web::web::{Data, Json, Query};
use lemmy_api_common::{
build_response::build_comment_response,
comment::{CommentResponse, GetComment},
context::LemmyContext,
utils::check_private_instance,
};
use lemmy_db_schema::source::local_site::LocalSite;
use lemmy_db_views::structs::LocalUserView;
use lemmy_utils::error::LemmyError;
#[tracing::instrument(skip(context))]
pub async fn get_comment(
data: Query<GetComment>,
context: Data<LemmyContext>,
local_user_view: Option<LocalUserView>,
) -> Result<Json<CommentResponse>, LemmyError> {
let local_site = LocalSite::read(&mut context.pool()).await?;
check_private_instance(&local_user_view, &local_site)?;
Ok(Json(
build_comment_response(&context, data.id, local_user_view, vec![]).await?,
))
}