mirror of
https://github.com/inspircd/inspircd.git
synced 2025-03-10 11:09:04 -04:00
Extract history sending logic in chanhistory to its own function.
This commit is contained in:
parent
850b7a3ace
commit
62f6e56e15
@ -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);
|
||||
}
|
||||
time_t mintime = 0;
|
||||
if (list->maxtime)
|
||||
mintime = ServerInstance->Time() - list->maxtime;
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
if (batchmanager)
|
||||
batchmanager->End(batch);
|
||||
SendHistory(localuser, memb->chan, list, mintime);
|
||||
}
|
||||
|
||||
Version GetVersion() CXX11_OVERRIDE
|
||||
|
Loading…
x
Reference in New Issue
Block a user