summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
Diffstat (limited to 'modules')
-rw-r--r--modules/hostserv/add.cpp4
-rw-r--r--modules/hostserv/del.cpp4
-rw-r--r--modules/hostserv/main/hostserv.cpp56
-rw-r--r--modules/hostserv/request.cpp3
4 files changed, 32 insertions, 35 deletions
diff --git a/modules/hostserv/add.cpp b/modules/hostserv/add.cpp
index 59eed187b..9ad20c44b 100644
--- a/modules/hostserv/add.cpp
+++ b/modules/hostserv/add.cpp
@@ -18,6 +18,7 @@
*/
#include "module.h"
+#include "modules/hostserv/add.h"
class CommandHSAdd : public Command
{
@@ -116,8 +117,7 @@ class CommandHSAdd : public Command
vhost->SetCreator(source.GetNick());
vhost->SetCreated(Anope::CurTime);
-#warning "change event to broadcast account"
- EventManager::Get()->Dispatch(&Event::SetVhost::OnSetVhost, na);
+ EventManager::Get()->Dispatch(&Event::SetVhost::OnSetVhost, &source, na->GetAccount(), vhost);
source.Reply(_("Vhost \002{0}\002 added to \002{1}\002."), mask, na->GetAccount()->GetDisplay());
}
diff --git a/modules/hostserv/del.cpp b/modules/hostserv/del.cpp
index ba13adaa9..aa34fac01 100644
--- a/modules/hostserv/del.cpp
+++ b/modules/hostserv/del.cpp
@@ -56,6 +56,7 @@ class CommandHSDel : public Command
logger.Admin(source, _("{source} used {command} on {0} to remove vhost {1}"), na->GetAccount()->GetDisplay(), vhost->Mask());
source.Reply(_("Vhost \002{0}\002 for \002{1}\002 has been removed."), vhost->Mask(), na->GetAccount()->GetDisplay());
+ EventManager::Get()->Dispatch(&Event::DeleteVhost::OnDeleteVhost, &source, na->GetAccount(), vhost);
vhost->Delete();
return;
}
@@ -69,8 +70,7 @@ class CommandHSDel : public Command
logger.Admin(source, _("{source} used {command} on {0}"), na->GetAccount()->GetDisplay());
-#warning "send account"
- EventManager::Get()->Dispatch(&Event::DeleteVhost::OnDeleteVhost, na);
+ EventManager::Get()->Dispatch(&Event::DeleteVhost::OnDeleteAllVhost, &source, na->GetAccount());
for (HostServ::VHost *v : vhosts)
v->Delete();
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
diff --git a/modules/hostserv/request.cpp b/modules/hostserv/request.cpp
index 3df0f1e97..d5a3de0ae 100644
--- a/modules/hostserv/request.cpp
+++ b/modules/hostserv/request.cpp
@@ -19,6 +19,7 @@
#include "module.h"
#include "modules/memoserv.h"
+#include "modules/hostserv/add.h"
class HostRequest : public Serialize::Object
{
@@ -301,7 +302,7 @@ class CommandHSActivate : public Command
vhost->SetCreator(source.GetNick());
vhost->SetCreated(req->GetTime());
- EventManager::Get()->Dispatch(&Event::SetVhost::OnSetVhost, na);
+ EventManager::Get()->Dispatch(&Event::SetVhost::OnSetVhost, &source, na->GetAccount(), vhost);
if (Config->GetModule(this->GetOwner())->Get<bool>("memouser") && memoserv)
memoserv->Send(source.service->nick, na->GetNick(), _("[auto memo] Your requested vHost has been approved."), true);