- `writeUpdate` state is now stored in a global variable, so hotpatching doesn't crash it
- throttling now writes on the tail (so two throttled `writeUpdate` calls will write one update, not two)
- room settings, punishments, and helptickets are now throttled
This introduces a new function, `setParent`, to handle the details
of setting up subrooms.
`roomid`, `parent`, and `subRooms` are now read-only, so they can't
be accidentally be set directly rather than through their setters
(`rename`, `setParent`, and `clearSubRooms`).
I don't think setters should be used for this, because I think it's
important to be clear that `rename` and `setParent` will change a lot
of other state and induce network activity.
We're skipping two major typescript-eslint versions, so there are a
bunch of changes here, including:
- it's catching a lot of things it didn't catch in the past, for
reasons unclear to me
- no-unused-vars has to be explicitly disabled in global-types now
- a lot of `ts-ignore`s were never necessary and have been fixed
- Crashlogger can now handle being thrown things that aren't errors.
This has never been a problem in the past, but to satisfy TypeScript
we might as well not die in a fire on the off chance someone tries to
`throw null` or something.
`room.settings.autojoin` and `room.settings.staffAutojoin` are now
merged.
Staff autojoin rooms are now simply regular autojoin rooms with a
modjoin setting. You simply autojoin all autojoin modjoin rooms that
you're allowed to join.
Fixes#7413
This doesn't really have any nice-to-have automatic restoration
features but it should be all the important parts.
`user.group` no longer exists, and has been replaced with
`user.tempGroup`, which now applies both to temporary promotions of
unregistered users, as well as temporary hidden ranks of auth.
At the moment, the staff intro and pending requests only appear on manual joins, not on autojoin. This is because `user.can('mute', null, this)` results false when it is run since the user is not yet logged in. This change creates a new method for generating the staff intro that is run after the user is fully logged in. It also modifies the original `getIntroMessage` so that the staff intro and pending requests still appear on manual joins.
Co-authored-by: Guangcong Luo <guangcongluo@gmail.com>
We were previously using `type Foo = import('bar').Foo` which works
actually equally well, because sucrase didn't support `import type`,
but now it does!
This removes any extra unnecessary newlines at the end of each message sent to each client, and will always handle all messages assigned to the buffer properly.
This will actually destroy groupchats when a user is locked/globally banned, which to my understanding is the intended behavior.
`continue`ing when a room isn't persistent makes no sense, since groupchats are by definition not persistent.
NOTE: This is changes the semantics of `hidenext`/`ionext` from
applying to the next created *battle* to applying to the next
created *search*/*challenge*.
They were only ever kept separate because of GlobalRoom. It might be
useful to support rooms that aren't ChatRooms, but we've been chucking
properties into either BasicChatRoom or BasicRoom essentially at
random, so I think it makes sense to wait until we actually have a
use-case for a non-Chat room before carefully deciding which properties
belong where.
I couldn't completely remove the global room in one commit, but this
solves basically every problem with it by making it no longer a `Room`.
In particular, this means:
- It's no longer of type `Room`
- It's no longer in the `Rooms.rooms` table
- Its class name is now `GlobalRoomState` rather than `GlobalRoom`
- It no longer tracks its own user list (online user count is now
provided by `Users.onlineCount`)
- It's no longer a socket channel (there's new syntax for "send this
message to every user")
This implements two big changes:
- All settings shared between `room.chatRoomData` and `room` have been
merged into `room.settings` (so, for instance, `room.slowchat` is now
only `room.settings.slowchat`).
This makes it so we never have to worry about them getting "out of
sync".
- Checking to see if a room is persistent is now `if (room.persist)`
instead of `if (room.chatRoomData)`
- `Rooms.global.writeChatRoomData()` is now rarely called directly;
there's a new `room.saveSettings()` which will handle it for you.
- All properties of `room.settings` are now optional (except
`title`).
- There's a new file `user-groups.ts` which handles authority.
- `room.auth` and `Users.globalAuth` are now
`Auth extends Map<ID, GroupSymbol>` objects.
- `room.auth` is now always defined, removing the need for
`room.auth?.[userid]` workarounds.
- A lot of code relating to usergroups and permission checks have
been refactored.
Co-authored-by: Guangcong Luo <guangcongluo@gmail.com>
PR #6781 only fixed one of the crashes; the real problem was that the
code expects aliases to be an empty array if rooms have no aliases,
which have multiple flaws including unnecessarily taking up JSON
space.
This is a really minor thing, but fewer words tend to make
sentences more readable, and crash messages should focus more
on why something crashed than the crash itself.
Guests usually don't appear in join/leave/rename messages, but it's
possible for a bot to /trn to a guest nick with an assertion from the
login server and trigger a leave message for a guest nick to get sent.
This shouldn't have any consequences for the official client, but can
crash bots that keep state for users.
Custom room rank symbols will now override all other ranks in the
userlist.
Their permissions now also fall back to global permissions.
(Also fix an obscure crash with custom rank symbols.)
Previously, if you gave e.g. roomvoice to a global moderator, that
would demote their room rank to voice. Now, they will remain a
moderator, with "voice" only appearing in `/roomauth` and `/auth`.
(Includes a refactor of Config.groups)
We previously only reported the first line of the stack trace, but now that .readmore exists, showing
the full stack trace isn't too spammy anymore.
Also, private logs are now put into Upper Staff.