From 3d1cd02f27518f1a04374c7c8320cd5d82ede6e9 Mon Sep 17 00:00:00 2001 From: Minteck Date: Thu, 23 Feb 2023 19:34:56 +0100 Subject: Updated 40 files, added 37 files, deleted 1103 files and renamed 3905 files (automated) --- together/src/types/Session.ts | 39 -------------------------------------- together/src/types/User.ts | 44 ------------------------------------------- together/src/types/Video.ts | 41 ---------------------------------------- 3 files changed, 124 deletions(-) delete mode 100644 together/src/types/Session.ts delete mode 100644 together/src/types/User.ts delete mode 100644 together/src/types/Video.ts (limited to 'together/src/types') diff --git a/together/src/types/Session.ts b/together/src/types/Session.ts deleted file mode 100644 index 5d3e799..0000000 --- a/together/src/types/Session.ts +++ /dev/null @@ -1,39 +0,0 @@ -import {v4 as uuidv4} from 'uuid'; -import User from "./User"; -import Video, {OngoingVideo} from "./Video"; -import {generateParyCode} from "../utils/PartyCodes"; - -export default class Session { - public id: string; - public partyCode: string; - public videoQueue: Video[]; - public currentVideo: OngoingVideo; - public users: User[]; - - constructor() { - this.id = uuidv4(); - this.partyCode = generateParyCode(); - this.videoQueue = []; - this.currentVideo = null; - this.users = []; - } - - update() { - if(this.videoQueue.length === 0) this.currentVideo = null; - else this.currentVideo = (this.videoQueue.shift()).toOngoingVideo(); - - this.users.forEach(user => { - user.ws.send(JSON.stringify({ - "task": "VIDEO_UPDATE", - "payload": { - "url": this.currentVideo.url, - "title": this.currentVideo.title, - "author": this.currentVideo.author, - "thumbnail": this.currentVideo.thumbnail, - "state": this.currentVideo.state, - "position": this.currentVideo.position - } - })) - }); - } -} \ No newline at end of file diff --git a/together/src/types/User.ts b/together/src/types/User.ts deleted file mode 100644 index 900acb8..0000000 --- a/together/src/types/User.ts +++ /dev/null @@ -1,44 +0,0 @@ -import {WebSocket} from "ws"; -import Video from "./Video"; -import superagent from "superagent"; - -export default class User { - public id: string; - public ws: WebSocket; - public videoPositon: number; - private apiToken: string; - - constructor(ws: WebSocket, apiToken: string) { - this.videoPositon = 0; - this.ws = ws; - this.apiToken = apiToken; - - this.getUserData(); - } - - async getUserData() { - let res = await superagent.get("https://peh-internal.minteck.org/api/me") - .set("Cookie", "PEH2_SESSION_TOKEN=" + this.apiToken) - .send(); - - this.id = res.body["id"]; - } - - async getYoutubeVideo(id: string): Promise