diff options
author | Madeline <46743919+MaddyUnderStars@users.noreply.github.com> | 2023-04-03 23:50:48 +1000 |
---|---|---|
committer | Madeline <46743919+MaddyUnderStars@users.noreply.github.com> | 2023-04-03 23:50:48 +1000 |
commit | 6ee26082efddfa4f996b4b0424a664a6a592501c (patch) | |
tree | da69812661ebe48cac1240482cbeedd7082d2317 /src/gateway/opcodes | |
parent | allow all role props through ready (diff) | |
download | server-6ee26082efddfa4f996b4b0424a664a6a592501c.tar.xz |
Respect CLIENT_STATE_V2 capability
Diffstat (limited to 'src/gateway/opcodes')
-rw-r--r-- | src/gateway/opcodes/Identify.ts | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/src/gateway/opcodes/Identify.ts b/src/gateway/opcodes/Identify.ts index 6aa152d3..f035fe15 100644 --- a/src/gateway/opcodes/Identify.ts +++ b/src/gateway/opcodes/Identify.ts @@ -16,7 +16,15 @@ along with this program. If not, see <https://www.gnu.org/licenses/>. */ -import { WebSocket, Payload, setupListener } from "@spacebar/gateway"; +import { + WebSocket, + Payload, + setupListener, + Capabilities, + CLOSECODES, + OPCODES, + Send, +} from "@spacebar/gateway"; import { checkToken, Intents, @@ -45,11 +53,9 @@ import { Permissions, DMChannel, GuildOrUnavailable, + Recipient, } from "@spacebar/util"; -import { Send } from "../util/Send"; -import { CLOSECODES, OPCODES } from "../util/Constants"; import { check } from "./instanceOf"; -import { Recipient } from "@spacebar/util"; // TODO: user sharding // TODO: check privileged intents, if defined in the config @@ -73,6 +79,8 @@ export async function onIdentify(this: WebSocket, data: Payload) { check.call(this, IdentifySchema, data.d); const identify: IdentifySchema = data.d; + this.capabilities = new Capabilities(identify.capabilities || 0); + // Check auth // TODO: the checkToken call will fetch user, and then we have to refetch with different select // checkToken should be able to select what we want @@ -374,7 +382,9 @@ export async function onIdentify(this: WebSocket, data: Payload) { : undefined, user: user.toPrivateUser(), user_settings: user.settings, - guilds: guilds.map((x) => new ReadyGuildDTO(x).toJSON()), + guilds: this.capabilities.has(Capabilities.FLAGS.CLIENT_STATE_V2) + ? guilds.map((x) => new ReadyGuildDTO(x).toJSON()) + : guilds, relationships: user.relationships.map((x) => x.toPublicRelationship()), read_state: { entries: read_states, |