From b30bfb5d2b926fccd72dac7481486b66e203f2b7 Mon Sep 17 00:00:00 2001 From: Sadie Powell Date: Fri, 7 Mar 2025 12:31:42 +0000 Subject: [PATCH] Import misc channel and user metadata in db_atheme. --- modules/chanserv/cs_set_misc.cpp | 6 +++++- modules/database/db_atheme.cpp | 29 +++++++++++++++++++++++++++++ modules/nickserv/ns_set_misc.cpp | 3 +++ 3 files changed, 37 insertions(+), 1 deletion(-) diff --git a/modules/chanserv/cs_set_misc.cpp b/modules/chanserv/cs_set_misc.cpp index 01a5b90b7..4439589a8 100644 --- a/modules/chanserv/cs_set_misc.cpp +++ b/modules/chanserv/cs_set_misc.cpp @@ -207,9 +207,13 @@ public: descriptions[cname] = desc; + // Force creation of the extension item. + const auto extname = "cs_set_misc:" + GetAttribute(cname); + GetItem(extname); + auto numeric = block.Get("misc_numeric"); if (numeric >= 1 && numeric <= 999) - numerics["cs_set_misc:" + GetAttribute(cname)] = numeric; + numerics[extname] = numeric; } } diff --git a/modules/database/db_atheme.cpp b/modules/database/db_atheme.cpp index ada5d25a6..912e7fd2c 100644 --- a/modules/database/db_atheme.cpp +++ b/modules/database/db_atheme.cpp @@ -23,6 +23,7 @@ #include "modules/os_news.h" #include "modules/os_oper.h" #include "modules/os_session.h" +#include "modules/set_misc.h" #include "modules/suspend.h" // Handles reading from an Atheme database row. @@ -1066,6 +1067,20 @@ private: ci->last_topic_time = Anope::Convert(value, 0); else if (key.compare(0, 14, "private:stats:", 14) == 0) return HandleIgnoreMetadata(ci->name, key, value); + else if (key.find(':') == Anope::string::npos) + { + ExtensibleRef extref("cs_set_misc:" + key.upper()); + if (!extref) + { + Log(this) << "Unknown public metadata for " << ci->name << ": " << key << " = " << value; + return true; + } + + auto *data = extref->Set(ci); + data->object = ci->name; + data->name = key; + data->data = value; + } else Log(this) << "Unknown channel metadata for " << ci->name << ": " << key << " = " << value; @@ -1178,6 +1193,20 @@ private: data->vhost_ts = Anope::Convert(value, 0); else if (key.compare(0, 18, "private:usercloak:", 18) == 0) data->vhost_nick[key.substr(18)] = value; + else if (key.find(':') == Anope::string::npos) + { + ExtensibleRef extref("ns_set_misc:" + key.upper()); + if (!extref) + { + Log(this) << "Unknown public channel metadata for " << nc->display << ": " << key << " = " << value; + return true; + } + + auto *data = extref->Set(nc); + data->object = nc->display; + data->name = key; + data->data = value; + } else Log(this) << "Unknown account metadata for " << nc->display << ": " << key << " = " << value; diff --git a/modules/nickserv/ns_set_misc.cpp b/modules/nickserv/ns_set_misc.cpp index 77dd62d92..90d463fff 100644 --- a/modules/nickserv/ns_set_misc.cpp +++ b/modules/nickserv/ns_set_misc.cpp @@ -220,6 +220,9 @@ public: continue; descriptions[cname] = desc; + + // Force creation of the extension item. + GetItem("ns_set_misc:" + GetAttribute(cname)); } }