diff --git a/back/src/Model/Admin.ts b/back/src/Model/Admin.ts index 0be74b85..29b53385 100644 --- a/back/src/Model/Admin.ts +++ b/back/src/Model/Admin.ts @@ -1,9 +1,6 @@ import { - BatchMessage, - PusherToBackMessage, ServerToAdminClientMessage, - ServerToClientMessage, - SubMessage, UserJoinedRoomMessage, UserLeftRoomMessage + UserJoinedRoomMessage, UserLeftRoomMessage } from "../Messages/generated/messages_pb"; import {AdminSocket} from "../RoomManager"; diff --git a/back/src/Model/GameRoom.ts b/back/src/Model/GameRoom.ts index 22ea8ca5..53d0a855 100644 --- a/back/src/Model/GameRoom.ts +++ b/back/src/Model/GameRoom.ts @@ -108,6 +108,7 @@ export class GameRoom { this.positionNotifier, socket, joinRoomMessage.getTagList(), + joinRoomMessage.getVisitcardurl(), joinRoomMessage.getName(), ProtobufUtils.toCharacterLayerObjects(joinRoomMessage.getCharacterlayerList()), joinRoomMessage.getCompanion() diff --git a/back/src/Model/User.ts b/back/src/Model/User.ts index 52a96b61..4a3e75ec 100644 --- a/back/src/Model/User.ts +++ b/back/src/Model/User.ts @@ -22,6 +22,7 @@ export class User implements Movable { private positionNotifier: PositionNotifier, public readonly socket: UserSocket, public readonly tags: string[], + public readonly visitCardUrl: string|null, public readonly name: string, public readonly characterLayers: CharacterLayer[], public readonly companion?: CompanionMessage diff --git a/back/src/RoomManager.ts b/back/src/RoomManager.ts index a0f983e0..19266687 100644 --- a/back/src/RoomManager.ts +++ b/back/src/RoomManager.ts @@ -11,7 +11,7 @@ import { JoinRoomMessage, PlayGlobalMessage, PusherToBackMessage, - QueryJitsiJwtMessage, RefreshRoomPromptMessage, RequestVisitCardMessage, + QueryJitsiJwtMessage, RefreshRoomPromptMessage, ServerToAdminClientMessage, ServerToClientMessage, SilentMessage, @@ -74,8 +74,6 @@ const roomManager: IRoomManagerServer = { socketManager.handleQueryJitsiJwtMessage(user, message.getQueryjitsijwtmessage() as QueryJitsiJwtMessage); } else if (message.hasEmotepromptmessage()){ socketManager.handleEmoteEventMessage(room, user, message.getEmotepromptmessage() as EmotePromptMessage); - } else if (message.hasRequestvisitcardmessage()) { - socketManager.handleRequestVisitCardMessage(room, user, message.getRequestvisitcardmessage() as RequestVisitCardMessage); }else if (message.hasSendusermessage()) { const sendUserMessage = message.getSendusermessage(); if(sendUserMessage !== undefined) { diff --git a/back/src/Services/AdminApi.ts b/back/src/Services/AdminApi.ts deleted file mode 100644 index 09b092bf..00000000 --- a/back/src/Services/AdminApi.ts +++ /dev/null @@ -1,22 +0,0 @@ -import {ADMIN_API_TOKEN, ADMIN_API_URL} from "../Enum/EnvironmentVariable"; -import Axios from "axios"; - - -class AdminApi { - - fetchVisitCardUrl(membershipUuid: string): Promise { - if (ADMIN_API_URL) { - return Axios.get(ADMIN_API_URL + '/api/membership/'+membershipUuid, - {headers: {"Authorization": `${ADMIN_API_TOKEN}`}} - ).then((res) => { - return res.data; - }).catch(() => { - return 'INVALID'; - }); - } else { - return Promise.resolve('INVALID') - } - } -} - -export const adminApi = new AdminApi(); diff --git a/back/src/Services/SocketManager.ts b/back/src/Services/SocketManager.ts index f8fe7cd3..a56a1ac4 100644 --- a/back/src/Services/SocketManager.ts +++ b/back/src/Services/SocketManager.ts @@ -27,7 +27,7 @@ import { WorldFullWarningMessage, UserLeftZoneMessage, EmoteEventMessage, - BanUserMessage, RefreshRoomMessage, EmotePromptMessage, RequestVisitCardMessage, VisitCardMessage, + BanUserMessage, RefreshRoomMessage, EmotePromptMessage, } from "../Messages/generated/messages_pb"; import {User, UserSocket} from "../Model/User"; import {ProtobufUtils} from "../Model/Websocket/ProtobufUtils"; @@ -51,7 +51,6 @@ import {Zone} from "_Model/Zone"; import Debug from "debug"; import {Admin} from "_Model/Admin"; import crypto from "crypto"; -import {adminApi} from "./AdminApi"; const debug = Debug('sockermanager'); @@ -300,6 +299,9 @@ export class SocketManager { userJoinedZoneMessage.setCharacterlayersList(ProtobufUtils.toCharacterLayerMessages(thing.characterLayers)); userJoinedZoneMessage.setPosition(ProtobufUtils.toPositionMessage(thing.getPosition())); userJoinedZoneMessage.setFromzone(this.toProtoZone(fromZone)); + if (thing.visitCardUrl) { + userJoinedZoneMessage.setVisitcardurl(thing.visitCardUrl); + } userJoinedZoneMessage.setCompanion(thing.companion); const subMessage = new SubToPusherMessage(); @@ -605,6 +607,9 @@ export class SocketManager { userJoinedMessage.setName(thing.name); userJoinedMessage.setCharacterlayersList(ProtobufUtils.toCharacterLayerMessages(thing.characterLayers)); userJoinedMessage.setPosition(ProtobufUtils.toPositionMessage(thing.getPosition())); + if (thing.visitCardUrl) { + userJoinedMessage.setVisitcardurl(thing.visitCardUrl); + } userJoinedMessage.setCompanion(thing.companion); const subMessage = new SubToPusherMessage(); @@ -770,21 +775,6 @@ export class SocketManager { emoteEventMessage.setActoruserid(user.id); room.emitEmoteEvent(user, emoteEventMessage); } - - async handleRequestVisitCardMessage(room: GameRoom, user: User, requestvisitcardmessage: RequestVisitCardMessage): Promise { - const targetUser = room.getUserById(requestvisitcardmessage.getTargetuserid()); - if (!targetUser) { - throw 'Could not find user for id '+requestvisitcardmessage.getTargetuserid(); - } - const url = await adminApi.fetchVisitCardUrl(targetUser.uuid); - - const visitCardMessage = new VisitCardMessage(); - visitCardMessage.setUrl(url); - const clientMessage = new ServerToClientMessage(); - clientMessage.setVisitcardmessage(visitCardMessage); - - user.socket.write(clientMessage); - } } export const socketManager = new SocketManager(); diff --git a/back/tests/PositionNotifierTest.ts b/back/tests/PositionNotifierTest.ts index 24b171d9..1aaf2e13 100644 --- a/back/tests/PositionNotifierTest.ts +++ b/back/tests/PositionNotifierTest.ts @@ -1,10 +1,6 @@ import "jasmine"; -import {GameRoom, ConnectCallback, DisconnectCallback } from "_Model/GameRoom"; -import {Point} from "../src/Model/Websocket/MessageUserPosition"; -import { Group } from "../src/Model/Group"; import {PositionNotifier} from "../src/Model/PositionNotifier"; import {User, UserSocket} from "../src/Model/User"; -import {PointInterface} from "../src/Model/Websocket/PointInterface"; import {Zone} from "_Model/Zone"; import {Movable} from "_Model/Movable"; import {PositionInterface} from "_Model/PositionInterface"; @@ -30,14 +26,14 @@ describe("PositionNotifier", () => { y: 500, moving: false, direction: 'down' - }, false, positionNotifier, {} as UserSocket, [], 'foo', []); + }, false, positionNotifier, {} as UserSocket, [], null, 'foo', []); const user2 = new User(2, 'test', '10.0.0.2', { x: -9999, y: -9999, moving: false, direction: 'down' - }, false, positionNotifier, {} as UserSocket, [], 'foo', []); + }, false, positionNotifier, {} as UserSocket, [], null, 'foo', []); positionNotifier.addZoneListener({} as ZoneSocket, 0, 0); positionNotifier.addZoneListener({} as ZoneSocket, 0, 1); @@ -105,14 +101,14 @@ describe("PositionNotifier", () => { y: 500, moving: false, direction: 'down' - }, false, positionNotifier, {} as UserSocket, [], 'foo', []); + }, false, positionNotifier, {} as UserSocket, [], null, 'foo', []); const user2 = new User(2, 'test', '10.0.0.2', { x: 0, y: 0, moving: false, direction: 'down' - }, false, positionNotifier, {} as UserSocket, [], 'foo', []); + }, false, positionNotifier, {} as UserSocket, [], null, 'foo', []); const listener = {} as ZoneSocket; positionNotifier.addZoneListener(listener, 0, 0); diff --git a/benchmark/package-lock.json b/benchmark/package-lock.json index 72d0aae4..ba52caf2 100644 --- a/benchmark/package-lock.json +++ b/benchmark/package-lock.json @@ -209,9 +209,9 @@ } }, "glob-parent": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.1.tgz", - "integrity": "sha512-FnI+VGOpnlGHWZxthPGR+QhR78fuiK0sNLkHQv+bL9fQi57lNNdquIbna/WrfROrolq8GK5Ek6BiMwqL/voRYQ==", + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", + "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==", "requires": { "is-glob": "^4.0.1" } diff --git a/benchmark/yarn.lock b/benchmark/yarn.lock index f1209dcf..a7f9ec0d 100644 --- a/benchmark/yarn.lock +++ b/benchmark/yarn.lock @@ -148,8 +148,8 @@ get-stdin@^4.0.1: resolved "https://registry.yarnpkg.com/get-stdin/-/get-stdin-4.0.1.tgz#b968c6b0a04384324902e8bf1a5df32579a450fe" glob-parent@~5.1.0: - version "5.1.1" - resolved "https://registry.yarnpkg.com/glob-parent/-/glob-parent-5.1.1.tgz#b6c1ef417c4e5663ea498f1c45afac6916bbc229" + version "5.1.2" + resolved "https://registry.yarnpkg.com/glob-parent/-/glob-parent-5.1.2.tgz#869832c58034fe68a4093c17dc15e8340d8401c4" dependencies: is-glob "^4.0.1" diff --git a/front/dist/resources/html/gameMenu.html b/front/dist/resources/html/gameMenu.html index 399cf349..26be2a1c 100644 --- a/front/dist/resources/html/gameMenu.html +++ b/front/dist/resources/html/gameMenu.html @@ -64,7 +64,7 @@ diff --git a/front/src/Api/IframeListener.ts b/front/src/Api/IframeListener.ts index fbc2b4f1..6c3afa31 100644 --- a/front/src/Api/IframeListener.ts +++ b/front/src/Api/IframeListener.ts @@ -70,15 +70,23 @@ class IframeListener { // Do we trust the sender of this message? // Let's only accept messages from the iframe that are allowed. // Note: maybe we could restrict on the domain too for additional security (in case the iframe goes to another domain). - let foundSrc: string | null = null; - for (const iframe of this.iframes) { - if (iframe.contentWindow === message.source) { - foundSrc = iframe.src; - break; + let foundSrc: string | undefined; + + foundSrc = [...this.scripts.keys()].find(key => { + return this.scripts.get(key)?.contentWindow == message.source + }); + + if (foundSrc === undefined) { + for (const iframe of this.iframes) { + if (iframe.contentWindow === message.source) { + foundSrc = iframe.src; + break; + } + } + + if (foundSrc === undefined) { + return; } - } - if (!foundSrc) { - return; } const payload = message.data; @@ -106,11 +114,7 @@ class IframeListener { this._loadSoundStream.next(payload.data); } else if (payload.type === 'openCoWebSite' && isOpenCoWebsite(payload.data)) { - const scriptUrl = [...this.scripts.keys()].find(key => { - return this.scripts.get(key)?.contentWindow == message.source - }) - - scriptUtils.openCoWebsite(payload.data.url, scriptUrl || foundSrc); + scriptUtils.openCoWebsite(payload.data.url, foundSrc); } else if (payload.type === 'closeCoWebSite') { diff --git a/front/src/Components/EnableCamera/EnableCameraScene.svelte b/front/src/Components/EnableCamera/EnableCameraScene.svelte index 537e8bdb..605a1458 100644 --- a/front/src/Components/EnableCamera/EnableCameraScene.svelte +++ b/front/src/Components/EnableCamera/EnableCameraScene.svelte @@ -61,8 +61,8 @@ onDestroy(unsubscribe); function normalizeDeviceName(label: string): string { - // remove text in parenthesis - return label.replace(/\([^()]*\)/g, '').trim(); + // remove IDs (that can appear in Chrome, like: "HD Pro Webcam (4df7:4eda)" + return label.replace(/(\([[0-9a-f]{4}:[0-9a-f]{4}\))/g, '').trim(); } function selectCamera() { @@ -93,7 +93,7 @@ {#if $cameraListStore.length > 1 }
Camera -
+
{#each $microphoneListStore as microphone}