Fix user notifications tests
authorChocobozzz <me@florianbigard.com>
Thu, 25 Apr 2019 12:23:15 +0000 (14:23 +0200)
committerChocobozzz <me@florianbigard.com>
Thu, 25 Apr 2019 12:23:15 +0000 (14:23 +0200)
server/lib/activitypub/crawl.ts
server/tests/api/notifications/user-notifications.ts

index ba5b67beeedb0bd795e4c686db43dc56de892c48..0ba59b47dde4c0c90e7d133ab2333f756bdaf27a 100644 (file)
@@ -1,8 +1,10 @@
-import { ACTIVITY_PUB, JOB_REQUEST_TIMEOUT } from '../../initializers/constants'
+import { ACTIVITY_PUB, JOB_REQUEST_TIMEOUT, WEBSERVER } from '../../initializers/constants'
 import { doRequest } from '../../helpers/requests'
 import { logger } from '../../helpers/logger'
 import * as Bluebird from 'bluebird'
 import { ActivityPubOrderedCollection } from '../../../shared/models/activitypub'
+import { checkUrlsSameHost } from '../../helpers/activitypub'
+import { parse } from "url"
 
 type HandlerFunction<T> = (items: T[]) => (Promise<any> | Bluebird<any>)
 type CleanerFunction = (startedDate: Date) => (Promise<any> | Bluebird<any>)
@@ -27,6 +29,10 @@ async function crawlCollectionPage <T> (uri: string, handler: HandlerFunction<T>
   let i = 0
   let nextLink = firstBody.first
   while (nextLink && i < limit) {
+    // Don't crawl ourselves
+    const remoteHost = parse(nextLink).host
+    if (remoteHost === WEBSERVER.HOST) continue
+
     options.uri = nextLink
 
     const { body } = await doRequest<ActivityPubOrderedCollection<T>>(options)
index 3874b0aab4cd19777ad5d452aa62ad9e2c0028da..f479e1785509c4ae9e75db7dae37482e74fbe6f3 100644 (file)
@@ -4,24 +4,27 @@ import * as chai from 'chai'
 import 'mocha'
 import {
   addVideoToBlacklist,
+  cleanupTests,
   createUser,
   doubleFollow,
   flushAndRunMultipleServers,
-  flushTests,
+  follow,
+  getCustomConfig,
   getMyUserInformation,
+  getVideoCommentThreads,
+  getVideoThreadComments,
   immutableAssign,
   registerUser,
   removeVideoFromBlacklist,
   reportVideoAbuse,
+  updateCustomConfig,
   updateMyUser,
   updateVideo,
   updateVideoChannel,
   userLogin,
-  wait,
-  getCustomConfig,
-  updateCustomConfig, getVideoThreadComments, getVideoCommentThreads, follow, cleanupTests
+  wait
 } from '../../../../shared/extra-utils'
-import { killallServers, ServerInfo, uploadVideo } from '../../../../shared/extra-utils/index'
+import { ServerInfo, uploadVideo } from '../../../../shared/extra-utils/index'
 import { setAccessTokensToServers } from '../../../../shared/extra-utils/users/login'
 import { waitJobs } from '../../../../shared/extra-utils/server/jobs'
 import { getUserNotificationSocket } from '../../../../shared/extra-utils/socket/socket-io'
@@ -32,16 +35,17 @@ import {
   checkNewActorFollow,
   checkNewBlacklistOnMyVideo,
   checkNewCommentOnMyVideo,
+  checkNewInstanceFollower,
   checkNewVideoAbuseForModerators,
-  checkVideoAutoBlacklistForModerators,
   checkNewVideoFromSubscription,
   checkUserRegistered,
+  checkVideoAutoBlacklistForModerators,
   checkVideoIsPublished,
   getLastNotification,
   getUserNotifications,
+  markAsReadAllNotifications,
   markAsReadNotifications,
-  updateMyNotificationSettings,
-  markAsReadAllNotifications, checkNewInstanceFollower
+  updateMyNotificationSettings
 } from '../../../../shared/extra-utils/users/user-notifications'
 import {
   User,
@@ -879,7 +883,7 @@ describe('Test users notifications', function () {
     })
 
     it('Should send a notification only to admin when there is a new instance follower', async function () {
-      this.timeout(10000)
+      this.timeout(20000)
 
       await follow(servers[2].url, [ servers[0].url ], servers[2].accessToken)