+ Better formatting in hyper compact code

+ Adding ADD_NEIGHBOR permissions flag
This commit is contained in:
shockrah 2021-05-09 23:16:43 -07:00
parent b3c27b86ce
commit ee5d9fb248

View File

@ -13,6 +13,7 @@ pub const _ADMIN: u64 = 1 << 62; // can make other admins but can't really touch
// ADMIN PERMS
pub const CREATE_CHANNEL:u64 = 64;
pub const DELETE_CHANNEL:u64 = 128;
pub const ADD_NEIGHBOR:u64 = 256;
// BELOW ARE COLLECTIVE PERMISSION SETS
pub const OWNER: u64 = std::u64::MAX;
@ -21,16 +22,22 @@ pub const ADMIN_PERMS: u64 = !(std::u64::MAX & OWNER); // filter the only perm a
pub fn get_perm_mask(path: &str) -> Option<u64> {
use crate::routes::{
self,
INVITE_CREATE,
CHANNELS_LIST, CHANNELS_CREATE, CHANNELS_DELETE,
MESSAGE_SEND,
};
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),
routes::ADD_NEIGHBOR => Some(ADD_NEIGHBOR),
_ => Some(0)
}
}
@ -39,4 +46,4 @@ pub fn get_perm_mask(path: &str) -> Option<u64> {
pub fn has_perm(mask: u64, target: u64) -> bool {
// Check if the given mask contains the target permissions mask
return (mask & target) == target;
}
}