a lot of changes

This commit is contained in:
dank074
2025-05-06 19:38:09 -05:00
parent 96e457323b
commit 77b8d45543
35 changed files with 540 additions and 178 deletions
+42
View File
@@ -0,0 +1,42 @@
import {
Column,
Entity,
JoinColumn,
ManyToOne,
OneToMany,
RelationId,
} from "typeorm";
import { BaseClass } from "./BaseClass";
import { dbEngine } from "../util/Database";
import { User } from "./User";
import { Channel } from "./Channel";
import { StreamSession } from "./StreamSession";
@Entity({
name: "streams",
engine: dbEngine,
})
export class Stream extends BaseClass {
@Column()
@RelationId((stream: Stream) => stream.owner)
owner_id: string;
@JoinColumn({ name: "owner_id" })
@ManyToOne(() => User, {
onDelete: "CASCADE",
})
owner: User;
@Column()
@RelationId((stream: Stream) => stream.channel)
channel_id: string;
@JoinColumn({ name: "channel_id" })
@ManyToOne(() => Channel, {
onDelete: "CASCADE",
})
channel: Channel;
@Column()
endpoint: string;
}
+48
View File
@@ -0,0 +1,48 @@
import {
Column,
Entity,
JoinColumn,
ManyToOne,
OneToMany,
RelationId,
} from "typeorm";
import { BaseClass } from "./BaseClass";
import { dbEngine } from "../util/Database";
import { User } from "./User";
import { Stream } from "./Stream";
@Entity({
name: "stream_sessions",
engine: dbEngine,
})
export class StreamSession extends BaseClass {
@Column()
@RelationId((session: StreamSession) => session.stream)
stream_id: string;
@JoinColumn({ name: "stream_id" })
@ManyToOne(() => Stream, {
onDelete: "CASCADE",
})
stream: Stream;
@Column()
@RelationId((session: StreamSession) => session.user)
user_id: string;
@JoinColumn({ name: "user_id" })
@ManyToOne(() => User, {
onDelete: "CASCADE",
})
user: User;
@Column({ nullable: true })
token: string;
// this is for gateway session
@Column()
session_id: string;
@Column({ default: false })
used: boolean;
}
+2
View File
@@ -47,6 +47,8 @@ export * from "./SecurityKey";
export * from "./Session";
export * from "./Sticker";
export * from "./StickerPack";
export * from "./Stream";
export * from "./StreamSession";
export * from "./Team";
export * from "./TeamMember";
export * from "./Template";
+3 -1
View File
@@ -440,8 +440,9 @@ export interface VoiceServerUpdateEvent extends Event {
event: "VOICE_SERVER_UPDATE";
data: {
token: string;
guild_id: string;
guild_id: string | null;
endpoint: string;
channel_id?: string;
};
}
@@ -700,6 +701,7 @@ export type EVENT =
| "VOICE_SERVER_UPDATE"
| "STREAM_CREATE"
| "STREAM_SERVER_UPDATE"
| "STREAM_DELETE"
| "APPLICATION_COMMAND_CREATE"
| "APPLICATION_COMMAND_UPDATE"
| "APPLICATION_COMMAND_DELETE"
+1 -1
View File
@@ -23,7 +23,7 @@ export interface VoiceIdentifySchema {
token: string;
video?: boolean;
streams?: {
type: string;
type: "video" | "audio" | "screen";
rid: string;
quality: number;
}[];
+1 -1
View File
@@ -22,7 +22,7 @@ export interface VoiceVideoSchema {
rtx_ssrc?: number;
user_id?: string;
streams?: {
type: "video" | "audio";
type: "video" | "audio" | "screen";
rid: string;
ssrc: number;
active: boolean;
+3 -3
View File
@@ -23,9 +23,9 @@ import { EVENT, Event } from "../interfaces";
export const events = new EventEmitter();
export async function emitEvent(payload: Omit<Event, "created_at">) {
const id = (payload.channel_id ||
payload.user_id ||
payload.guild_id) as string;
const id = (payload.guild_id ||
payload.channel_id ||
payload.user_id) as string;
if (!id) return console.error("event doesn't contain any id", payload);
if (RabbitMQ.connection) {