summaryrefslogtreecommitdiff
path: root/src/modules
diff options
context:
space:
mode:
authorPeter Powell <petpow@saberuk.com>2019-07-21 14:13:07 +0100
committerPeter Powell <petpow@saberuk.com>2019-07-21 14:13:07 +0100
commit62f6e56e158a3c147cd1395dab790f918ce2d1b4 (patch)
tree96505f1030bf08cb7b67991b8d6c2a29150f51b5 /src/modules
parent850b7a3ace862101a944a9332d72b6bd597c17cc (diff)
Extract history sending logic in chanhistory to its own function.
Diffstat (limited to 'src/modules')
-rw-r--r--src/modules/m_chanhistory.cpp53
1 files changed, 30 insertions, 23 deletions
diff --git a/src/modules/m_chanhistory.cpp b/src/modules/m_chanhistory.cpp
index 227fda3c2..ef7b2b177 100644
--- a/src/modules/m_chanhistory.cpp
+++ b/src/modules/m_chanhistory.cpp
@@ -114,6 +114,7 @@ class ModuleChanHistory
: public Module
, public ServerProtocol::BroadcastEventListener
{
+ private:
HistoryMode m;
bool sendnotice;
UserModeReference botmode;
@@ -123,6 +124,31 @@ class ModuleChanHistory
IRCv3::Batch::Batch batch;
IRCv3::ServerTime::API servertimemanager;
+ void SendHistory(LocalUser* user, Channel* channel, HistoryList* list, time_t mintime)
+ {
+ if (batchmanager)
+ {
+ batchmanager->Start(batch);
+ batch.GetBatchStartMessage().PushParamRef(channel->name);
+ }
+
+ for(std::deque<HistoryItem>::iterator i = list->lines.begin(); i != list->lines.end(); ++i)
+ {
+ const HistoryItem& item = *i;
+ if (item.ts >= mintime)
+ {
+ ClientProtocol::Messages::Privmsg msg(ClientProtocol::Messages::Privmsg::nocopy, item.sourcemask, channel, item.text);
+ if (servertimemanager)
+ servertimemanager->Set(msg, item.ts);
+ batch.AddToBatch(msg);
+ user->Send(ServerInstance->GetRFCEvents().privmsg, msg);
+ }
+ }
+
+ if (batchmanager)
+ batchmanager->End(batch);
+ }
+
public:
ModuleChanHistory()
: ServerProtocol::BroadcastEventListener(this)
@@ -175,9 +201,6 @@ class ModuleChanHistory
HistoryList* list = m.ext.get(memb->chan);
if (!list)
return;
- time_t mintime = 0;
- if (list->maxtime)
- mintime = ServerInstance->Time() - list->maxtime;
if ((sendnotice) && (!batchcap.get(localuser)))
{
@@ -187,27 +210,11 @@ class ModuleChanHistory
memb->WriteNotice(message);
}
- if (batchmanager)
- {
- batchmanager->Start(batch);
- batch.GetBatchStartMessage().PushParamRef(memb->chan->name);
- }
-
- for(std::deque<HistoryItem>::iterator i = list->lines.begin(); i != list->lines.end(); ++i)
- {
- const HistoryItem& item = *i;
- if (item.ts >= mintime)
- {
- ClientProtocol::Messages::Privmsg msg(ClientProtocol::Messages::Privmsg::nocopy, item.sourcemask, memb->chan, item.text);
- if (servertimemanager)
- servertimemanager->Set(msg, item.ts);
- batch.AddToBatch(msg);
- localuser->Send(ServerInstance->GetRFCEvents().privmsg, msg);
- }
- }
+ time_t mintime = 0;
+ if (list->maxtime)
+ mintime = ServerInstance->Time() - list->maxtime;
- if (batchmanager)
- batchmanager->End(batch);
+ SendHistory(localuser, memb->chan, list, mintime);
}
Version GetVersion() CXX11_OVERRIDE