This commit is contained in:
2026-07-14 23:07:48 +02:00
parent b7c48ce7f3
commit 8afa694aed
7 changed files with 119 additions and 34 deletions
+11 -1
View File
@@ -2,7 +2,7 @@ use super::types::{ServerExplorerItem, ServerTree};
use super::{AnyResult, RepositoryContext};
use crate::models::{category, channel, role, server, server_user};
use sea_orm::prelude::*;
use sea_orm::{ActiveModelTrait, Set};
use sea_orm::{ActiveModelTrait, QuerySelect, Set};
use std::sync::Arc;
use uuid::Uuid;
@@ -72,6 +72,16 @@ impl ServerRepository {
.insert(&self.context.db)
.await?;
let role_id: Uuid = role::Entity::find()
.filter(role::Column::ServerId.eq(server_id))
.filter(role::Column::IsDefault.eq(true))
.select_only()
.column(role::Column::Id)
.into_tuple::<Uuid>()
.one(&self.context.db)
.await?
.ok_or_else(|| anyhow::anyhow!("Rôle par défaut introuvable"))?;
self.context
.events
.emit("server_user_created", (server_id, user_id));