diff options
| author | 2026-03-11 21:54:40 +0000 | |
|---|---|---|
| committer | 2026-03-12 00:18:06 +0000 | |
| commit | fcb3090055429a108b9837dbd4ba505d9c291129 (patch) | |
| tree | 5c55fd77d3b24adeda54e250d91b2a44badc9c5d /modules/spanningtree/fjoin.cpp | |
| parent | Mark all acting extbans as MATCH_REQUIRE_CHANNEL. (diff) | |
Rework sending server protocol messages.
- Replace CmdBuilder with MessageBuilder. This has a less footgun
API. All message building has to go through this now so we can
implement other message formats in the future.
- Replace the message parsing in WriteLine with an analogue to
PreProcessOldProtocolMessage. This should be much faster.
- Move parameter translation from the core to spanningtree.
- Change EncodeParameter to return the value instead of updating
in place.
- Replace the OnBuild*Message events with one OnServerMessage that
can now access all parts of the message and change them.
Diffstat (limited to 'modules/spanningtree/fjoin.cpp')
| -rw-r--r-- | modules/spanningtree/fjoin.cpp | 52 |
1 files changed, 29 insertions, 23 deletions
diff --git a/modules/spanningtree/fjoin.cpp b/modules/spanningtree/fjoin.cpp index 565032384..5aa285077 100644 --- a/modules/spanningtree/fjoin.cpp +++ b/modules/spanningtree/fjoin.cpp @@ -193,8 +193,7 @@ CmdResult CommandFJoin::Handle(User* srcuser, Params& params) ProcessModeUUIDPair(item, sourceserver, chan, modechangelistptr, fwdfjoin); } - fwdfjoin.finalize(); - fwdfjoin.Forward(sourceserver->GetRoute()); + fwdfjoin.Broadcast(sourceserver->GetRoute()); // Set prefix modes on their users if we lost the FJOIN or had equal TS if (apply_other_sides_modes) @@ -310,33 +309,40 @@ void CommandFJoin::LowerTS(Channel* chan, time_t TS, const std::string& newname) chan->setby.clear(); } -CommandFJoin::Builder::Builder(Channel* chan, TreeServer* source) - : CmdBuilder(source, "FJOIN") +CommandFJoin::Builder::Builder(Channel* chan, TreeServer* server) + : MessageBuilder(server, "FJOIN") { - push(chan->name).push_int(chan->age).push_raw(" +"); - pos = str().size(); - push_raw(chan->ChanModes(true)).push_raw(" :"); -} + Push(chan->name, chan->age, "+"); -void CommandFJoin::Builder::add(Membership* memb, std::string::const_iterator mbegin, std::string::const_iterator mend) -{ - push_raw(mbegin, mend).push_raw(',').push_raw(memb->user->uuid); - push_raw(':').push_raw_int(memb->id); - push_raw('/').push_raw_int(memb->created); - push_raw(' '); -} + CommandBase::Params modeparams; + for (const auto& [_, mh] : ServerInstance->Modes.GetModes(MODETYPE_CHANNEL)) + { + if (!chan->IsModeSet(mh)) + continue; -void CommandFJoin::Builder::clear() -{ - content.erase(pos); - push_raw(" :"); + this->parameters.back().push_back(mh->GetModeChar()); + + auto* pm = mh->IsParameterMode(); + if (pm) + { + auto& param = modeparams.emplace_back(); + pm->GetParameter(chan, param); + } + } + PushParams(modeparams); + Push(""); } -const std::string& CommandFJoin::Builder::finalize() +void CommandFJoin::Builder::add(Membership* memb, std::string::const_iterator mbegin, std::string::const_iterator mend) { - if (content.back() == ' ') - content.pop_back(); - return str(); + auto& last = this->parameters.back(); + if (!last.empty()) + last.push_back(' '); + + last.append(std::string(mbegin, mend)) + .append(",").append(memb->user->uuid) + .append(":").append(ConvToStr(memb->id)) + .append("/").append(ConvToStr(memb->created)); } void FwdFJoinBuilder::add(Membership* memb, std::string::const_iterator mbegin, std::string::const_iterator mend) |
