From 87e2635a50ac2decb1c330e55c2ff7b6d07a85de Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 7 Jul 2021 11:55:16 +0200 Subject: Introduce socket io command --- shared/extra-utils/socket/index.ts | 1 + shared/extra-utils/socket/socket-io-command.ts | 15 +++++++++++++++ shared/extra-utils/socket/socket-io.ts | 18 ------------------ 3 files changed, 16 insertions(+), 18 deletions(-) create mode 100644 shared/extra-utils/socket/index.ts create mode 100644 shared/extra-utils/socket/socket-io-command.ts delete mode 100644 shared/extra-utils/socket/socket-io.ts (limited to 'shared/extra-utils/socket') diff --git a/shared/extra-utils/socket/index.ts b/shared/extra-utils/socket/index.ts new file mode 100644 index 000000000..594329b2f --- /dev/null +++ b/shared/extra-utils/socket/index.ts @@ -0,0 +1 @@ +export * from './socket-io-command' diff --git a/shared/extra-utils/socket/socket-io-command.ts b/shared/extra-utils/socket/socket-io-command.ts new file mode 100644 index 000000000..545561bed --- /dev/null +++ b/shared/extra-utils/socket/socket-io-command.ts @@ -0,0 +1,15 @@ +import { io } from 'socket.io-client' +import { AbstractCommand, OverrideCommandOptions } from '../shared' + +export class SocketIOCommand extends AbstractCommand { + + getUserNotificationSocket (options: OverrideCommandOptions = {}) { + return io(this.server.url + '/user-notifications', { + query: { accessToken: this.server.accessToken } + }) + } + + getLiveNotificationSocket () { + return io(this.server.url + '/live-videos') + } +} diff --git a/shared/extra-utils/socket/socket-io.ts b/shared/extra-utils/socket/socket-io.ts deleted file mode 100644 index 4ca93f453..000000000 --- a/shared/extra-utils/socket/socket-io.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { io } from 'socket.io-client' - -function getUserNotificationSocket (serverUrl: string, accessToken: string) { - return io(serverUrl + '/user-notifications', { - query: { accessToken } - }) -} - -function getLiveNotificationSocket (serverUrl: string) { - return io(serverUrl + '/live-videos') -} - -// --------------------------------------------------------------------------- - -export { - getUserNotificationSocket, - getLiveNotificationSocket -} -- cgit v1.2.3 From 5f8bd4cbb178290da7d8f81e996f19f0eccc8e4c Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 7 Jul 2021 16:02:46 +0200 Subject: Introduce blocklist command --- shared/extra-utils/socket/socket-io-command.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'shared/extra-utils/socket') diff --git a/shared/extra-utils/socket/socket-io-command.ts b/shared/extra-utils/socket/socket-io-command.ts index 545561bed..c277ead28 100644 --- a/shared/extra-utils/socket/socket-io-command.ts +++ b/shared/extra-utils/socket/socket-io-command.ts @@ -5,7 +5,7 @@ export class SocketIOCommand extends AbstractCommand { getUserNotificationSocket (options: OverrideCommandOptions = {}) { return io(this.server.url + '/user-notifications', { - query: { accessToken: this.server.accessToken } + query: { accessToken: options.token ?? this.server.accessToken } }) } -- cgit v1.2.3