summaryrefslogtreecommitdiff
path: root/modules/hostserv/main/hostserv.cpp
diff options
context:
space:
mode:
authorAdam <Adam@anope.org>2017-11-19 13:24:48 -0500
committerAdam <Adam@anope.org>2017-11-19 13:24:48 -0500
commit3fb9bb5118a5c3c6c916a48feed0e069867f3133 (patch)
tree16631512dbcff5ec3146d4f60a30e732ab6c64b1 /modules/hostserv/main/hostserv.cpp
parentd616bf3328eca31cb46b5d54e656b556dd513ed3 (diff)
hostserv: expand events for newer vhost model
Diffstat (limited to 'modules/hostserv/main/hostserv.cpp')
-rw-r--r--modules/hostserv/main/hostserv.cpp56
1 files changed, 26 insertions, 30 deletions
diff --git a/modules/hostserv/main/hostserv.cpp b/modules/hostserv/main/hostserv.cpp
index ceca2a5f4..28ec727f0 100644
--- a/modules/hostserv/main/hostserv.cpp
+++ b/modules/hostserv/main/hostserv.cpp
@@ -21,6 +21,7 @@
#include "modules/help.h"
#include "modules/nickserv/update.h"
#include "modules/nickserv/info.h"
+#include "modules/hostserv/add.h"
#include "modules/hostserv/del.h"
#include "vhosttype.h"
@@ -111,47 +112,42 @@ class HostServCore : public Module
{
}
- void OnSetVhost(NickServ::Nick *na) override
+ void OnSetVhost(CommandSource *source, NickServ::Account *account, HostServ::VHost *vhost) override
{
- if (Config->GetModule(this)->Get<bool>("activate_on_set"))
- {
- User *u = User::Find(na->GetNick());
-
- if (u && u->Account() == na->GetAccount())
- {
- HostServ::VHost *vhost = HostServ::FindVHost(u->Account());
-
- if (vhost == nullptr)
- return;
+ if (!Config->GetModule(this)->Get<bool>("activate_on_set"))
+ return;
- IRCD->Send<messages::VhostSet>(u, vhost->GetIdent(), vhost->GetHost());
+ for (User *u : account->users)
+ {
+ IRCD->Send<messages::VhostSet>(u, vhost->GetIdent(), vhost->GetHost());
- u->vhost = vhost->GetHost();
- u->UpdateHost();
+ u->vhost = vhost->GetHost();
+ u->UpdateHost();
- if (IRCD->CanSetVIdent && !vhost->GetIdent().empty())
- u->SetVIdent(vhost->GetIdent());
+ if (IRCD->CanSetVIdent && !vhost->GetIdent().empty())
+ u->SetVIdent(vhost->GetIdent());
- if (HostServ)
- {
- if (!vhost->GetIdent().empty())
- u->SendMessage(*HostServ, _("Your vhost of \002{0}\002@\002{1}\002 is now activated."), vhost->GetIdent(), vhost->GetHost());
- else
- u->SendMessage(*HostServ, _("Your vhost of \002{0}\002 is now activated."), vhost->GetHost());
- }
+ if (HostServ)
+ {
+ if (!vhost->GetIdent().empty())
+ u->SendMessage(*HostServ, _("Your vhost of \002{0}\002@\002{1}\002 is now activated."), vhost->GetIdent(), vhost->GetHost());
+ else
+ u->SendMessage(*HostServ, _("Your vhost of \002{0}\002 is now activated."), vhost->GetHost());
}
}
}
- void OnDeleteVhost(NickServ::Nick *na) override
+ void OnDeleteAllVhost(CommandSource *source, NickServ::Account *account) override
{
- if (Config->GetModule(this)->Get<bool>("activate_on_set"))
- {
- User *u = User::Find(na->GetNick());
+ if (!Config->GetModule(this)->Get<bool>("activate_on_set"))
+ return;
- if (u && u->Account() == na->GetAccount())
- IRCD->Send<messages::VhostDel>(u);
- }
+ for (User *u : account->users)
+ IRCD->Send<messages::VhostDel>(u);
+ }
+
+ void OnDeleteVhost(CommandSource *source, NickServ::Account *account, HostServ::VHost *vhost) override
+ {
}
void OnNickInfo(CommandSource &source, NickServ::Nick *na, InfoFormatter &info, bool show_hidden) override