This commit is contained in:
2026-08-02 11:09:50 +02:00
parent 659fd0f304
commit aa486be6e5
8 changed files with 221 additions and 60 deletions
+21 -1
View File
@@ -2,7 +2,7 @@ use crate::core::state::AppState;
use crate::http::context::Superuser;
use crate::http::error::HTTPError;
use crate::domain::dto::channel::{
ChannelQueryParams, ChannelResponse, ChannelRolePermissionResponse,
ChannelQueryParams, ChannelResponse, ChannelPermissionsResponse, ChannelRolePermissionResponse,
ChannelUserPermissionResponse, CreateChannelRequest, SetChannelPermissionRequest,
UpdateChannelRequest,
};
@@ -69,6 +69,26 @@ pub async fn get_by_id(
Ok(Json(mapper::channel_model_to_channel_response(channel)))
}
/// Liste les permissions directes configurées pour un canal.
#[utoipa::path(
get,
path = "/channels/{channel_id}/permissions",
params(("channel_id" = Uuid, Path, description = "ID du canal")),
responses((status = 200, body = ChannelPermissionsResponse), (status = 404, description = "Canal non trouvé")),
tag = "Channel Permissions"
)]
pub async fn list_permissions(
State(state): State<AppState>,
Path(channel_id): Path<Uuid>,
) -> Result<Json<ChannelPermissionsResponse>, HTTPError> {
state.repositories.channel.get_by_id(channel_id).await?.ok_or(HTTPError::NotFound)?;
let (users, roles) = tokio::try_join!(
state.repositories.channel.list_user_permissions(channel_id),
state.repositories.channel.list_role_permissions(channel_id),
)?;
Ok(Json(mapper::channel_permissions_to_response(users, roles)))
}
/// Crée un nouveau channel
#[utoipa::path(
post,