Update channel moving to match

This commit is contained in:
Conrad Irwin 2024-01-26 10:07:51 -07:00
parent c6d33d4bb9
commit 08de0d88b1
6 changed files with 72 additions and 30 deletions

View file

@ -995,20 +995,20 @@ impl Database {
let new_parent = self.get_channel_internal(new_parent_id, &*tx).await?;
if new_parent.root_id() != channel.root_id() {
Err(anyhow!("cannot move a channel into a different root"))?;
Err(anyhow!(ErrorCode::WrongMoveTarget))?;
}
if new_parent
.ancestors_including_self()
.any(|id| id == channel.id)
{
Err(anyhow!("cannot move a channel into one of its descendants"))?;
Err(anyhow!(ErrorCode::CircularNesting))?;
}
if channel.visibility == ChannelVisibility::Public
&& new_parent.visibility != ChannelVisibility::Public
{
Err(anyhow!("public channels must descend from public channels"))?;
Err(anyhow!(ErrorCode::BadPublicNesting))?;
}
let root_id = channel.root_id();