2023-07-28 14:39:38 +00:00
|
|
|
use actix_web::web::{Data, Json, Query};
|
2021-12-15 19:49:59 +00:00
|
|
|
use lemmy_api_common::{
|
2023-06-06 16:27:22 +00:00
|
|
|
build_response::build_comment_response,
|
2022-05-03 17:44:13 +00:00
|
|
|
comment::{CommentResponse, GetComment},
|
2022-11-28 14:29:33 +00:00
|
|
|
context::LemmyContext,
|
2023-05-25 14:50:07 +00:00
|
|
|
utils::{check_private_instance, local_user_view_from_jwt_opt},
|
2021-11-16 17:03:09 +00:00
|
|
|
};
|
2022-10-27 09:24:07 +00:00
|
|
|
use lemmy_db_schema::source::local_site::LocalSite;
|
2023-06-06 16:27:22 +00:00
|
|
|
use lemmy_utils::error::LemmyError;
|
2021-03-25 19:19:40 +00:00
|
|
|
|
2023-07-28 14:39:38 +00:00
|
|
|
#[tracing::instrument(skip(context))]
|
|
|
|
pub async fn get_comment(
|
|
|
|
data: Query<GetComment>,
|
|
|
|
context: Data<LemmyContext>,
|
|
|
|
) -> Result<Json<CommentResponse>, LemmyError> {
|
|
|
|
let local_user_view = local_user_view_from_jwt_opt(data.auth.as_ref(), &context).await;
|
|
|
|
let local_site = LocalSite::read(&mut context.pool()).await?;
|
2021-11-23 15:53:48 +00:00
|
|
|
|
2023-07-28 14:39:38 +00:00
|
|
|
check_private_instance(&local_user_view, &local_site)?;
|
2021-11-23 15:53:48 +00:00
|
|
|
|
2023-07-28 14:39:38 +00:00
|
|
|
Ok(Json(
|
2023-08-04 13:22:43 +00:00
|
|
|
build_comment_response(&context, data.id, local_user_view, vec![]).await?,
|
2023-07-28 14:39:38 +00:00
|
|
|
))
|
2021-11-23 15:53:48 +00:00
|
|
|
}
|