fix: switch to new permissions enum

This commit is contained in:
Paul Makles
2022-02-22 20:34:23 +00:00
parent aab85fa143
commit 7befd77c5b
37 changed files with 128 additions and 174 deletions

View File

@@ -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)
}
}
}