From 687778b72e31322a73b2e2e17af6bd0f2a2561bc Mon Sep 17 00:00:00 2001
From: Peter Powell <petpow@saberuk.com>
Date: Sun, 17 Nov 2019 22:06:36 +0000
Subject: Allow Channel::WriteNotice send to other servers and status ranks.

---
 src/modules/m_ojoin.cpp              | 6 +-----
 src/modules/m_spanningtree/fjoin.cpp | 9 +++++++--
 src/modules/m_timedbans.cpp          | 8 ++------
 src/modules/m_uninvite.cpp           | 5 +----
 4 files changed, 11 insertions(+), 17 deletions(-)

(limited to 'src/modules')

diff --git a/src/modules/m_ojoin.cpp b/src/modules/m_ojoin.cpp
index c0626ec69..e3366056d 100644
--- a/src/modules/m_ojoin.cpp
+++ b/src/modules/m_ojoin.cpp
@@ -57,11 +57,7 @@ class CommandOjoin : public SplitCommand
 			ServerInstance->SNO->WriteGlobalSno('a', user->nick+" used OJOIN to join "+channel->name);
 
 			if (notice)
-			{
-				const std::string msg = user->nick + " joined on official network business.";
-				channel->WriteNotice(msg);
-				ServerInstance->PI->SendChannelNotice(channel, 0, msg);
-			}
+				channel->WriteNotice(user->nick + " joined on official network business.");
 		}
 		else
 		{
diff --git a/src/modules/m_spanningtree/fjoin.cpp b/src/modules/m_spanningtree/fjoin.cpp
index 6305e5af8..02d985ef3 100644
--- a/src/modules/m_spanningtree/fjoin.cpp
+++ b/src/modules/m_spanningtree/fjoin.cpp
@@ -276,8 +276,13 @@ void CommandFJoin::RemoveStatus(Channel* c)
 void CommandFJoin::LowerTS(Channel* chan, time_t TS, const std::string& newname)
 {
 	if (Utils->AnnounceTSChange)
-		chan->WriteNotice(InspIRCd::Format("Creation time of %s changed from %s to %s", newname.c_str(),
-			InspIRCd::TimeString(chan->age).c_str(), InspIRCd::TimeString(TS).c_str()));
+	{
+		// WriteNotice is not used here because the message only needs to go to the local server.
+		const std::string tsmessage  = InspIRCd::Format("Creation time of %s changed from %s to %s", newname.c_str(),
+			InspIRCd::TimeString(chan->age).c_str(), InspIRCd::TimeString(TS).c_str());
+		ClientProtocol::Messages::Privmsg privmsg(ClientProtocol::Messages::Privmsg::nocopy, ServerInstance->FakeClient, chan, tsmessage, MSG_NOTICE);
+		chan->Write(ServerInstance->GetRFCEvents().privmsg, privmsg);
+	}
 
 	// While the name is equal in case-insensitive compare, it might differ in case; use the remote version
 	chan->name = newname;
diff --git a/src/modules/m_timedbans.cpp b/src/modules/m_timedbans.cpp
index ef3382e4b..eb3c47527 100644
--- a/src/modules/m_timedbans.cpp
+++ b/src/modules/m_timedbans.cpp
@@ -128,9 +128,7 @@ class CommandTban : public Command
 		PrefixMode* mh = ServerInstance->Modes->FindPrefixMode('h');
 		char pfxchar = (mh && mh->name == "halfop") ? mh->GetPrefix() : '@';
 
-		ClientProtocol::Messages::Privmsg notice(ServerInstance->FakeClient, channel, message, MSG_NOTICE);
-		channel->Write(ServerInstance->GetRFCEvents().privmsg, notice, pfxchar);
-		ServerInstance->PI->SendChannelNotice(channel, pfxchar, message);
+		channel->WriteNotice(message, pfxchar);
 		return CMD_SUCCESS;
 	}
 
@@ -221,9 +219,7 @@ class ModuleTimedBans : public Module
 			PrefixMode* mh = ServerInstance->Modes->FindPrefixMode('h');
 			char pfxchar = (mh && mh->name == "halfop") ? mh->GetPrefix() : '@';
 
-			ClientProtocol::Messages::Privmsg notice(ClientProtocol::Messages::Privmsg::nocopy, ServerInstance->FakeClient, cr, message, MSG_NOTICE);
-			cr->Write(ServerInstance->GetRFCEvents().privmsg, notice, pfxchar);
-			ServerInstance->PI->SendChannelNotice(cr, pfxchar, message);
+			cr->WriteNotice(message, pfxchar);
 
 			Modes::ChangeList setban;
 			setban.push_remove(ServerInstance->Modes->FindMode('b', MODETYPE_CHANNEL), mask);
diff --git a/src/modules/m_uninvite.cpp b/src/modules/m_uninvite.cpp
index ae1553a23..ec5653806 100644
--- a/src/modules/m_uninvite.cpp
+++ b/src/modules/m_uninvite.cpp
@@ -100,10 +100,7 @@ class CommandUninvite : public Command
 			user->WriteRemoteNumeric(n);
 
 			lu->WriteNumeric(RPL_UNINVITED, InspIRCd::Format("You were uninvited from %s by %s", c->name.c_str(), user->nick.c_str()));
-
-			std::string msg = "*** " + user->nick + " uninvited " + u->nick + ".";
-			c->WriteNotice(msg);
-			ServerInstance->PI->SendChannelNotice(c, 0, msg);
+			c->WriteNotice(InspIRCd::Format("*** %s uninvited %s.", user->nick.c_str(), u->nick.c_str()));
 		}
 
 		return CMD_SUCCESS;
-- 
cgit v1.2.3