feat: implement member list id generation
This commit is contained in:
parent
60394d8c43
commit
564d1a2fc9
BIN
package-lock.json
generated
BIN
package-lock.json
generated
Binary file not shown.
@ -49,6 +49,7 @@
|
|||||||
"@types/jsonwebtoken": "^8.5.9",
|
"@types/jsonwebtoken": "^8.5.9",
|
||||||
"@types/morgan": "^1.9.3",
|
"@types/morgan": "^1.9.3",
|
||||||
"@types/multer": "^1.4.7",
|
"@types/multer": "^1.4.7",
|
||||||
|
"@types/murmurhash-js": "^1.0.4",
|
||||||
"@types/node": "^18.7.20",
|
"@types/node": "^18.7.20",
|
||||||
"@types/node-fetch": "^2.6.2",
|
"@types/node-fetch": "^2.6.2",
|
||||||
"@types/node-os-utils": "^1.3.0",
|
"@types/node-os-utils": "^1.3.0",
|
||||||
@ -94,6 +95,7 @@
|
|||||||
"module-alias": "^2.2.2",
|
"module-alias": "^2.2.2",
|
||||||
"morgan": "^1.10.0",
|
"morgan": "^1.10.0",
|
||||||
"multer": "^1.4.5-lts.1",
|
"multer": "^1.4.5-lts.1",
|
||||||
|
"murmurhash-js": "^1.0.0",
|
||||||
"node-2fa": "^2.0.3",
|
"node-2fa": "^2.0.3",
|
||||||
"node-fetch": "^2.6.7",
|
"node-fetch": "^2.6.7",
|
||||||
"node-os-utils": "^1.3.7",
|
"node-os-utils": "^1.3.7",
|
||||||
|
|||||||
@ -27,6 +27,8 @@ import {
|
|||||||
User,
|
User,
|
||||||
Presence,
|
Presence,
|
||||||
partition,
|
partition,
|
||||||
|
Channel,
|
||||||
|
Permissions,
|
||||||
} from "@spacebar/util";
|
} from "@spacebar/util";
|
||||||
import {
|
import {
|
||||||
WebSocket,
|
WebSocket,
|
||||||
@ -35,6 +37,7 @@ import {
|
|||||||
OPCODES,
|
OPCODES,
|
||||||
Send,
|
Send,
|
||||||
} from "@spacebar/gateway";
|
} from "@spacebar/gateway";
|
||||||
|
import murmur from "murmurhash-js/murmurhash3_gc";
|
||||||
import { check } from "./instanceOf";
|
import { check } from "./instanceOf";
|
||||||
|
|
||||||
// TODO: only show roles/members that have access to this channel
|
// TODO: only show roles/members that have access to this channel
|
||||||
@ -271,6 +274,28 @@ export async function onLazyRequest(this: WebSocket, { d }: Payload) {
|
|||||||
ranges.map((x) => getMembers(guild_id, x as [number, number])),
|
ranges.map((x) => getMembers(guild_id, x as [number, number])),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
let list_id = "everyone";
|
||||||
|
|
||||||
|
const channel = await Channel.findOneOrFail({
|
||||||
|
where: { id: channel_id },
|
||||||
|
});
|
||||||
|
if (channel.permission_overwrites) {
|
||||||
|
const perms: string[] = [];
|
||||||
|
|
||||||
|
channel.permission_overwrites.forEach((overwrite) => {
|
||||||
|
const { id, allow, deny } = overwrite;
|
||||||
|
|
||||||
|
if (allow.toBigInt() & Permissions.FLAGS.VIEW_CHANNEL)
|
||||||
|
perms.push(`allow:${id}`);
|
||||||
|
else if (deny.toBigInt() & Permissions.FLAGS.VIEW_CHANNEL)
|
||||||
|
perms.push(`deny:${id}`);
|
||||||
|
});
|
||||||
|
|
||||||
|
if (perms.length > 0) {
|
||||||
|
list_id = murmur(perms.sort().join(",")).toString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: unsubscribe member_events that are not in op.members
|
// TODO: unsubscribe member_events that are not in op.members
|
||||||
|
|
||||||
ops.forEach((op) => {
|
ops.forEach((op) => {
|
||||||
@ -299,7 +324,7 @@ export async function onLazyRequest(this: WebSocket, { d }: Payload) {
|
|||||||
member_count -
|
member_count -
|
||||||
(groups.find((x) => x.id == "offline")?.count ?? 0),
|
(groups.find((x) => x.id == "offline")?.count ?? 0),
|
||||||
member_count,
|
member_count,
|
||||||
id: "everyone",
|
id: list_id,
|
||||||
guild_id,
|
guild_id,
|
||||||
groups,
|
groups,
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user