fix: switch to new permissions enum
This commit is contained in:
@@ -1,14 +1,14 @@
|
||||
use revolt_quark::{
|
||||
models::{channel::PartialChannel, Channel, User},
|
||||
perms, ChannelPermission, Db, EmptyResponse, Error, Ref, Result,
|
||||
perms, Db, EmptyResponse, Error, Permission, Ref, Result,
|
||||
};
|
||||
|
||||
#[delete("/<target>")]
|
||||
pub async fn req(db: &Db, user: User, target: Ref) -> Result<EmptyResponse> {
|
||||
let channel = target.as_channel(db).await?;
|
||||
let perm = perms(&user).channel(&channel).calc_channel(db).await;
|
||||
let perm = perms(&user).channel(&channel).calc(db).await;
|
||||
|
||||
if !perm.get_view() {
|
||||
if !perm.can_view_channel() {
|
||||
return Err(Error::NotFound);
|
||||
}
|
||||
|
||||
@@ -30,12 +30,10 @@ pub async fn req(db: &Db, user: User, target: Ref) -> Result<EmptyResponse> {
|
||||
.await
|
||||
.map(|_| EmptyResponse),
|
||||
Channel::TextChannel { .. } | Channel::VoiceChannel { .. } => {
|
||||
if perm.get_manage_channel() {
|
||||
if perm.can_manage_channel() {
|
||||
channel.delete(db).await.map(|_| EmptyResponse)
|
||||
} else {
|
||||
Err(Error::MissingPermission {
|
||||
permission: ChannelPermission::ManageChannel as i32,
|
||||
})
|
||||
Error::from_permission(Permission::ManageChannel)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user