aboutsummaryrefslogtreecommitdiffhomepage
path: root/server
diff options
context:
space:
mode:
Diffstat (limited to 'server')
-rw-r--r--server/lib/activitypub/crawl.ts8
-rw-r--r--server/tests/api/notifications/user-notifications.ts22
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 @@
1import { ACTIVITY_PUB, JOB_REQUEST_TIMEOUT } from '../../initializers/constants' 1import { ACTIVITY_PUB, JOB_REQUEST_TIMEOUT, WEBSERVER } from '../../initializers/constants'
2import { doRequest } from '../../helpers/requests' 2import { doRequest } from '../../helpers/requests'
3import { logger } from '../../helpers/logger' 3import { logger } from '../../helpers/logger'
4import * as Bluebird from 'bluebird' 4import * as Bluebird from 'bluebird'
5import { ActivityPubOrderedCollection } from '../../../shared/models/activitypub' 5import { ActivityPubOrderedCollection } from '../../../shared/models/activitypub'
6import { checkUrlsSameHost } from '../../helpers/activitypub'
7import { parse } from "url"
6 8
7type HandlerFunction<T> = (items: T[]) => (Promise<any> | Bluebird<any>) 9type HandlerFunction<T> = (items: T[]) => (Promise<any> | Bluebird<any>)
8type CleanerFunction = (startedDate: Date) => (Promise<any> | Bluebird<any>) 10type 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'
4import 'mocha' 4import 'mocha'
5import { 5import {
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'
24import { killallServers, ServerInfo, uploadVideo } from '../../../../shared/extra-utils/index' 27import { ServerInfo, uploadVideo } from '../../../../shared/extra-utils/index'
25import { setAccessTokensToServers } from '../../../../shared/extra-utils/users/login' 28import { setAccessTokensToServers } from '../../../../shared/extra-utils/users/login'
26import { waitJobs } from '../../../../shared/extra-utils/server/jobs' 29import { waitJobs } from '../../../../shared/extra-utils/server/jobs'
27import { getUserNotificationSocket } from '../../../../shared/extra-utils/socket/socket-io' 30import { 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'
46import { 50import {
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