From e7dd7159b1e1ab5b3edabc44ece5338672f8fbb4 Mon Sep 17 00:00:00 2001 From: Adam Date: Sun, 9 Oct 2016 19:51:39 -0400 Subject: Make vhosts assignable to accounts, not nicks. Allow multiple vhosts per account. --- modules/hostserv/request.cpp | 42 +++++++++++++++++++----------------------- 1 file changed, 19 insertions(+), 23 deletions(-) (limited to 'modules/hostserv/request.cpp') diff --git a/modules/hostserv/request.cpp b/modules/hostserv/request.cpp index 2bad26b48..2e9ccd41b 100644 --- a/modules/hostserv/request.cpp +++ b/modules/hostserv/request.cpp @@ -24,7 +24,7 @@ class HostRequest : public Serialize::Object { friend class HostRequestType; - NickServ::Nick *na = nullptr; + NickServ::Account *acc = nullptr; Anope::string ident, host; time_t time = 0; @@ -34,8 +34,8 @@ class HostRequest : public Serialize::Object HostRequest(Serialize::TypeBase *type) : Serialize::Object(type) { } HostRequest(Serialize::TypeBase *type, Serialize::ID id) : Serialize::Object(type, id) { } - NickServ::Nick *GetNick(); - void SetNick(NickServ::Nick *na); + NickServ::Account *GetAccount(); + void SetAccount(NickServ::Account *); Anope::string GetIdent(); void SetIdent(const Anope::string &i); @@ -50,12 +50,12 @@ class HostRequest : public Serialize::Object class HostRequestType : public Serialize::Type { public: - Serialize::ObjectField na; + Serialize::ObjectField acc; Serialize::Field ident, host; Serialize::Field time; HostRequestType(Module *me) : Serialize::Type(me) - , na(this, "na", &HostRequest::na, true) + , acc(this, "acc", &HostRequest::acc, true) , ident(this, "ident", &HostRequest::ident) , host(this, "host", &HostRequest::host) , time(this, "time", &HostRequest::time) @@ -63,14 +63,14 @@ class HostRequestType : public Serialize::Type } }; -NickServ::Nick *HostRequest::GetNick() +NickServ::Account *HostRequest::GetAccount() { - return Get(&HostRequestType::na); + return Get(&HostRequestType::acc); } -void HostRequest::SetNick(NickServ::Nick *na) +void HostRequest::SetAccount(NickServ::Account *acc) { - Set(&HostRequestType::na, na); + Set(&HostRequestType::acc, acc); } Anope::string HostRequest::GetIdent() @@ -145,12 +145,6 @@ class CommandHSRequest : public Command } User *u = source.GetUser(); - NickServ::Nick *na = NickServ::FindNick(source.GetNick()); - if (!na || na->GetAccount() != source.GetAccount()) - { - source.Reply(_("Access denied.")); //XXX with nonickownership this should be allowed. - return; - } if (source.GetAccount()->HasFieldS("UNCONFIRMED")) { @@ -218,8 +212,12 @@ class CommandHSRequest : public Command return; } - HostRequest *req = Serialize::New(); - req->SetNick(na); + HostRequest *req = u->Account()->GetRef(); + if (req != nullptr) + req->Delete(); // delete old request + + req = Serialize::New(); + req->SetAccount(u->Account()); req->SetIdent(user); req->SetHost(host); req->SetTime(Anope::CurTime); @@ -264,7 +262,7 @@ class CommandHSActivate : public Command return; } - HostRequest *req = na->GetExt("hostrequest"); + HostRequest *req = na->GetAccount()->GetRef(); if (!req) { source.Reply(_("\002{0}\002 does not have a pending vhost request."), na->GetNick()); @@ -278,14 +276,12 @@ class CommandHSActivate : public Command return; } - vhost->SetOwner(na); + vhost->SetOwner(na->GetAccount()); vhost->SetIdent(req->GetIdent()); vhost->SetHost(req->GetHost()); vhost->SetCreator(source.GetNick()); vhost->SetCreated(req->GetTime()); - na->SetVHost(vhost); - EventManager::Get()->Dispatch(&Event::SetVhost::OnSetVhost, na); if (Config->GetModule(this->GetOwner())->Get("memouser") && memoserv) @@ -335,7 +331,7 @@ class CommandHSReject : public Command return; } - HostRequest *req = na->GetExt("hostrequest"); + HostRequest *req = na->GetAccount()->GetRef(); if (!req) { source.Reply(_("\002{0}\002 does not have a pending vhost request."), na->GetNick()); @@ -393,7 +389,7 @@ class CommandHSWaiting : public Command ListFormatter::ListEntry entry; entry["Number"] = stringify(display_counter); - entry["Nick"] = hr->GetNick()->GetNick(); + entry["Nick"] = hr->GetAccount()->GetDisplay(); if (!hr->GetIdent().empty()) entry["Vhost"] = hr->GetIdent() + "@" + hr->GetHost(); else -- cgit