1
0
mirror of https://github.com/anope/anope.git synced 2026-06-27 09:26:38 +02:00

Fix importing Atheme opers.

This commit is contained in:
Sadie Powell
2024-06-19 22:10:19 +01:00
parent 3388736fab
commit 01fc3ea22e
3 changed files with 86 additions and 38 deletions
+46
View File
@@ -0,0 +1,46 @@
/*
*
* (C) 2011-2024 Anope Team
* Contact us at team@anope.org
*
* Please read COPYING and README for further details.
*/
#pragma once
struct MyOper final
: Oper
, Serializable
{
MyOper(const Anope::string &n, OperType *o) : Oper(n, o), Serializable("Oper") { }
void Serialize(Serialize::Data &data) const override
{
data["name"] << this->name;
data["type"] << this->ot->GetName();
}
static Serializable *Unserialize(Serializable *obj, Serialize::Data &data)
{
Anope::string stype, sname;
data["type"] >> stype;
data["name"] >> sname;
OperType *ot = OperType::Find(stype);
if (ot == NULL)
return NULL;
NickCore *nc = NickCore::Find(sname);
if (nc == NULL)
return NULL;
MyOper *myo;
if (obj)
myo = anope_dynamic_static_cast<MyOper *>(obj);
else
myo = new MyOper(nc->display, ot);
nc->o = myo;
Log(LOG_NORMAL, "operserv/oper") << "Tied oper " << nc->display << " to type " << ot->GetName();
return myo;
}
};
+39 -1
View File
@@ -20,6 +20,7 @@
#include "modules/info.h"
#include "modules/ns_cert.h"
#include "modules/os_forbid.h"
#include "modules/os_oper.h"
#include "modules/os_session.h"
#include "modules/suspend.h"
@@ -202,7 +203,7 @@ private:
{ "RR", &DBAtheme::HandleIgnore },
{ "RW", &DBAtheme::HandleIgnore },
{ "SI", &DBAtheme::HandleIgnore },
{ "SO", &DBAtheme::HandleIgnore },
{ "SO", &DBAtheme::HandleSO },
{ "TS", &DBAtheme::HandleIgnore },
{ "XID", &DBAtheme::HandleIgnore },
{ "XL", &DBAtheme::HandleXL },
@@ -1328,6 +1329,43 @@ private:
return true;
}
bool HandleSO(AthemeRow &row)
{
// SO <display> <type> <flags>
auto display = row.Get();
auto type = row.Get();
auto flags = row.Get();
if (!row)
return row.LogError(this);
auto *nc = NickCore::Find(display);
if (!nc)
{
Log(this) << "Missing NickCore for SO: " << display;
return false;
}
auto ot = OperType::Find(type);
if (!ot)
{
// Attempt to convert oper types.
if (type == "sra")
ot = OperType::Find("Services Root");
else if (type == "ircop")
ot = OperType::Find("Services Operator");
}
if (!ot)
{
Log(this) << "Unable to convert operator status for " << nc->display << " as there is no equivalent oper type: " << type;
return true;
}
nc->o = new MyOper(nc->display, ot);
return true;
}
bool HandleXL(AthemeRow &row)
{
// XL <id> <real> <duration> <settime> <setby> <reason>
+1 -37
View File
@@ -10,43 +10,7 @@
*/
#include "module.h"
struct MyOper final
: Oper
, Serializable
{
MyOper(const Anope::string &n, OperType *o) : Oper(n, o), Serializable("Oper") { }
void Serialize(Serialize::Data &data) const override
{
data["name"] << this->name;
data["type"] << this->ot->GetName();
}
static Serializable *Unserialize(Serializable *obj, Serialize::Data &data)
{
Anope::string stype, sname;
data["type"] >> stype;
data["name"] >> sname;
OperType *ot = OperType::Find(stype);
if (ot == NULL)
return NULL;
NickCore *nc = NickCore::Find(sname);
if (nc == NULL)
return NULL;
MyOper *myo;
if (obj)
myo = anope_dynamic_static_cast<MyOper *>(obj);
else
myo = new MyOper(nc->display, ot);
nc->o = myo;
Log(LOG_NORMAL, "operserv/oper") << "Tied oper " << nc->display << " to type " << ot->GetName();
return myo;
}
};
#include "modules/os_oper.h"
class CommandOSOper final
: public Command