aboutsummaryrefslogtreecommitdiff
path: root/src/modules/m_sqloper.cpp
diff options
context:
space:
mode:
authorGravatar Sadie Powell2022-11-27 07:32:42 +0000
committerGravatar Sadie Powell2022-11-28 02:57:50 +0000
commitee44af8d04f23b4a16c9b377764f930d69e575f7 (patch)
tree4348a9d4b76ea65266875651d57d2ebf3e1d7894 /src/modules/m_sqloper.cpp
parentMerge branch 'insp3' into master. (diff)
Refactor the internals of the oper system.
- Allow overriding privileges from the <class> blocks in the <type> and <oper> blocks. - Separate oper types from oper accounts in the code. This enables moving some core stuff out of the config tag later. - Merge the config tags together to make a synthetic tag that can have getXXX called on it instead of using getConfig and then converting it. - Move the details of Have*Permission into the oper type class. - Improve oper events to allow modules to easily hook into the oper system.
Diffstat (limited to 'src/modules/m_sqloper.cpp')
-rw-r--r--src/modules/m_sqloper.cpp21
1 files changed, 7 insertions, 14 deletions
diff --git a/src/modules/m_sqloper.cpp b/src/modules/m_sqloper.cpp
index 6323d1ef2..8eb295222 100644
--- a/src/modules/m_sqloper.cpp
+++ b/src/modules/m_sqloper.cpp
@@ -54,11 +54,9 @@ public:
void OnResult(SQL::Result& res) override
{
- ServerConfig::OperIndex& oper_blocks = ServerInstance->Config->oper_blocks;
-
- // Remove our previous blocks from oper_blocks for a clean update
+ // Remove our previous blocks from the core for a clean update
for (const auto& block : my_blocks)
- oper_blocks.erase(block);
+ ServerInstance->Config->OperAccounts.erase(block);
my_blocks.clear();
SQL::Row row;
@@ -82,11 +80,11 @@ public:
const std::string name = tag->getString("name");
// Skip both duplicate sqloper blocks and sqloper blocks that attempt to override conf blocks.
- if (oper_blocks.find(name) != oper_blocks.end())
+ if (ServerInstance->Config->OperAccounts.find(name) != ServerInstance->Config->OperAccounts.end())
continue;
const std::string type = tag->getString("type");
- ServerConfig::OperIndex::iterator tblk = ServerInstance->Config->OperTypes.find(type);
+ auto tblk = ServerInstance->Config->OperTypes.find(type);
if (tblk == ServerInstance->Config->OperTypes.end())
{
ServerInstance->Logs.Normal(MODNAME, "Sqloper block " + name + " has missing type " + type);
@@ -94,12 +92,7 @@ public:
continue;
}
- auto ifo = std::make_shared<OperInfo>(type);
-
- ifo->type_block = tblk->second->type_block;
- ifo->oper_block = std::move(tag);
- ifo->class_blocks.assign(tblk->second->class_blocks.begin(), tblk->second->class_blocks.end());
- oper_blocks[name] = ifo;
+ ServerInstance->Config->OperAccounts[name] = std::make_shared<OperAccount>(name, tblk->second, tag);
my_blocks.push_back(name);
row.clear();
}
@@ -123,7 +116,7 @@ public:
}
}
- // Call /oper after placing all blocks from the SQL table into the config->oper_blocks list.
+ // Call /oper after placing all blocks from the SQL table into the Config->OperAccounts list.
void OperExec()
{
auto user = ServerInstance->Users.Find(uid);
@@ -199,7 +192,7 @@ public:
{
// Remove all oper blocks that were from the DB
for (const auto& block : my_blocks)
- ServerInstance->Config->oper_blocks.erase(block);
+ ServerInstance->Config->OperAccounts.erase(block);
}
ModResult OnPreCommand(std::string& command, CommandBase::Params& parameters, LocalUser* user, bool validated) override