mirror of
https://github.com/inspircd/inspircd.git
synced 2025-03-10 19:19:02 -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 Module
|
||||||
, public ServerProtocol::BroadcastEventListener
|
, public ServerProtocol::BroadcastEventListener
|
||||||
{
|
{
|
||||||
|
private:
|
||||||
HistoryMode m;
|
HistoryMode m;
|
||||||
bool sendnotice;
|
bool sendnotice;
|
||||||
UserModeReference botmode;
|
UserModeReference botmode;
|
||||||
@ -123,6 +124,31 @@ class ModuleChanHistory
|
|||||||
IRCv3::Batch::Batch batch;
|
IRCv3::Batch::Batch batch;
|
||||||
IRCv3::ServerTime::API servertimemanager;
|
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:
|
public:
|
||||||
ModuleChanHistory()
|
ModuleChanHistory()
|
||||||
: ServerProtocol::BroadcastEventListener(this)
|
: ServerProtocol::BroadcastEventListener(this)
|
||||||
@ -175,9 +201,6 @@ class ModuleChanHistory
|
|||||||
HistoryList* list = m.ext.get(memb->chan);
|
HistoryList* list = m.ext.get(memb->chan);
|
||||||
if (!list)
|
if (!list)
|
||||||
return;
|
return;
|
||||||
time_t mintime = 0;
|
|
||||||
if (list->maxtime)
|
|
||||||
mintime = ServerInstance->Time() - list->maxtime;
|
|
||||||
|
|
||||||
if ((sendnotice) && (!batchcap.get(localuser)))
|
if ((sendnotice) && (!batchcap.get(localuser)))
|
||||||
{
|
{
|
||||||
@ -187,27 +210,11 @@ class ModuleChanHistory
|
|||||||
memb->WriteNotice(message);
|
memb->WriteNotice(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (batchmanager)
|
time_t mintime = 0;
|
||||||
{
|
if (list->maxtime)
|
||||||
batchmanager->Start(batch);
|
mintime = ServerInstance->Time() - list->maxtime;
|
||||||
batch.GetBatchStartMessage().PushParamRef(memb->chan->name);
|
|
||||||
}
|
|
||||||
|
|
||||||
for(std::deque<HistoryItem>::iterator i = list->lines.begin(); i != list->lines.end(); ++i)
|
SendHistory(localuser, memb->chan, list, mintime);
|
||||||
{
|
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Version GetVersion() CXX11_OVERRIDE
|
Version GetVersion() CXX11_OVERRIDE
|
||||||
|
Loading…
x
Reference in New Issue
Block a user