mirror of
https://github.com/spacebarchat/server.git
synced 2024-11-10 20:52:42 +01:00
Gateway permission check fix
This commit is contained in:
parent
b446a3110b
commit
75c43b7db3
@ -116,7 +116,7 @@ async function consume(this: WebSocket, opts: EventOpts) {
|
|||||||
.has("VIEW_CHANNEL")
|
.has("VIEW_CHANNEL")
|
||||||
)
|
)
|
||||||
return;
|
return;
|
||||||
// TODO: check if user has permission to channel
|
break;
|
||||||
case "GUILD_CREATE":
|
case "GUILD_CREATE":
|
||||||
this.events[id] = await listenEvent(id, consumer, listenOpts);
|
this.events[id] = await listenEvent(id, consumer, listenOpts);
|
||||||
break;
|
break;
|
||||||
@ -193,11 +193,16 @@ async function consume(this: WebSocket, opts: EventOpts) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
Send(this, {
|
let aa = {
|
||||||
op: OPCODES.Dispatch,
|
op: OPCODES.Dispatch,
|
||||||
t: event,
|
t: event,
|
||||||
d: data,
|
d: data,
|
||||||
s: this.sequence++,
|
s: this.sequence++,
|
||||||
});
|
}
|
||||||
|
|
||||||
|
//TODO remove before PR merge
|
||||||
|
console.log(aa)
|
||||||
|
|
||||||
|
Send(this, aa);
|
||||||
opts.acknowledge?.();
|
opts.acknowledge?.();
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@ import { EVENT, Event } from "../interfaces";
|
|||||||
const events = new EventEmitter();
|
const events = new EventEmitter();
|
||||||
|
|
||||||
export async function emitEvent(payload: Omit<Event, "created_at">) {
|
export async function emitEvent(payload: Omit<Event, "created_at">) {
|
||||||
|
console.log(payload) //TODO remove before merge
|
||||||
const id = (payload.channel_id || payload.user_id || payload.guild_id) as string;
|
const id = (payload.channel_id || payload.user_id || payload.guild_id) as string;
|
||||||
if (!id) return console.error("event doesn't contain any id", payload);
|
if (!id) return console.error("event doesn't contain any id", payload);
|
||||||
|
|
||||||
|
@ -92,6 +92,7 @@ export class Permissions extends BitField {
|
|||||||
}
|
}
|
||||||
|
|
||||||
overwriteChannel(overwrites: ChannelPermissionOverwrite[]) {
|
overwriteChannel(overwrites: ChannelPermissionOverwrite[]) {
|
||||||
|
if (!overwrites) return this
|
||||||
if (!this.cache) throw new Error("permission chache not available");
|
if (!this.cache) throw new Error("permission chache not available");
|
||||||
overwrites = overwrites.filter((x) => {
|
overwrites = overwrites.filter((x) => {
|
||||||
if (x.type === 0 && this.cache.roles?.some((r) => r.id === x.id)) return true;
|
if (x.type === 0 && this.cache.roles?.some((r) => r.id === x.id)) return true;
|
||||||
|
Loading…
Reference in New Issue
Block a user