summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/event.h12
-rw-r--r--include/modules/hostserv/add.h36
-rw-r--r--include/modules/hostserv/del.h13
-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
7 files changed, 79 insertions, 49 deletions
diff --git a/include/event.h b/include/event.h
index 0dc200c7e..774672843 100644
--- a/include/event.h
+++ b/include/event.h
@@ -875,18 +875,6 @@ namespace Event
virtual void OnInvite(User *source, Channel *c, User *targ) anope_abstract;
};
- struct CoreExport SetVhost : Events
- {
- static constexpr const char *NAME = "setvhost";
-
- using Events::Events;
-
- /** Called when a vhost is set
- * @param na The nickalias of the vhost
- */
- virtual void OnSetVhost(NickServ::Nick *na) anope_abstract;
- };
-
struct CoreExport SetDisplayedHost : Events
{
static constexpr const char *NAME = "setdisplayedhost";
diff --git a/include/modules/hostserv/add.h b/include/modules/hostserv/add.h
new file mode 100644
index 000000000..b930760ad
--- /dev/null
+++ b/include/modules/hostserv/add.h
@@ -0,0 +1,36 @@
+/*
+ * Anope IRC Services
+ *
+ * Copyright (C) 2014-2017 Anope Team <team@anope.org>
+ *
+ * This file is part of Anope. Anope is free software; you can
+ * redistribute it and/or modify it under the terms of the GNU
+ * General Public License as published by the Free Software
+ * Foundation, version 2.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see see <http://www.gnu.org/licenses/>.
+ */
+
+namespace Event
+{
+ struct CoreExport SetVhost : Events
+ {
+ static constexpr const char *NAME = "setvhost";
+
+ using Events::Events;
+
+ /** Called when a vhost is set
+ * @param source The setter of the vhost
+ * @param account The account the vhost is set on
+ * @param vhost The vhost
+ */
+ virtual void OnSetVhost(CommandSource *source, NickServ::Account *account, HostServ::VHost *vhost) anope_abstract;
+ };
+}
+
diff --git a/include/modules/hostserv/del.h b/include/modules/hostserv/del.h
index 5df29d772..05007e337 100644
--- a/include/modules/hostserv/del.h
+++ b/include/modules/hostserv/del.h
@@ -25,10 +25,19 @@ namespace Event
using Events::Events;
+ /**
+ * Called when all of a users vhosts are being deleted
+ * @param source The user deleting the vhost
+ * @param account The account the vhost is being deleted from
+ */
+ virtual void OnDeleteAllVhost(CommandSource *source, NickServ::Account *account) anope_abstract;
+
/** Called when a vhost is deleted
- * @param na The nickalias of the vhost
+ * @param source The user deleting the vhost
+ * @param account The account the vhost is being deleted from
+ * @param vhost The vhost being deleted
*/
- virtual void OnDeleteVhost(NickServ::Nick *na) anope_abstract;
+ virtual void OnDeleteVhost(CommandSource *source, NickServ::Account *account, HostServ::VHost *vhost) anope_abstract;
};
}
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);