mirror of
https://github.com/inspircd/inspircd.git
synced 2025-03-11 19:49:02 -04:00
Implement DELLINE, allow both DELLINE and ADDLINE to take a server OR client origin
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@8468 e03df62e-2008-0410-955e-edbf42e46eb7
This commit is contained in:
parent
f2b187052b
commit
8d395f8c46
@ -738,50 +738,40 @@ void ModuleSpanningTree::OnOper(User* user, const std::string &opertype)
|
||||
|
||||
void ModuleSpanningTree::OnAddLine(XLine* line, User* user)
|
||||
{
|
||||
char data[MAXBUF];
|
||||
snprintf(data,MAXBUF,"%s %s %s %lu %lu :%s", line->type.c_str(), line->Displayable(), ServerInstance->Config->ServerName, line->set_time,
|
||||
line->duration, line->reason);
|
||||
std::deque<std::string> params;
|
||||
params.push_back(data);
|
||||
|
||||
if (!user)
|
||||
{
|
||||
/* Server-set lines */
|
||||
char data[MAXBUF];
|
||||
snprintf(data,MAXBUF,"%s %s %s %lu %lu :%s", line->type.c_str(), line->Displayable(), ServerInstance->Config->ServerName, line->set_time,
|
||||
line->duration, line->reason);
|
||||
std::deque<std::string> params;
|
||||
params.push_back(data);
|
||||
Utils->DoOneToMany(ServerInstance->Config->GetSID(), "ADDLINE", params);
|
||||
}
|
||||
else
|
||||
else if (IS_LOCAL(user))
|
||||
{
|
||||
/** XXX: This is WRONG and needs fixing.
|
||||
* We need to implement a DELLINE
|
||||
*/
|
||||
if (user && IS_LOCAL(user))
|
||||
{
|
||||
char type[8];
|
||||
snprintf(type,8,"%sLINE",line->type.c_str());
|
||||
std::string stype(type);
|
||||
char sduration[MAXBUF];
|
||||
snprintf(sduration,MAXBUF,"%ld",line->duration);
|
||||
std::deque<std::string> params;
|
||||
params.push_back(line->Displayable());
|
||||
params.push_back(ConvToStr(line->duration));
|
||||
params.push_back(std::string(":")+line->reason);
|
||||
Utils->DoOneToMany(user->uuid,stype,params);
|
||||
}
|
||||
/* User-set lines */
|
||||
Utils->DoOneToMany(user->uuid, "ADDLINE", params);
|
||||
}
|
||||
}
|
||||
|
||||
void ModuleSpanningTree::OnDelLine(XLine* line, User* user)
|
||||
{
|
||||
if (user && IS_LOCAL(user))
|
||||
char data[MAXBUF];
|
||||
snprintf(data,MAXBUF,"%s %s", line->type.c_str(), line->Displayable());
|
||||
std::deque<std::string> params;
|
||||
params.push_back(data);
|
||||
|
||||
if (!user)
|
||||
{
|
||||
/** XXX: This is WRONG and needs fixing.
|
||||
* We need to implement a DELLINE
|
||||
*/
|
||||
char type[8];
|
||||
snprintf(type,8,"%sLINE",line->type.c_str());
|
||||
std::string stype(type);
|
||||
std::deque<std::string> params;
|
||||
params.push_back(line->Displayable());
|
||||
Utils->DoOneToMany(user->uuid,stype,params);
|
||||
/* Server-unset lines */
|
||||
Utils->DoOneToMany(ServerInstance->Config->GetSID(), "DELLINE", params);
|
||||
}
|
||||
else if (IS_LOCAL(user))
|
||||
{
|
||||
/* User-unset lines */
|
||||
Utils->DoOneToMany(user->uuid, "DELLINE", params);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -331,6 +331,10 @@ class TreeSocket : public BufferedSocket
|
||||
*/
|
||||
bool AddLine(const std::string &prefix, std::deque<std::string> ¶ms);
|
||||
|
||||
/** DELLINE
|
||||
*/
|
||||
bool DelLine(const std::string &prefix, std::deque<std::string> ¶ms);
|
||||
|
||||
/** CHGNAME
|
||||
*/
|
||||
bool ChangeName(const std::string &prefix, std::deque<std::string> ¶ms);
|
||||
|
@ -532,18 +532,20 @@ bool TreeSocket::AddLine(const std::string &prefix, std::deque<std::string> &par
|
||||
xl->SetCreateTime(atoi(params[3].c_str()));
|
||||
if (Instance->XLines->AddLine(xl,NULL))
|
||||
{
|
||||
if (xl->expiry)
|
||||
if (xl->duration)
|
||||
{
|
||||
this->Instance->SNO->WriteToSnoMask('x',"%s Added %s%s on %s to expire on %s (%s).",prefix.c_str(),params[0].c_str(),params[0].length() == 1 ? "LINE" : "",
|
||||
this->Instance->SNO->WriteToSnoMask('x',"%s added %s%s on %s to expire on %s (%s).",prefix.c_str(),params[0].c_str(),params[0].length() == 1 ? "LINE" : "",
|
||||
params[1].c_str(),Instance->TimeString(xl->expiry).c_str(),params[5].c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
this->Instance->SNO->WriteToSnoMask('x',"%s Added permenant %s%s on %s (%s).",prefix.c_str(),params[0].c_str(),params[0].length() == 1 ? "LINE" : "",
|
||||
this->Instance->SNO->WriteToSnoMask('x',"%s added permenant %s%s on %s (%s).",prefix.c_str(),params[0].c_str(),params[0].length() == 1 ? "LINE" : "",
|
||||
params[1].c_str(),params[5].c_str());
|
||||
}
|
||||
params[5] = ":" + params[5];
|
||||
Utils->DoOneToAllButSender(prefix,"ADDLINE",params,prefix);
|
||||
|
||||
User* u = Instance->FindNick(prefix);
|
||||
Utils->DoOneToAllButSender(prefix, "ADDLINE", params, u ? u->server : prefix);
|
||||
}
|
||||
else
|
||||
delete xl;
|
||||
@ -556,6 +558,23 @@ bool TreeSocket::AddLine(const std::string &prefix, std::deque<std::string> &par
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TreeSocket::DelLine(const std::string &prefix, std::deque<std::string> ¶ms)
|
||||
{
|
||||
if (params.size() < 2)
|
||||
return true;
|
||||
|
||||
User* user = Instance->FindNick(prefix);
|
||||
|
||||
/* NOTE: No check needed on 'user', this function safely handles NULL */
|
||||
if (Instance->XLines->DelLine(params[0].c_str(), params[1], user))
|
||||
{
|
||||
this->Instance->SNO->WriteToSnoMask('x',"%s removed %s%s on %s.", prefix.c_str(),
|
||||
params[0].c_str(), params[0].length() == 1 ? "LINE" : "", params[1].c_str());
|
||||
Utils->DoOneToAllButSender(prefix,"DELLINE", params, prefix);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TreeSocket::ChangeName(const std::string &prefix, std::deque<std::string> ¶ms)
|
||||
{
|
||||
if (params.size() < 1)
|
||||
@ -1363,6 +1382,10 @@ bool TreeSocket::ProcessLine(std::string &line)
|
||||
Utils->SetRemoteBursting(ServerSource, false);
|
||||
return this->AddLine(prefix,params);
|
||||
}
|
||||
else if (command == "DELLINE")
|
||||
{
|
||||
return this->DelLine(prefix,params);
|
||||
}
|
||||
else if (command == "SVSNICK")
|
||||
{
|
||||
return this->ForceNick(prefix,params);
|
||||
|
Loading…
x
Reference in New Issue
Block a user