Merge branch 'master' into 1.4.0
This commit is contained in:
commit
7822d20efe
@ -238,7 +238,7 @@ inline sql::result load_permissions_v2(const std::shared_ptr<TSServer>& server,
|
||||
auto server_id = server ? server->getServerId() : 0;
|
||||
return command.query([&](int length, char** values, char** names){
|
||||
permission::PermissionType key = permission::PermissionType::undefined;
|
||||
permission::PermissionValue value = 0, granted = 0;
|
||||
permission::PermissionValue value = permNotGranted, granted = permNotGranted;
|
||||
bool negated = false, skipped = false;
|
||||
std::shared_ptr<BasicChannel> channel;
|
||||
|
||||
@ -342,9 +342,9 @@ std::shared_ptr<v2::PermissionManager> DatabaseHelper::loadClientPermissionManag
|
||||
auto channel = perm->channelId > 0 ? server->getChannelTree()->findChannel(perm->channelId) : nullptr;
|
||||
|
||||
if(channel)
|
||||
pMgr->load_permission(perm->permission->type, {perm->value, perm->grant}, channel->channelId(), perm->flag_negate, perm->flag_skip, perm->value != permNotGranted, perm->grant != permNotGranted);
|
||||
pMgr->load_permission(perm->permission->type, {perm->value, perm->grant}, channel->channelId(), perm->flag_skip, perm->flag_negate, perm->value != permNotGranted, perm->grant != permNotGranted);
|
||||
else
|
||||
pMgr->load_permission(perm->permission->type, {perm->value, perm->grant}, perm->flag_negate, perm->flag_skip, perm->value != permNotGranted, perm->grant != permNotGranted);
|
||||
pMgr->load_permission(perm->permission->type, {perm->value, perm->grant}, perm->flag_skip, perm->flag_negate, perm->value != permNotGranted, perm->grant != permNotGranted);
|
||||
}
|
||||
}
|
||||
loaded = true;
|
||||
@ -384,6 +384,8 @@ void DatabaseHelper::saveClientPermissions(const std::shared_ptr<ts::server::TSS
|
||||
std::string query = update.flag_delete ? DELETE_COMMAND : (update.flag_db ? UPDATE_COMMAND : INSERT_COMMAND);
|
||||
|
||||
auto permission_data = permission::resolvePermissionData(update.permission);
|
||||
auto value = update.update_value == v2::delete_value ? permNotGranted : update.values.value;
|
||||
auto grant = update.update_grant == v2::delete_value ? permNotGranted : update.values.grant;
|
||||
logTrace(server_id, "[CHANNEL] Updating client permission for client {}: {}. New value: {}. New grant: {}. Query: {}",
|
||||
client_dbid,
|
||||
permission_data->name,
|
||||
@ -398,8 +400,8 @@ void DatabaseHelper::saveClientPermissions(const std::shared_ptr<ts::server::TSS
|
||||
variable{":type", permission::SQL_PERM_USER},
|
||||
|
||||
variable{":permId", permission_data->name},
|
||||
variable{":value", update.values.value},
|
||||
variable{":grant", update.values.grant},
|
||||
variable{":value", value},
|
||||
variable{":grant", grant},
|
||||
variable{":flag_skip", update.flag_skip},
|
||||
variable{":flag_negate", update.flag_negate})
|
||||
.executeLater().waitAndGetLater(LOG_SQL_CMD, {-1, "future error"});
|
||||
@ -423,7 +425,7 @@ std::shared_ptr<permission::v2::PermissionManager> DatabaseHelper::loadGroupPerm
|
||||
if(entry) {
|
||||
for(const auto& perm : entry->permissions) {
|
||||
if(perm->type == permission::SQL_PERM_GROUP && perm->id == group_id) {
|
||||
result->load_permission(perm->permission->type, {perm->value, perm->grant}, perm->flag_negate, perm->flag_skip, perm->value != permNotGranted, perm->grant != permNotGranted);
|
||||
result->load_permission(perm->permission->type, {perm->value, perm->grant}, perm->flag_skip, perm->flag_negate, perm->value != permNotGranted, perm->grant != permNotGranted);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
@ -449,11 +451,13 @@ void DatabaseHelper::saveGroupPermissions(const std::shared_ptr<ts::server::TSSe
|
||||
std::string query = update.flag_delete ? DELETE_COMMAND : (update.flag_db ? UPDATE_COMMAND : INSERT_COMMAND);
|
||||
|
||||
auto permission_data = permission::resolvePermissionData(update.permission);
|
||||
auto value = update.update_value == v2::delete_value ? permNotGranted : update.values.value;
|
||||
auto grant = update.update_grant == v2::delete_value ? permNotGranted : update.values.grant;
|
||||
logTrace(server_id, "[CHANNEL] Updating group permission for group {}: {}. New value: {}. New grant: {}. Query: {}",
|
||||
group_id,
|
||||
permission_data->name,
|
||||
update.values.value,
|
||||
update.values.grant,
|
||||
value,
|
||||
grant,
|
||||
query
|
||||
);
|
||||
sql::command(this->sql, query,
|
||||
@ -463,8 +467,8 @@ void DatabaseHelper::saveGroupPermissions(const std::shared_ptr<ts::server::TSSe
|
||||
variable{":type", permission::SQL_PERM_GROUP},
|
||||
|
||||
variable{":permId", permission_data->name},
|
||||
variable{":value", update.values.value},
|
||||
variable{":grant", update.values.grant},
|
||||
variable{":value", value},
|
||||
variable{":grant", grant},
|
||||
variable{":flag_skip", update.flag_skip},
|
||||
variable{":flag_negate", update.flag_negate})
|
||||
.executeLater().waitAndGetLater(LOG_SQL_CMD, {-1, "future error"});
|
||||
@ -568,7 +572,7 @@ std::shared_ptr<permission::v2::PermissionManager> DatabaseHelper::loadChannelPe
|
||||
if(entry) {
|
||||
for(const auto& perm : entry->permissions) {
|
||||
if(perm->type == permission::SQL_PERM_CHANNEL && perm->channelId == channel) {
|
||||
result->load_permission(perm->permission->type, {perm->value, perm->grant}, perm->flag_negate, perm->flag_skip, perm->value != permNotGranted, perm->grant != permNotGranted);
|
||||
result->load_permission(perm->permission->type, {perm->value, perm->grant}, perm->flag_skip, perm->flag_negate, perm->value != permNotGranted, perm->grant != permNotGranted);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
@ -593,12 +597,14 @@ void DatabaseHelper::saveChannelPermissions(const std::shared_ptr<ts::server::TS
|
||||
for(auto& update : updates) {
|
||||
std::string query = update.flag_delete ? DELETE_COMMAND : (update.flag_db ? UPDATE_COMMAND : INSERT_COMMAND);
|
||||
|
||||
auto value = update.update_value == v2::delete_value ? permNotGranted : update.values.value;
|
||||
auto grant = update.update_grant == v2::delete_value ? permNotGranted : update.values.grant;
|
||||
auto permission_data = permission::resolvePermissionData(update.permission);
|
||||
logTrace(server_id, "[CHANNEL] Updating channel permission for channel {}: {}. New value: {}. New grant: {}. Query: {}",
|
||||
channel_id,
|
||||
permission_data->name,
|
||||
update.values.value,
|
||||
update.values.grant,
|
||||
value,
|
||||
grant,
|
||||
query
|
||||
);
|
||||
sql::command(this->sql, query,
|
||||
@ -608,8 +614,8 @@ void DatabaseHelper::saveChannelPermissions(const std::shared_ptr<ts::server::TS
|
||||
variable{":type", permission::SQL_PERM_CHANNEL},
|
||||
|
||||
variable{":permId", permission_data->name},
|
||||
variable{":value", update.values.value},
|
||||
variable{":grant", update.values.grant},
|
||||
variable{":value", value},
|
||||
variable{":grant", grant},
|
||||
variable{":flag_skip", update.flag_skip},
|
||||
variable{":flag_negate", update.flag_negate})
|
||||
.executeLater().waitAndGetLater(LOG_SQL_CMD, {-1, "future error"});
|
||||
@ -1100,7 +1106,7 @@ void DatabaseHelper::loadStartupPermissionCache() {
|
||||
StartupPermissionArgument arg;
|
||||
sql::command(this->sql, "SELECT `serverId`, `type`, `id`, `channelId`, `permId`, `value`, `grant`, `flag_skip`, `flag_negate` FROM permissions ORDER BY `serverId`").query([&](StartupPermissionArgument* arg, int length, char** values, char** names) {
|
||||
auto key = permission::PermissionTypeEntry::unknown;
|
||||
permission::PermissionValue value = 0, granted = 0;
|
||||
permission::PermissionValue value = permNotGranted, granted = permNotGranted;
|
||||
permission::PermissionSqlType type = SQL_PERM_GROUP;
|
||||
bool negated = false, skipped = false;
|
||||
ChannelId channel = 0;
|
||||
|
2
shared
2
shared
@ -1 +1 @@
|
||||
Subproject commit 837852114f92d0f3acb94b5e0807dee265bf40e5
|
||||
Subproject commit cb73d9df3258eaf59e4799c9e54d5f865e891734
|
Loading…
Reference in New Issue
Block a user