X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fcoremods%2Fcore_channel%2Fcmd_invite.cpp;h=7bf669b296837b469ea56072acf4209e34ad7589;hb=127fe6ed1076c294e01925e4fa8ab2bd64c1b0e0;hp=3260d7862edd0d018f9fcafda1a4255f115612bd;hpb=34f1ef3c9b2a50bbeb3c97eb9f4d5e07895e27db;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/coremods/core_channel/cmd_invite.cpp b/src/coremods/core_channel/cmd_invite.cpp index 3260d7862..7bf669b29 100644 --- a/src/coremods/core_channel/cmd_invite.cpp +++ b/src/coremods/core_channel/cmd_invite.cpp @@ -36,7 +36,7 @@ CmdResult CommandInvite::Handle (const std::vector& parameters, Use { ModResult MOD_RESULT; - if (parameters.size() == 2 || parameters.size() == 3) + if (parameters.size() >= 2) { User* u; if (IS_LOCAL(user)) @@ -46,12 +46,12 @@ CmdResult CommandInvite::Handle (const std::vector& parameters, Use Channel* c = ServerInstance->FindChan(parameters[1]); time_t timeout = 0; - if (parameters.size() == 3) + if (parameters.size() >= 3) { if (IS_LOCAL(user)) timeout = ServerInstance->Time() + InspIRCd::Duration(parameters[2]); - else - timeout = ConvToInt(parameters[2]); + else if (parameters.size() > 3) + timeout = ConvToInt(parameters[3]); } if ((!c) || (!u) || (u->registered != REG_ALL)) @@ -60,6 +60,19 @@ CmdResult CommandInvite::Handle (const std::vector& parameters, Use return CMD_FAILURE; } + // Verify channel timestamp if the INVITE is coming from a remote server + if (!IS_LOCAL(user)) + { + // Remote INVITE commands must carry a channel timestamp + if (parameters.size() < 3) + return CMD_INVALID; + + // Drop the invite if our channel TS is lower + time_t RemoteTS = ConvToInt(parameters[2]); + if (c->age < RemoteTS) + return CMD_FAILURE; + } + if ((IS_LOCAL(user)) && (!c->HasUser(user))) { user->WriteNumeric(ERR_NOTONCHANNEL, "%s :You're not on that channel!", c->name.c_str()); @@ -101,7 +114,11 @@ CmdResult CommandInvite::Handle (const std::vector& parameters, Use } if (IS_LOCAL(user)) + { user->WriteNumeric(RPL_INVITING, "%s %s", u->nick.c_str(),c->name.c_str()); + if (u->IsAway()) + user->WriteNumeric(RPL_AWAY, "%s :%s", u->nick.c_str(), u->awaymsg.c_str()); + } if (ServerInstance->Config->AnnounceInvites != ServerConfig::INVITE_ANNOUNCE_NONE) {