diff options
Diffstat (limited to 'shared')
-rw-r--r-- | shared/extra-utils/index.ts | 1 | ||||
-rw-r--r-- | shared/extra-utils/server/servers.ts | 3 | ||||
-rw-r--r-- | shared/extra-utils/socket/index.ts | 1 | ||||
-rw-r--r-- | shared/extra-utils/socket/socket-io-command.ts | 15 | ||||
-rw-r--r-- | shared/extra-utils/socket/socket-io.ts | 18 | ||||
-rw-r--r-- | shared/extra-utils/users/user-notifications.ts | 7 |
6 files changed, 23 insertions, 22 deletions
diff --git a/shared/extra-utils/index.ts b/shared/extra-utils/index.ts index f69d7241e..ed7d7ab04 100644 --- a/shared/extra-utils/index.ts +++ b/shared/extra-utils/index.ts | |||
@@ -9,6 +9,7 @@ export * from './moderation' | |||
9 | export * from './overviews' | 9 | export * from './overviews' |
10 | export * from './search' | 10 | export * from './search' |
11 | export * from './server' | 11 | export * from './server' |
12 | export * from './socket' | ||
12 | 13 | ||
13 | export * from './requests/check-api-params' | 14 | export * from './requests/check-api-params' |
14 | export * from './requests/requests' | 15 | export * from './requests/requests' |
diff --git a/shared/extra-utils/server/servers.ts b/shared/extra-utils/server/servers.ts index c33b68316..8bd4446be 100644 --- a/shared/extra-utils/server/servers.ts +++ b/shared/extra-utils/server/servers.ts | |||
@@ -16,6 +16,7 @@ import { AbusesCommand } from '../moderation' | |||
16 | import { OverviewsCommand } from '../overviews' | 16 | import { OverviewsCommand } from '../overviews' |
17 | import { makeGetRequest } from '../requests/requests' | 17 | import { makeGetRequest } from '../requests/requests' |
18 | import { SearchCommand } from '../search' | 18 | import { SearchCommand } from '../search' |
19 | import { SocketIOCommand } from '../socket' | ||
19 | import { ConfigCommand } from './config-command' | 20 | import { ConfigCommand } from './config-command' |
20 | import { ContactFormCommand } from './contact-form-command' | 21 | import { ContactFormCommand } from './contact-form-command' |
21 | import { DebugCommand } from './debug-command' | 22 | import { DebugCommand } from './debug-command' |
@@ -93,6 +94,7 @@ interface ServerInfo { | |||
93 | redundancyCommand?: RedundancyCommand | 94 | redundancyCommand?: RedundancyCommand |
94 | statsCommand?: StatsCommand | 95 | statsCommand?: StatsCommand |
95 | configCommand?: ConfigCommand | 96 | configCommand?: ConfigCommand |
97 | socketIOCommand?: SocketIOCommand | ||
96 | } | 98 | } |
97 | 99 | ||
98 | function parallelTests () { | 100 | function parallelTests () { |
@@ -314,6 +316,7 @@ async function runServer (server: ServerInfo, configOverrideArg?: any, args = [] | |||
314 | server.redundancyCommand = new RedundancyCommand(server) | 316 | server.redundancyCommand = new RedundancyCommand(server) |
315 | server.statsCommand = new StatsCommand(server) | 317 | server.statsCommand = new StatsCommand(server) |
316 | server.configCommand = new ConfigCommand(server) | 318 | server.configCommand = new ConfigCommand(server) |
319 | server.socketIOCommand = new SocketIOCommand(server) | ||
317 | 320 | ||
318 | res(server) | 321 | res(server) |
319 | }) | 322 | }) |
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 @@ | |||
1 | import { io } from 'socket.io-client' | ||
2 | import { AbstractCommand, OverrideCommandOptions } from '../shared' | ||
3 | |||
4 | export class SocketIOCommand extends AbstractCommand { | ||
5 | |||
6 | getUserNotificationSocket (options: OverrideCommandOptions = {}) { | ||
7 | return io(this.server.url + '/user-notifications', { | ||
8 | query: { accessToken: this.server.accessToken } | ||
9 | }) | ||
10 | } | ||
11 | |||
12 | getLiveNotificationSocket () { | ||
13 | return io(this.server.url + '/live-videos') | ||
14 | } | ||
15 | } | ||
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 @@ | |||
1 | import { io } from 'socket.io-client' | ||
2 | |||
3 | function getUserNotificationSocket (serverUrl: string, accessToken: string) { | ||
4 | return io(serverUrl + '/user-notifications', { | ||
5 | query: { accessToken } | ||
6 | }) | ||
7 | } | ||
8 | |||
9 | function getLiveNotificationSocket (serverUrl: string) { | ||
10 | return io(serverUrl + '/live-videos') | ||
11 | } | ||
12 | |||
13 | // --------------------------------------------------------------------------- | ||
14 | |||
15 | export { | ||
16 | getUserNotificationSocket, | ||
17 | getLiveNotificationSocket | ||
18 | } | ||
diff --git a/shared/extra-utils/users/user-notifications.ts b/shared/extra-utils/users/user-notifications.ts index e75946eec..961cfcc0f 100644 --- a/shared/extra-utils/users/user-notifications.ts +++ b/shared/extra-utils/users/user-notifications.ts | |||
@@ -9,7 +9,6 @@ import { MockSmtpServer } from '../mock-servers/mock-email' | |||
9 | import { makeGetRequest, makePostBodyRequest, makePutBodyRequest } from '../requests/requests' | 9 | import { makeGetRequest, makePostBodyRequest, makePutBodyRequest } from '../requests/requests' |
10 | import { doubleFollow } from '../server/follows' | 10 | import { doubleFollow } from '../server/follows' |
11 | import { flushAndRunMultipleServers, ServerInfo } from '../server/servers' | 11 | import { flushAndRunMultipleServers, ServerInfo } from '../server/servers' |
12 | import { getUserNotificationSocket } from '../socket/socket-io' | ||
13 | import { setAccessTokensToServers, userLogin } from './login' | 12 | import { setAccessTokensToServers, userLogin } from './login' |
14 | import { createUser, getMyUserInformation } from './users' | 13 | import { createUser, getMyUserInformation } from './users' |
15 | 14 | ||
@@ -748,16 +747,16 @@ async function prepareNotificationsTest (serversCount = 3, overrideConfigArg: an | |||
748 | } | 747 | } |
749 | 748 | ||
750 | { | 749 | { |
751 | const socket = getUserNotificationSocket(servers[0].url, userAccessToken) | 750 | const socket = servers[0].socketIOCommand.getUserNotificationSocket({ token: userAccessToken }) |
752 | socket.on('new-notification', n => userNotifications.push(n)) | 751 | socket.on('new-notification', n => userNotifications.push(n)) |
753 | } | 752 | } |
754 | { | 753 | { |
755 | const socket = getUserNotificationSocket(servers[0].url, servers[0].accessToken) | 754 | const socket = servers[0].socketIOCommand.getUserNotificationSocket() |
756 | socket.on('new-notification', n => adminNotifications.push(n)) | 755 | socket.on('new-notification', n => adminNotifications.push(n)) |
757 | } | 756 | } |
758 | 757 | ||
759 | if (serversCount > 1) { | 758 | if (serversCount > 1) { |
760 | const socket = getUserNotificationSocket(servers[1].url, servers[1].accessToken) | 759 | const socket = servers[1].socketIOCommand.getUserNotificationSocket() |
761 | socket.on('new-notification', n => adminNotificationsServer2.push(n)) | 760 | socket.on('new-notification', n => adminNotificationsServer2.push(n)) |
762 | } | 761 | } |
763 | 762 | ||