diff options
author | Chocobozzz <me@florianbigard.com> | 2019-04-25 14:23:15 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2019-04-25 14:23:15 +0200 |
commit | c0e71e849a40871ed8eea3dacd8608d380bdb490 (patch) | |
tree | 0b6529213077acaafadbc5906e9de15855bcd920 /server | |
parent | 2b4dd7e26d93c2d9bef4f365cb03c511eff4ca8f (diff) | |
download | PeerTube-c0e71e849a40871ed8eea3dacd8608d380bdb490.tar.gz PeerTube-c0e71e849a40871ed8eea3dacd8608d380bdb490.tar.zst PeerTube-c0e71e849a40871ed8eea3dacd8608d380bdb490.zip |
Fix user notifications tests
Diffstat (limited to 'server')
-rw-r--r-- | server/lib/activitypub/crawl.ts | 8 | ||||
-rw-r--r-- | server/tests/api/notifications/user-notifications.ts | 22 |
2 files changed, 20 insertions, 10 deletions
diff --git a/server/lib/activitypub/crawl.ts b/server/lib/activitypub/crawl.ts index ba5b67bee..0ba59b47d 100644 --- a/server/lib/activitypub/crawl.ts +++ b/server/lib/activitypub/crawl.ts | |||
@@ -1,8 +1,10 @@ | |||
1 | import { ACTIVITY_PUB, JOB_REQUEST_TIMEOUT } from '../../initializers/constants' | 1 | import { ACTIVITY_PUB, JOB_REQUEST_TIMEOUT, WEBSERVER } from '../../initializers/constants' |
2 | import { doRequest } from '../../helpers/requests' | 2 | import { doRequest } from '../../helpers/requests' |
3 | import { logger } from '../../helpers/logger' | 3 | import { logger } from '../../helpers/logger' |
4 | import * as Bluebird from 'bluebird' | 4 | import * as Bluebird from 'bluebird' |
5 | import { ActivityPubOrderedCollection } from '../../../shared/models/activitypub' | 5 | import { ActivityPubOrderedCollection } from '../../../shared/models/activitypub' |
6 | import { checkUrlsSameHost } from '../../helpers/activitypub' | ||
7 | import { parse } from "url" | ||
6 | 8 | ||
7 | type HandlerFunction<T> = (items: T[]) => (Promise<any> | Bluebird<any>) | 9 | type HandlerFunction<T> = (items: T[]) => (Promise<any> | Bluebird<any>) |
8 | type CleanerFunction = (startedDate: Date) => (Promise<any> | Bluebird<any>) | 10 | type CleanerFunction = (startedDate: Date) => (Promise<any> | Bluebird<any>) |
@@ -27,6 +29,10 @@ async function crawlCollectionPage <T> (uri: string, handler: HandlerFunction<T> | |||
27 | let i = 0 | 29 | let i = 0 |
28 | let nextLink = firstBody.first | 30 | let nextLink = firstBody.first |
29 | while (nextLink && i < limit) { | 31 | while (nextLink && i < limit) { |
32 | // Don't crawl ourselves | ||
33 | const remoteHost = parse(nextLink).host | ||
34 | if (remoteHost === WEBSERVER.HOST) continue | ||
35 | |||
30 | options.uri = nextLink | 36 | options.uri = nextLink |
31 | 37 | ||
32 | const { body } = await doRequest<ActivityPubOrderedCollection<T>>(options) | 38 | const { body } = await doRequest<ActivityPubOrderedCollection<T>>(options) |
diff --git a/server/tests/api/notifications/user-notifications.ts b/server/tests/api/notifications/user-notifications.ts index 3874b0aab..f479e1785 100644 --- a/server/tests/api/notifications/user-notifications.ts +++ b/server/tests/api/notifications/user-notifications.ts | |||
@@ -4,24 +4,27 @@ import * as chai from 'chai' | |||
4 | import 'mocha' | 4 | import 'mocha' |
5 | import { | 5 | import { |
6 | addVideoToBlacklist, | 6 | addVideoToBlacklist, |
7 | cleanupTests, | ||
7 | createUser, | 8 | createUser, |
8 | doubleFollow, | 9 | doubleFollow, |
9 | flushAndRunMultipleServers, | 10 | flushAndRunMultipleServers, |
10 | flushTests, | 11 | follow, |
12 | getCustomConfig, | ||
11 | getMyUserInformation, | 13 | getMyUserInformation, |
14 | getVideoCommentThreads, | ||
15 | getVideoThreadComments, | ||
12 | immutableAssign, | 16 | immutableAssign, |
13 | registerUser, | 17 | registerUser, |
14 | removeVideoFromBlacklist, | 18 | removeVideoFromBlacklist, |
15 | reportVideoAbuse, | 19 | reportVideoAbuse, |
20 | updateCustomConfig, | ||
16 | updateMyUser, | 21 | updateMyUser, |
17 | updateVideo, | 22 | updateVideo, |
18 | updateVideoChannel, | 23 | updateVideoChannel, |
19 | userLogin, | 24 | userLogin, |
20 | wait, | 25 | wait |
21 | getCustomConfig, | ||
22 | updateCustomConfig, getVideoThreadComments, getVideoCommentThreads, follow, cleanupTests | ||
23 | } from '../../../../shared/extra-utils' | 26 | } from '../../../../shared/extra-utils' |
24 | import { killallServers, ServerInfo, uploadVideo } from '../../../../shared/extra-utils/index' | 27 | import { ServerInfo, uploadVideo } from '../../../../shared/extra-utils/index' |
25 | import { setAccessTokensToServers } from '../../../../shared/extra-utils/users/login' | 28 | import { setAccessTokensToServers } from '../../../../shared/extra-utils/users/login' |
26 | import { waitJobs } from '../../../../shared/extra-utils/server/jobs' | 29 | import { waitJobs } from '../../../../shared/extra-utils/server/jobs' |
27 | import { getUserNotificationSocket } from '../../../../shared/extra-utils/socket/socket-io' | 30 | import { getUserNotificationSocket } from '../../../../shared/extra-utils/socket/socket-io' |
@@ -32,16 +35,17 @@ import { | |||
32 | checkNewActorFollow, | 35 | checkNewActorFollow, |
33 | checkNewBlacklistOnMyVideo, | 36 | checkNewBlacklistOnMyVideo, |
34 | checkNewCommentOnMyVideo, | 37 | checkNewCommentOnMyVideo, |
38 | checkNewInstanceFollower, | ||
35 | checkNewVideoAbuseForModerators, | 39 | checkNewVideoAbuseForModerators, |
36 | checkVideoAutoBlacklistForModerators, | ||
37 | checkNewVideoFromSubscription, | 40 | checkNewVideoFromSubscription, |
38 | checkUserRegistered, | 41 | checkUserRegistered, |
42 | checkVideoAutoBlacklistForModerators, | ||
39 | checkVideoIsPublished, | 43 | checkVideoIsPublished, |
40 | getLastNotification, | 44 | getLastNotification, |
41 | getUserNotifications, | 45 | getUserNotifications, |
46 | markAsReadAllNotifications, | ||
42 | markAsReadNotifications, | 47 | markAsReadNotifications, |
43 | updateMyNotificationSettings, | 48 | updateMyNotificationSettings |
44 | markAsReadAllNotifications, checkNewInstanceFollower | ||
45 | } from '../../../../shared/extra-utils/users/user-notifications' | 49 | } from '../../../../shared/extra-utils/users/user-notifications' |
46 | import { | 50 | import { |
47 | User, | 51 | User, |
@@ -879,7 +883,7 @@ describe('Test users notifications', function () { | |||
879 | }) | 883 | }) |
880 | 884 | ||
881 | it('Should send a notification only to admin when there is a new instance follower', async function () { | 885 | it('Should send a notification only to admin when there is a new instance follower', async function () { |
882 | this.timeout(10000) | 886 | this.timeout(20000) |
883 | 887 | ||
884 | await follow(servers[2].url, [ servers[0].url ], servers[2].accessToken) | 888 | await follow(servers[2].url, [ servers[0].url ], servers[2].accessToken) |
885 | 889 | ||