Update channel moving to match
This commit is contained in:
parent
c6d33d4bb9
commit
08de0d88b1
6 changed files with 72 additions and 30 deletions
|
@ -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();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue