diff --git a/json-api/src/perms.rs b/json-api/src/perms.rs index 0541e17..ea98e12 100644 --- a/json-api/src/perms.rs +++ b/json-api/src/perms.rs @@ -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 { 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 { pub fn has_perm(mask: u64, target: u64) -> bool { // Check if the given mask contains the target permissions mask return (mask & target) == target; -} \ No newline at end of file +}