1 use crate::PerformCrud;
2 use actix_web::web::Data;
3 use lemmy_api_common::{
4 comment::{CommentResponse, GetComment},
6 utils::{check_private_instance, local_user_view_from_jwt_opt},
8 use lemmy_db_schema::source::local_site::LocalSite;
9 use lemmy_db_views::structs::CommentView;
10 use lemmy_utils::{error::LemmyError, ConnectionId};
12 #[async_trait::async_trait(?Send)]
13 impl PerformCrud for GetComment {
14 type Response = CommentResponse;
16 #[tracing::instrument(skip(context, _websocket_id))]
19 context: &Data<LemmyContext>,
20 _websocket_id: Option<ConnectionId>,
21 ) -> Result<Self::Response, LemmyError> {
23 let local_user_view = local_user_view_from_jwt_opt(data.auth.as_ref(), context).await;
24 let local_site = LocalSite::read(context.pool()).await?;
26 check_private_instance(&local_user_view, &local_site)?;
28 let person_id = local_user_view.map(|u| u.person.id);
30 let comment_view = CommentView::read(context.pool(), id, person_id)
32 .map_err(|e| LemmyError::from_error_message(e, "couldnt_find_comment"))?;
37 recipient_ids: Vec::new(),