Fix user notifications tests
This commit is contained in:
parent
2b4dd7e26d
commit
c0e71e849a
|
@ -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 { doRequest } from '../../helpers/requests'
|
||||||
import { logger } from '../../helpers/logger'
|
import { logger } from '../../helpers/logger'
|
||||||
import * as Bluebird from 'bluebird'
|
import * as Bluebird from 'bluebird'
|
||||||
import { ActivityPubOrderedCollection } from '../../../shared/models/activitypub'
|
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 HandlerFunction<T> = (items: T[]) => (Promise<any> | Bluebird<any>)
|
||||||
type CleanerFunction = (startedDate: Date) => (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 i = 0
|
||||||
let nextLink = firstBody.first
|
let nextLink = firstBody.first
|
||||||
while (nextLink && i < limit) {
|
while (nextLink && i < limit) {
|
||||||
|
// Don't crawl ourselves
|
||||||
|
const remoteHost = parse(nextLink).host
|
||||||
|
if (remoteHost === WEBSERVER.HOST) continue
|
||||||
|
|
||||||
options.uri = nextLink
|
options.uri = nextLink
|
||||||
|
|
||||||
const { body } = await doRequest<ActivityPubOrderedCollection<T>>(options)
|
const { body } = await doRequest<ActivityPubOrderedCollection<T>>(options)
|
||||||
|
|
|
@ -4,24 +4,27 @@ import * as chai from 'chai'
|
||||||
import 'mocha'
|
import 'mocha'
|
||||||
import {
|
import {
|
||||||
addVideoToBlacklist,
|
addVideoToBlacklist,
|
||||||
|
cleanupTests,
|
||||||
createUser,
|
createUser,
|
||||||
doubleFollow,
|
doubleFollow,
|
||||||
flushAndRunMultipleServers,
|
flushAndRunMultipleServers,
|
||||||
flushTests,
|
follow,
|
||||||
|
getCustomConfig,
|
||||||
getMyUserInformation,
|
getMyUserInformation,
|
||||||
|
getVideoCommentThreads,
|
||||||
|
getVideoThreadComments,
|
||||||
immutableAssign,
|
immutableAssign,
|
||||||
registerUser,
|
registerUser,
|
||||||
removeVideoFromBlacklist,
|
removeVideoFromBlacklist,
|
||||||
reportVideoAbuse,
|
reportVideoAbuse,
|
||||||
|
updateCustomConfig,
|
||||||
updateMyUser,
|
updateMyUser,
|
||||||
updateVideo,
|
updateVideo,
|
||||||
updateVideoChannel,
|
updateVideoChannel,
|
||||||
userLogin,
|
userLogin,
|
||||||
wait,
|
wait
|
||||||
getCustomConfig,
|
|
||||||
updateCustomConfig, getVideoThreadComments, getVideoCommentThreads, follow, cleanupTests
|
|
||||||
} from '../../../../shared/extra-utils'
|
} 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 { setAccessTokensToServers } from '../../../../shared/extra-utils/users/login'
|
||||||
import { waitJobs } from '../../../../shared/extra-utils/server/jobs'
|
import { waitJobs } from '../../../../shared/extra-utils/server/jobs'
|
||||||
import { getUserNotificationSocket } from '../../../../shared/extra-utils/socket/socket-io'
|
import { getUserNotificationSocket } from '../../../../shared/extra-utils/socket/socket-io'
|
||||||
|
@ -32,16 +35,17 @@ import {
|
||||||
checkNewActorFollow,
|
checkNewActorFollow,
|
||||||
checkNewBlacklistOnMyVideo,
|
checkNewBlacklistOnMyVideo,
|
||||||
checkNewCommentOnMyVideo,
|
checkNewCommentOnMyVideo,
|
||||||
|
checkNewInstanceFollower,
|
||||||
checkNewVideoAbuseForModerators,
|
checkNewVideoAbuseForModerators,
|
||||||
checkVideoAutoBlacklistForModerators,
|
|
||||||
checkNewVideoFromSubscription,
|
checkNewVideoFromSubscription,
|
||||||
checkUserRegistered,
|
checkUserRegistered,
|
||||||
|
checkVideoAutoBlacklistForModerators,
|
||||||
checkVideoIsPublished,
|
checkVideoIsPublished,
|
||||||
getLastNotification,
|
getLastNotification,
|
||||||
getUserNotifications,
|
getUserNotifications,
|
||||||
|
markAsReadAllNotifications,
|
||||||
markAsReadNotifications,
|
markAsReadNotifications,
|
||||||
updateMyNotificationSettings,
|
updateMyNotificationSettings
|
||||||
markAsReadAllNotifications, checkNewInstanceFollower
|
|
||||||
} from '../../../../shared/extra-utils/users/user-notifications'
|
} from '../../../../shared/extra-utils/users/user-notifications'
|
||||||
import {
|
import {
|
||||||
User,
|
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 () {
|
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)
|
await follow(servers[2].url, [ servers[0].url ], servers[2].accessToken)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue