Commit Graph

133 Commits

Author SHA1 Message Date
Annika
bece58ee93
Fixes for /unrangelock (#7266) 2020-08-26 22:48:00 -07:00
Annika
33e8da3c13
Properly inform client of statusType changes (#7262)
This should fix the bug where usernames remain grey on the client after reloading.
2020-08-26 07:49:05 -07:00
Annika
d65335f415
Improve handling of locks when users are merged (#7264) 2020-08-26 04:34:44 -07:00
Guangcong Luo
91a86df155 Fix /hiderank 2020-08-22 07:47:36 -07:00
Guangcong Luo
e14485656f Implement a basic /hiderank
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.
2020-08-22 07:20:26 -07:00
Guangcong Luo
2878793964 Revert accidental merge of /hiderank code
`/hiderank` code was accidentally merged into #7078

This fully backs out its code.
2020-08-22 06:57:24 -07:00
Annika
3ef50d8feb
Move forced public prefix logic to RoomBattle (#7244) 2020-08-22 05:29:51 -07:00
Annika
27d4212771
Display whitelist correctly in demotion messages (#7238) 2020-08-20 21:18:09 -07:00
Annika
44d369ca8a
Allow users to set their own language and translate helptickets (#7220) 2020-08-19 00:21:51 -07:00
Annika
fe2f77c5fe
Improvements to the /dnd command (#7196) 2020-08-18 16:56:51 -07:00
Guangcong Luo
a315c93836 Switch to using import type
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!
2020-08-09 08:07:00 -05:00
Annika
8287cbc7fb
Remove User#authAtLeast and add more sysop bypasses (#7046) 2020-08-06 00:12:30 -07:00
Annika
cd85cd7a9d
Hosts & IPTools: Refactor to remove hardcoded ranges (#7078) 2020-07-29 23:04:50 -07:00
Mia
94fff9d496
Support customizing permissions per-room (#6883) 2020-07-29 00:22:03 -07:00
Guangcong Luo
3931f680c3 Improve assertion error message
There's no longer a need to assume that corrupt assertions are
assertions from 2013, rather than some other code mistake.

Inspired by #7064
2020-07-28 17:10:05 -07:00
Peach
f2bfe2538c
Make sendhtmlpage perms more strict, refactor perm checks (#7044) 2020-07-25 23:31:28 -07:00
Annika
528045a03f
Support hiding battles from /cmd userdetails (#7040) 2020-07-23 21:30:30 -07:00
Annika
7375ab4d90
Add cooldown for unregistered namechanges (#7032) 2020-07-23 00:00:29 -07:00
Peach
e9611b7ce2
Remove unnecessary references to the global room (#7033) 2020-07-22 08:52:46 -07:00
Annika
570df13186
Support renaming battles (#7015) 2020-07-18 21:27:24 -07:00
Guangcong Luo
52f0096c30 Refactor Auth.hasPermission
Half the permissions checks were previously in `user.can`, which is
unintuitive. It's now completely self-contained and should be pretty
readable, now, with `getEffectiveSymbol` and `hasJurisdiction` as
separate functions.
2020-07-13 00:55:23 -07:00
Kirk Scheibelhut
eea2196280
Server side changes to support persistent user settings and privacy changes (#6947)
NOTE: This is changes the semantics of `hidenext`/`ionext` from
applying to the next created *battle* to applying to the next
created *search*/*challenge*.
2020-07-06 21:18:38 -07:00
Guangcong Luo
26615490f7 Merge BasicChatRoom and BasicRoom
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.
2020-07-02 18:54:02 -07:00
Guangcong Luo
46c9afa2f3
"Remove" the global room (#6885)
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")
2020-07-02 11:31:34 -07:00
Guangcong Luo
6af875af8b Improve RoomPermission/GlobalPermission checks
Global permissions can no longer be used as room permissions. Instead,
the two are entirely separate lists, with only a few permissions in
both lists.
2020-06-21 03:53:06 -07:00
Guangcong Luo
ee6e43b552 Strongly type RoomPermission and GlobalPermission
`user-groups.ts` now tracks the list of possible values for
`RoomPermission` and `GlobalPermission` in a const.
2020-06-21 01:43:27 -07:00
Guangcong Luo
8c4d55b184 Fix bugs in Settings refactor 2020-06-09 15:40:54 -04:00
Guangcong Luo
c444036f85 Support whitelisting users
(Whitelist is being implemented as a hardcoded custom group.)
2020-06-09 08:22:44 -07:00
Mia
15fed24b40
Refactor auth and room.settings (#6777)
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>
2020-06-09 08:22:25 -07:00
Guangcong Luo
ddb9a5d11e Improve code documentation 2020-05-26 21:29:34 -04:00
Guangcong Luo
8498842697 Make custom room ranks always override
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.)
2020-04-18 07:22:29 -07:00
Guangcong Luo
776ccf9796
Refactor Sockets to ProcessManager+TypeScript (#6584) 2020-04-17 04:05:45 -07:00
Guangcong Luo
c49343b7e2 Setting a room rank can no longer demote globals
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)
2020-04-17 03:32:11 -07:00
Peach
76688629e4
Don't let locked users PM through any level of blocking (#6555) 2020-04-10 17:24:38 -07:00
Mia
3fc757e958
Typescript chat-commands/moderation, refactor Punishments (#6490) 2020-04-08 11:56:19 -07:00
HoeenHero
b74a86d83c Only prune disconnected users 2020-03-17 13:42:24 -04:00
Kirk Scheibelhut
17501fc001
Remove restrictions on concurrent battle searches (#6462)
https://www.smogon.com/forums/threads/improve-searching-for-concurrent-ladder-battles.3660989/
2020-03-16 21:17:34 -07:00
Guangcong Luo
7de51956c5 Change BasicChatRoom to Room in some types
`user.can` and `user.authAtLeast` now take `Room | BasicChatRoom`
instead of `BasicChatRoom`. It's now significantly less necessary to
cast things to `BasicChatRoom`.
2020-03-15 19:52:59 -07:00
asgdf
cac033ab86
Improve handling of mobile IPs with permalocks (#6338) 2020-03-07 11:50:08 -08:00
Guangcong Luo
125fe31d06 Improve eslintrc
Fixed some more code style, allowing these rules to be enabled:

- `comma-dangle`
- `function-paren-newline`
- `member-delimiter-style`
- `no-eval`
- `no-fallthrough`
- `no-misused-promises`
- `no-unused-vars`
- `operator-linebreak`
2020-03-06 22:35:55 -08:00
Waleed Hassan
8aa4f053bb
Use optional chaining and linter improvements (#6422)
This is mostly just a follow up to #6342.

`prefer-optional-chaining` was turned on and fixed in every location it
complained in. The transformed function [0] looks expensive from a
glance but from skimming through the replaced sites it doesn't appear
to be ran in any important place, so it should be OK.

The linter improvements are:
- Increase linter performance
	- Make `full-lint` and `lint` write to different caches so we
	  avoid overwriting their caches since they're different configs
	- Change husky's hook to `npm run lint` so as to write to the
	  same cache
	- Remove `@typescript-eslint/eslint-plugin-tslint` which is
	  essentially a wrapper to TSLint because the rules aren't worth
	  running another linter
- Convert `.eslintrc.json` and `.eslintrc-syntax.json` to two spaces
  rather than four tabs to respect PS' `.editorconfig`
- Rename `fulllint` to `full-lint` to ease spelling it

[0] - https://pastie.io/mmtxpf.js (prettified)
2020-03-06 11:44:32 -08:00
Guangcong Luo
b21c9047e2
Migrate to typescript-eslint (#6342) 2020-03-05 08:33:06 -08:00
whales
38daf467fc
Add some common rooms to the roomid type (#6393) 2020-02-24 19:52:41 -08:00
Kris Johnson
e64e083e6c
Typescript The Cafe (#6379) 2020-02-20 23:01:20 -08:00
whales
7db204730c
Make User#update more typesafe (#6359) 2020-02-13 10:33:16 -08:00
Waleed Hassan
02c862da31 Add a GroupSymbol type (#6285) 2020-01-14 14:07:11 -08:00
Waleed Hassan
27563f6380 RoomGame: Uncomment optional functions (#5992)
TypeScript will now recognizes these functions existence so
we don't have to supress the compiler whenever they come up.
2019-11-18 16:43:40 +13:00
Lusamine
a591b639f7 Fix handling of locked and proxy connections (#5938) 2019-11-15 11:10:04 +13:00
Lusamine
684b03e2f3 Allow /blockpms to block locked and semilocked users (#5923) 2019-11-01 13:34:52 +10:30
Waleed Hassan
a518cf102a Take steps to statically type Config (#5920)
This commit changes the TypeScript global variable of `Config` from
`AnyObject` to `Config & AnyObject`.

It still falls back to `AnyObject` (hence the 'Take steps') because of
the main-specific `Config` properties that are used without being in the
`Config` object itself.

These can be added by someone with access to the PS main server.

Regardlesss, this is an improvement as IntelliSense can display and
autocomplete the known properies.

In addition, the TypeScript compiler will now report bugs
concerning the types of the properties, which I have fixed in this
commit.
2019-10-30 18:45:20 +10:30
Waleed Hassan
28e870c4fb Server: Use readonly where appropriate (#5902) 2019-10-21 16:12:32 +10:30
whales
ea2dea1283 Rooms: Rooms.get can return null (#5860) 2019-10-09 18:52:33 +11:00
Waleed Hassan
5607c158e4 Use void in promises to appease TSLint (#5827) 2019-10-03 19:08:30 +10:00
asgdf
bd6ac0f024 Prevent overzealous spead of locks under some circumstances (#5824) 2019-10-03 19:00:40 +10:00
Waleed Hassan
da4b887054 Rename Room#id -> Room#roomid, User#userid -> User#id (#5826)
These should make it clearer that userids are IDs but roomids aren't.
2019-10-03 18:57:38 +10:00
whales
cdab768131 Properly give trusted users a 100ms throttle (#5839) 2019-10-03 01:53:22 +10:00
whales
ba47b1ba61 Give trusted users a 100ms chat delay (#5838)
Down from 300ms for global auth
2019-10-03 01:21:29 +10:00
Lusamine
5244315932 Remove "[unregistered]" label on forcerename messages; shorten reused name message (#5832) 2019-09-30 20:00:45 +02:00
whales
21d494079d Show "access denied" for modjoined rooms (#5778) 2019-09-18 16:30:30 +09:30
Ben Davies
0a98132e1b Track connection times and log probable ghosts (#5768)
This logs connections that have been around for longer than a week,
every week.
2019-09-17 21:02:57 -07:00
whales
b8114fbae0 Improve username punishments (#5743)
* Improve username punishments

Track how many times a name has been forcerenamed, note differently for offline warns and forcerenames

* Hyperlink names, show trusted/ac/registered

* rebase

* pseudorank -> accountstatus
2019-09-15 06:25:15 +02:00
TheJetOU
f2783c642d Add a RoomID type (#5759) 2019-09-07 14:15:27 -05:00
whales
b15dd2a528 Typescript punishments (#5728) 2019-08-29 19:46:42 -05:00
TheJetOU
2b28c9fd6b Refactor Rooms(), Users() to Rooms.get(), Users.get() (#5725) 2019-08-25 06:33:56 -07:00
TheJetOU
7fe2e5338c TypeScript Tournaments (#5723) 2019-08-24 03:48:13 -07:00
Guangcong Luo
e0a2cf07e1 Correctly define global types for .ts files
Global types are defined differently for `.ts` files than for `.js`
files, leading to some confusion for past refactors.

This commit defines them correctly.

I'm also considering making certain global types only available under
namespaces, but I don't want to do that to `User` or `Room`, so for
now, there are no changes there, besides putting streams in the
`Streams` namespace (so `WriteStream` is now `Streams.WriteStream`).
2019-08-23 09:33:49 -07:00
TheJetOU
5597916644 TypeScript Rooms and Roomlogs (#5699) 2019-08-14 20:44:57 +02:00
TheJetOU
3c3d897b92 Move JSDoc comments from assignment to declaration (#5701)
This makes IntelliSense show the JSDoc comment.
2019-08-13 17:25:29 +02:00
TheJetOU
f586e88326 Simplify Map declarations (#5702) 2019-08-13 17:23:27 +02:00
whales
10266ffe92 Typescript chat (#5620) 2019-08-10 15:30:34 -07:00
whales
9b43bf4448 Set prevUsers properly when merging (#5690)
* Set prevnames properly when merging

* change param order

* rename, again
2019-08-09 17:57:44 -07:00
whales
9b222862c5 Send updateuser when changing status type (#5675) 2019-08-05 09:56:54 +02:00
whales
2336659432 Fix self idle display on merging (#5674) 2019-08-05 09:42:19 +02:00
whales
2eaed9105d Update status properly on merging (#5663) 2019-08-01 13:56:43 +02:00
Kirk Scheibelhut
4326aeae04
Add forcedpublicprefixes for public OLT battles (#5661) 2019-08-01 09:28:48 +02:00
Guangcong Luo
dd6ce3c2dd Give sysops isStaff
This fixes a situation where sysops couldn't see the results of
commands they used.
2019-07-20 08:53:15 -05:00
Guangcong Luo
8313f6a825 Properly give gdrivers roommod powers
The previous solution had some rough edges, like accidentally
knocking global leaders down to roommod.

This also restores the corresponding symbols, for better clarity.
2019-07-20 08:50:59 -05:00
Kirk Scheibelhut
21cd5cf02c Actually ACTUALLY prevent Idle state from propagating 2019-07-19 09:31:19 -07:00
Kirk Scheibelhut
ba4e0254d8 Actually prevent Idle state from propagating 2019-07-19 09:03:27 -07:00
asgdf
97a42995db Add easy method of undoing /trustuser (#5631) 2019-07-19 10:40:19 -05:00
Kirk Scheibelhut
c43e2557f0 Prevent Idle state from propagating (#5630) 2019-07-18 21:12:39 -05:00
Kirk Scheibelhut
37ba36b2da Remove Idle popup (#5622)
This was originally added in the original design when we were
actively logging Idle users out of their account. Currently it
serves mostly to explain what Idle is, but mostly it just annoys
users.
2019-07-17 12:19:39 -05:00
whales
94bb4084d5 Typescript users (#5617) 2019-07-16 19:22:38 -07:00