1
0
mirror of https://github.com/spacebarchat/server.git synced 2024-11-24 03:12:38 +01:00

🐛 fix channel events + message send

This commit is contained in:
Flam3rboy 2021-09-13 00:17:56 +02:00
parent e32bb24fa8
commit 6b21e107dd
3 changed files with 17 additions and 13 deletions

View File

@ -11,7 +11,8 @@
"build:api": "cd ../api/ && npm run build",
"build:cdn": "cd ../cdn/ && npm run build",
"build:gateway": "cd ../gateway/ && npm run build",
"start": "npm run build && node -r ./tsconfig-paths-bootstrap.js dist/start.js",
"start": "npm run build && npm run start:bundle",
"start:bundle": "node -r ./tsconfig-paths-bootstrap.js dist/start.js",
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {

View File

@ -26,16 +26,16 @@ import { Recipient } from "@fosscord/util";
// TODO: use already queried guilds/channels of Identify and don't fetch them again
export async function setupListener(this: WebSocket) {
const members = await Member.find({ id: this.user_id });
const guild_ids = members.map((x) => x.guild_id);
const user = await User.findOneOrFail({ id: this.user_id });
const members = await Member.find({
where: { id: this.user_id },
relations: ["guild", "guild.channels"],
});
const guilds = members.map((x) => x.guild);
const recipients = await Recipient.find({
where: { user_id: this.user_id },
relations: ["channel"],
});
const channels = await Channel.find({ guild_id: In(guild_ids) });
const dm_channels = recipients.map((x) => x.channel);
const guild_channels = channels.filter((x) => x.guild_id);
const opts: { acknowledge: boolean; channel?: AMQChannel } = {
acknowledge: true,
@ -54,18 +54,20 @@ export async function setupListener(this: WebSocket) {
this.events[channel.id] = await listenEvent(channel.id, consumer, opts);
}
for (const guild of guild_ids) {
for (const guild of guilds) {
// contains guild and dm channels
getPermission(this.user_id, guild)
getPermission(this.user_id, guild.id)
.then(async (x) => {
this.permissions[guild] = x;
this.permissions[guild.id] = x;
this.listeners;
this.events[guild] = await listenEvent(guild, consumer, opts);
this.events[guild.id] = await listenEvent(
guild.id,
consumer,
opts
);
for (const channel of guild_channels.filter(
(c) => c.guild_id === guild
)) {
for (const channel of guild.channels) {
if (
x
.overwriteChannel(channel.permission_overwrites)

View File

@ -61,6 +61,7 @@ export class Channel extends BaseClass {
@ManyToOne(() => Channel)
parent?: Channel;
// only for group dms
@Column({ nullable: true })
@RelationId((channel: Channel) => channel.owner)
owner_id: string;