Implemented new chat system
This commit is contained in:
parent
692fba3791
commit
9f2181c18b
@ -67,17 +67,20 @@ namespace ts {
|
|||||||
auto permission_manager = this->permissions(); /* copy the manager */
|
auto permission_manager = this->permissions(); /* copy the manager */
|
||||||
assert(permission_manager);
|
assert(permission_manager);
|
||||||
const auto data = permission_manager->permission_value_flagged(permission);
|
const auto data = permission_manager->permission_value_flagged(permission);
|
||||||
if(!data.has_value) {
|
return BasicChannel::permission_granted(data,granted_value, require_granted_value);
|
||||||
|
}
|
||||||
|
|
||||||
|
ts_always_inline
|
||||||
|
static bool permission_granted(const permission::v2::PermissionFlaggedValue& channel_permission_value, const permission::v2::PermissionFlaggedValue& granted_value, bool require_granted_value) {
|
||||||
|
if(!channel_permission_value.has_value || channel_permission_value.value == 0) {
|
||||||
return !require_granted_value || granted_value.has_value;
|
return !require_granted_value || granted_value.has_value;
|
||||||
}
|
}
|
||||||
if(!granted_value.has_value) {
|
if(channel_permission_value.value == -1) {
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if(data.value == -1) {
|
|
||||||
return granted_value.value == -1;
|
return granted_value.value == -1;
|
||||||
}
|
}
|
||||||
return granted_value.value >= data.value;
|
return granted_value.value >= channel_permission_value.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
ts_always_inline bool talk_power_granted(const permission::v2::PermissionFlaggedValue& granted_value) {
|
ts_always_inline bool talk_power_granted(const permission::v2::PermissionFlaggedValue& granted_value) {
|
||||||
return this->permission_granted(permission::i_client_needed_talk_power, granted_value, false);
|
return this->permission_granted(permission::i_client_needed_talk_power, granted_value, false);
|
||||||
}
|
}
|
||||||
|
@ -1173,7 +1173,7 @@ void v2::PermissionManager::set_permission(const PermissionType &permission, con
|
|||||||
} else if(action_value == v2::PermissionUpdateType::delete_value) {
|
} else if(action_value == v2::PermissionUpdateType::delete_value) {
|
||||||
data.flags.value_set = false;
|
data.flags.value_set = false;
|
||||||
data.flags.flag_value_update = true;
|
data.flags.flag_value_update = true;
|
||||||
data.values.grant = permNotGranted; /* required for the database else it does not "deletes" the value */
|
data.values.value = permNotGranted; /* required for the database else it does not "deletes" the value */
|
||||||
}
|
}
|
||||||
|
|
||||||
if(action_grant == v2::PermissionUpdateType::set_value) {
|
if(action_grant == v2::PermissionUpdateType::set_value) {
|
||||||
@ -1248,7 +1248,7 @@ void v2::PermissionManager::set_channel_permission(const PermissionType &permiss
|
|||||||
if(action_grant == v2::PermissionUpdateType::set_value) {
|
if(action_grant == v2::PermissionUpdateType::set_value) {
|
||||||
permission_container->flags.grant_set = true;
|
permission_container->flags.grant_set = true;
|
||||||
permission_container->flags.flag_grant_update = true;
|
permission_container->flags.flag_grant_update = true;
|
||||||
permission_container->values.grant = values.value;
|
permission_container->values.grant = values.grant;
|
||||||
} else if(action_grant == v2::PermissionUpdateType::delete_value) {
|
} else if(action_grant == v2::PermissionUpdateType::delete_value) {
|
||||||
permission_container->flags.grant_set = false;
|
permission_container->flags.grant_set = false;
|
||||||
permission_container->flags.flag_grant_update = true;
|
permission_container->flags.flag_grant_update = true;
|
||||||
|
Loading…
Reference in New Issue
Block a user