This commit is contained in:
2026-08-29 14:05:43 +02:00
parent 5e97e9c223
commit 88ad3c389f
15 changed files with 423 additions and 109 deletions
+21 -5
View File
@@ -13,14 +13,30 @@ use axum::{
extract::{Path, Query, State},
http::StatusCode,
};
use uuid::Uuid;
use sea_orm::{ColumnTrait, EntityTrait, QueryFilter};
use uuid::Uuid;
async fn require_channel_member(state: &AppState, channel_id: Uuid, user_id: Uuid) -> Result<(), HTTPError> {
let channel = state.repositories.channel.get_by_id(channel_id).await?.ok_or(HTTPError::NotFound)?;
async fn require_channel_member(
state: &AppState,
channel_id: Uuid,
user_id: Uuid,
) -> Result<(), HTTPError> {
let channel = state
.repositories
.channel
.get_by_id(channel_id)
.await?
.ok_or(HTTPError::NotFound)?;
if channel.channel_type == channel::ChannelType::DM
&& channel_user::Entity::find().filter(channel_user::Column::ChannelId.eq(channel_id)).filter(channel_user::Column::UserId.eq(user_id)).one(&state.db).await?.is_none()
{ return Err(HTTPError::Forbidden); }
&& channel_user::Entity::find()
.filter(channel_user::Column::ChannelId.eq(channel_id))
.filter(channel_user::Column::UserId.eq(user_id))
.one(&state.db)
.await?
.is_none()
{
return Err(HTTPError::Forbidden);
}
Ok(())
}