We had a lot of discussion in Dev and a somewhat-close poll, but in
the end "Chat" was a better name than "Messages", and also has the
advantage of being shorter (which is nice for Chat.html and
Chat.plural which should be short).
CommandParser.parse has been refactored so most of its logic now
resides in CommandContext#parse.
CommandParser recursion is now a lot lighter. Instead of make a new
copy of the CommandContext, the existing one is reused.
messages.js no longer needs to exist; its functionality is now in
CommandContext#parse and CommandContext#canTalk. Its duplicate code
is gone now! :D
The inNamespace option of CommandContext#parse appears unused and has
been removed.
Users#matchesRank has been renamed Users#authAtLeast.
This unifies modjoin checks (both Room#modjoin and Room#staffRoom join
restrictions) under one function, Room#checkModjoin.
This makes it easier for commands to check whether a user should know
about a room's existence, which, previously, had been duplicated
unreliably in each command's implementation.
Fixes#2426
Roombans/blacklists have been mostly rewritten from scratch.
The new code mostly uses the same patterns as global punishments.
In addition:
- /ban has been renamed /globalban
- globalbans and blacklists now require a reason
- bans and blacklists in public rooms now show up in global modlog
- blacklist syntax is different: /blacklist and /unblacklist
- ban/blacklist display in /whoare is now more detailed
This isn't all the work that needs to be done on blacklists, but it's
the highest-priority changes.
- blacklists.tsv has been renamed room-punishments.tsv
- The format everywhere has changed to roomid:userid, rather than
roomid|userid
- roompunishments.tsv's format is now `Room ID:User ID, IPs and alts`
rather than `User ID, Room ID|IPs and alts`, which is more sane and
also cuts down on repetition of room IDs
Those are the changes that affect storage format, which are highest
priority because I don't want to support the previous format.
Other changes include:
- Punishments.roombannedIps renamed to Punishments.roomIps
- Punishments.roombannedUserids renamed to Punishments.roomUserids
- Some refactoring for ES6 destructuring
- Various bugfixes
Room#chat has now been folded into CommandParser.parse.
User#chat now directly calls CommandParser.parse, saving a line of
stack, and eliminating a function that never did much, really.
The 'root' permission used to be applied globally, but a refactor made
it apply per-room, so admins wouldn't have the permission while in
private rooms and rooms they have other roomauth in.
This once again makes 'root' a global permission.
This commit introduces Tools.html and Tools.plural, helper functions
for string construction.
Tools.html is a template tag function that escapes HTML inside the
template string.
Tools.plural is a helper function that takes a passed Number, Array,
Set, or Map and returns a string representing whether or not it's
plural.
It also starts doing some refactors of some files to make it clear how
I expect code style for template strings to look.
Previously, we used ' for IDs, " for English text, and ' for code.
We should now be using ' for IDs, ` for English text, and ` for code.
User#games no longer retains games; it instead gets them from
Rooms(roomid).game.
The Trivia tests needed to be fixed for fidelity to continue passing.
This should make it easier to hunt down that bug that's causing SockJS
not to disconnect.
(I have suspicions that it's related to websocket-raw but it's always
nice to get more data...)
User#games, previously a null-prototype roomid:game Object,
is now User#games, a roomid:game Map.
It would have been refactored into a roomid Set, but I'm afraid of
inconsistent state, even more so than I am of the corresponding
problem in Connection#inRooms. TODO: that.
This also fixes the handling of the race condition where a ladder
battle starts after a user starts a name change but before the name
change finishes.
Now, the battle is force-forfeited. Perhaps the ladder battle
should be prevented if the user changes name...
Connection#rooms, previously a null-prototype roomid:room Object,
is now Connection#inRooms, a roomid Set.
This, incidentally, makes it stop retaining rooms, which may make the
GC's job easier and may also lead to unexpected bugs if we get
inconsistent state (we often do get inconsistent state, so look
forward to that!)
The rename is mostly to put it in line with the new User#inRooms,
and for ease of greppability without running into Rooms.rooms.
Users#roomCount, previously a null-prototype roomid:count Object,
is now Users#inRooms, a roomid Set.
The new name is "inRooms" rather than "rooms" mostly for ease of
greppability. I'm kind of tired of getting Rooms.rooms when
grepping for ".rooms"
This is the next step in the process of using Maps/Sets instead of
null-proto Objects for maps/sets we add/remove to/from a lot.
I tried to get rid of the room counter completely, but that made
iterating a user's rooms take tens of milliseconds rather than
tens of microseconds, which is unacceptably slow for how often we do
that.
Not actively tracking the number of connections in a room does not
change the asymptotic complexity of any function. It slows down
leaveRoom but doesn't change its asymptotic complexity (nor does
it slow it down in any noticeable way).
leaveRoom was, incidentally, kinda gnarly code which is now a lot
cleaner. Yay!
This makes it so that when Users#setGroup is called, it looks slightly less hard-coded to be a whatever symbol a regular user is (should that symbol ever change)
This is a major refactor.
countConnection, countBattle, countPrepBattle, and countGroupChat have
been rewritten to use a new TimedCounter class that extends Map. Newer
versions of V8 seem to deal poorly with hash-mode Objects, so I hope
this approach is better.
countBattle now reports to Monitor.adminlog (console log and Upper
Staff room if it exists) instead of Monitor.log. This makes it match
countConnection, since non-programmers can't really do anything about
it anyway.
The teamValidatorChanged/Unchanged counters have been removed. They
were added to measure the proportion of times a validator has resulted
in no changes (the answer is approximately 50%).
countNetworkUse is now only active in emergency mode. It does nothing
but take up RAM normally.
countCmd has been removed entirely. The original code was buggy (only
blocking 1 out of every 15 client queries even when spammed) and
was only active in emergency mode. It should probably be rewritten
from scratch the next time we have a need for it.
This makes it so confirmed users that get their lock removed through changing to that account don't retain the lock symbol even though they're not locked
Updating these maps are now done in the specific functions Users.add,
Users.delete, Users.move, and Users.merge.
No other function should modify these maps at all.
The chatQueue previously put a reference to the room directly in the
chatQueue array. This refactors it to use a room ID.
This mostly doesn't matter much, but it's nice not to have references
to rooms outside of the room, and makes for slightly cleaner code by
not needing the weird workaround to see if the room has expired.
Namelock used to get its own symbol, but it's been rolled in with
the regular lock symbol. It's easy enough for people who need to to
tell namelocked and regularly locked users apart, anyway, and this
should be less confusing to users who aren't familiar with the
distinction.