Skip to content
Clone
7a0eb3a
34 lines 1.2 KB Rust
use axum::extract::{Path, State};
use export::data::AppResponseData;
use jwt::extractor::AuthUser;
use uuid::Uuid;
use crate::error::IssueResult;
use crate::features::IssueService;
use crate::features::comment::CommentView;
#[utoipa::path(
get,
path = "/issues/{space_name}/{issue_id}/comments/{comment_id}",
tag = "issues",
params(
("space_name" = String, Path),
("issue_id" = Uuid, Path),
("comment_id" = Uuid, Path),
),
responses((status = 200, description = "Get comment", body = AppResponseData<CommentView>)),
security(("bearer_auth" = []))
)]
pub(crate) async fn handler(
State(svc): State<IssueService>,
AuthUser { claims }: AuthUser,
Path((space_name, issue_id, comment_id)): Path<(String, Uuid, Uuid)>,
) -> IssueResult<AppResponseData<CommentView>> {
let space_id = space::features::lookup::lookup_space_by_name(&svc, &space_name).await?;
space::features::authz::require_active_member(&svc, claims.sub, space_id).await?;
let channel_id = crate::features::lookup::channel_for_issue(&svc, issue_id).await?;
let view = svc
.get_comment(claims.sub, channel_id, issue_id, comment_id)
.await?;
Ok(AppResponseData::ok(view))
}