diff options
author | Attila Molnar <attilamolnar@hush.com> | 2014-06-11 14:46:53 +0200 |
---|---|---|
committer | Attila Molnar <attilamolnar@hush.com> | 2014-06-11 14:46:53 +0200 |
commit | da20866cee3bf46b3752122736b684f08e5dba36 (patch) | |
tree | 17c17866ecad46b17089d7d48af5a4f59ef04fe5 /src/modules/m_spanningtree | |
parent | 612629df8b915a0c87dbd6c29ad305aaedcbe0fd (diff) |
m_spanningtree Send and parse FJOINs with membership ids
Diffstat (limited to 'src/modules/m_spanningtree')
-rw-r--r-- | src/modules/m_spanningtree/commands.h | 4 | ||||
-rw-r--r-- | src/modules/m_spanningtree/fjoin.cpp | 30 |
2 files changed, 27 insertions, 7 deletions
diff --git a/src/modules/m_spanningtree/commands.h b/src/modules/m_spanningtree/commands.h index e26b2b8eb..741954392 100644 --- a/src/modules/m_spanningtree/commands.h +++ b/src/modules/m_spanningtree/commands.h @@ -137,6 +137,10 @@ class CommandFJoin : public ServerCommand class Builder : public CmdBuilder { + /** Maximum possible Membership::Id length in decimal digits, used for determining whether a user will fit into + * a message or not + */ + static const size_t membid_max_digits = 20; static const size_t maxline = 480; std::string::size_type pos; diff --git a/src/modules/m_spanningtree/fjoin.cpp b/src/modules/m_spanningtree/fjoin.cpp index 7deb04b31..1992d3904 100644 --- a/src/modules/m_spanningtree/fjoin.cpp +++ b/src/modules/m_spanningtree/fjoin.cpp @@ -55,10 +55,12 @@ CmdResult CommandFJoin::Handle(User* srcuser, std::vector<std::string>& params) * who succeed at internets. :-) * * Syntax: - * :<sid> FJOIN <chan> <TS> <modes> :[[modes,]<uuid> [[modes,]<uuid> ... ]] - * The last parameter is a list consisting of zero or more (modelist, uuid) - * pairs (permanent channels may have zero users). The mode list for each - * user is a concatenation of the mode letters the user has on the channel + * :<sid> FJOIN <chan> <TS> <modes> :[<member> [<member> ...]] + * The last parameter is a list consisting of zero or more channel members + * (permanent channels may have zero users). Each entry on the list is in the + * following format: + * [[<modes>,]<uuid>[:<membid>] + * <modes> is a concatenation of the mode letters the user has on the channel * (e.g.: "ov" if the user is opped and voiced). The order of the mode letters * are not important but if a server ecounters an unknown mode letter, it will * drop the link to avoid desync. @@ -67,6 +69,9 @@ CmdResult CommandFJoin::Handle(User* srcuser, std::vector<std::string>& params) * had no prefix modes on the channel, InspIRCd 2.2 and later does not require * a comma in this case anymore. * + * <membid> is a positive integer representing the id of the membership. + * If not present (in FJOINs coming from pre-1205 servers), 0 is assumed. + * */ time_t TS = ServerCommand::ExtractTS(params[1]); @@ -166,7 +171,8 @@ void CommandFJoin::ProcessModeUUIDPair(const std::string& item, TreeSocket* src_ std::string::size_type comma = item.find(','); // Comma not required anymore if the user has no modes - std::string uuid = ((comma == std::string::npos) ? item : item.substr(comma+1)); + const std::string::size_type ubegin = (comma == std::string::npos ? 0 : comma+1); + std::string uuid(item, ubegin, UIDGenerator::UUID_LENGTH); User* who = ServerInstance->FindUUID(uuid); if (!who) { @@ -196,7 +202,16 @@ void CommandFJoin::ProcessModeUUIDPair(const std::string& item, TreeSocket* src_ } } - chan->ForceJoin(who, NULL, route_back_again->bursting); + Membership* memb = chan->ForceJoin(who, NULL, route_back_again->bursting); + if (!memb) + return; + + // Assign the id to the new Membership + Membership::Id membid = 0; + const std::string::size_type colon = item.rfind(':'); + if (colon != std::string::npos) + membid = Membership::IdFromString(item.substr(colon+1)); + memb->id = membid; } void CommandFJoin::RemoveStatus(Channel* c) @@ -269,12 +284,13 @@ CommandFJoin::Builder::Builder(Channel* chan) void CommandFJoin::Builder::add(Membership* memb) { push_raw(memb->modes).push_raw(',').push_raw(memb->user->uuid); + push_raw(':').push_raw_int(memb->id); push_raw(' '); } bool CommandFJoin::Builder::has_room(Membership* memb) const { - return ((str().size() + memb->modes.size() + UIDGenerator::UUID_LENGTH + 2) <= maxline); + return ((str().size() + memb->modes.size() + UIDGenerator::UUID_LENGTH + 2 + membid_max_digits + 1) <= maxline); } void CommandFJoin::Builder::clear() |