+ checkin mod::auth for valid permissions

+ helper function for getting a permission mask from permissions module
This commit is contained in:
shockrah
2020-08-25 23:27:41 -07:00
parent ef5b7a13f9
commit 9eff4284a9
2 changed files with 37 additions and 1 deletions

View File

@@ -8,6 +8,7 @@ pub const CREATE_TMP_INVITES:u64 = 4;
pub const CREATE_PERM_INVITES:u64 = 8; // to make perma invites you need both flags
pub const OWNER: u64 = 1 << 63;
pub const ADMIN: u64 = 1 << 62; // can make other admins but can't really touch the owner
@@ -19,3 +20,21 @@ pub const DELETE_CHANNEL:u64 = 128;
pub const OWNER_PERMS: u64 = std::u64::MAX;
pub const GENERAL_NEW: u64 = JOIN_VOICE | SEND_MESSAGES | ALLOW_PFP | CHANGE_NICK;
pub const ADMIN_PERMS: u64 = !(std::u64::MAX & OWNER); // filter the only perm admins don't get
pub fn get_perm_mask(path: &str) -> Option<u64> {
use crate::routes::{
INVITE_CREATE,
CHANNELS_LIST, CHANNELS_CREATE, CHANNELS_DELETE,
MESSAGE_SEND,
SERVER_META,
};
match path {
INVITE_CREATE => Some(CREATE_TMP_INVITES),
CHANNELS_LIST => None,
CHANNELS_CREATE => Some(CREATE_CHANNEL),
CHANNELS_DELETE => Some(DELETE_CHANNEL),
MESSAGE_SEND => Some(SEND_MESSAGES),
SERVER_META => None,
_ => Some(0)
}
}