diff --git a/packages/tests/src/api/notifications/user-notifications.ts b/packages/tests/src/api/notifications/user-notifications.ts index 2f1fe2191..cadf3fa5a 100644 --- a/packages/tests/src/api/notifications/user-notifications.ts +++ b/packages/tests/src/api/notifications/user-notifications.ts @@ -1,24 +1,24 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ -import { expect } from 'chai' import { wait } from '@peertube/peertube-core-utils' import { UserNotification, UserNotificationType, VideoPrivacy, VideoStudioTask } from '@peertube/peertube-models' import { buildUUID } from '@peertube/peertube-node-utils' import { cleanupTests, findExternalSavedVideo, PeerTubeServer, stopFfmpeg, waitJobs } from '@peertube/peertube-server-commands' +import { FIXTURE_URLS } from '@tests/shared/fixture-urls.js' import { MockSmtpServer } from '@tests/shared/mock-servers/mock-email.js' import { - prepareNotificationsTest, CheckerBaseParams, - checkNewVideoFromSubscription, - checkMyVideoIsPublished, - checkVideoStudioEditionIsFinished, checkMyVideoImportIsFinished, + checkMyVideoIsPublished, checkNewActorFollow, checkNewLiveFromSubscription, + checkNewVideoFromSubscription, + checkVideoStudioEditionIsFinished, + prepareNotificationsTest, waitUntilNotification } from '@tests/shared/notifications.js' -import { FIXTURE_URLS } from '@tests/shared/fixture-urls.js' import { uploadRandomVideoOnServers } from '@tests/shared/videos.js' +import { expect } from 'chai' describe('Test user notifications', function () { let servers: PeerTubeServer[] = [] @@ -72,8 +72,10 @@ describe('Test user notifications', function () { await servers[0].subscriptions.add({ token: userAccessToken, targetUri: 'root_channel@' + servers[0].host }) await waitJobs(servers) - const { name, shortUUID } = await uploadRandomVideoOnServers(servers, 1) - await checkNewVideoFromSubscription({ ...baseParams, videoName: name, shortUUID, checkType: 'presence' }) + for (const privacy of [ VideoPrivacy.PUBLIC, VideoPrivacy.INTERNAL ]) { + const { name, shortUUID } = await uploadRandomVideoOnServers(servers, 1, { privacy }) + await checkNewVideoFromSubscription({ ...baseParams, videoName: name, shortUUID, checkType: 'presence' }) + } }) it('Should send a new video notification from a remote account', async function () { @@ -146,15 +148,16 @@ describe('Test user notifications', function () { it('Should send a new video notification when a video becomes public', async function () { this.timeout(50000) - const data = { privacy: VideoPrivacy.PRIVATE } - const { name, uuid, shortUUID } = await uploadRandomVideoOnServers(servers, 1, data) + for (const privacy of [ VideoPrivacy.PUBLIC, VideoPrivacy.INTERNAL ]) { + const { name, uuid, shortUUID } = await uploadRandomVideoOnServers(servers, 1, { privacy: VideoPrivacy.PRIVATE }) - await checkNewVideoFromSubscription({ ...baseParams, videoName: name, shortUUID, checkType: 'absence' }) + await checkNewVideoFromSubscription({ ...baseParams, videoName: name, shortUUID, checkType: 'absence' }) - await servers[0].videos.update({ id: uuid, attributes: { privacy: VideoPrivacy.PUBLIC } }) + await servers[0].videos.update({ id: uuid, attributes: { privacy } }) - await waitJobs(servers) - await checkNewVideoFromSubscription({ ...baseParams, videoName: name, shortUUID, checkType: 'presence' }) + await waitJobs(servers) + await checkNewVideoFromSubscription({ ...baseParams, videoName: name, shortUUID, checkType: 'presence' }) + } }) it('Should send a new video notification when a remote video becomes public', async function () { @@ -211,7 +214,6 @@ describe('Test user notifications', function () { await checkNewVideoFromSubscription({ ...baseParams, videoName: name, shortUUID: video.shortUUID, checkType: 'presence' }) }) - }) describe('New live from my subscription notification', function () { diff --git a/server/core/lib/notifier/shared/video-publication/new-video-or-live-for-subscribers.ts b/server/core/lib/notifier/shared/video-publication/new-video-or-live-for-subscribers.ts index 9bfe7720c..882295a0e 100644 --- a/server/core/lib/notifier/shared/video-publication/new-video-or-live-for-subscribers.ts +++ b/server/core/lib/notifier/shared/video-publication/new-video-or-live-for-subscribers.ts @@ -19,7 +19,11 @@ export class NewVideoOrLiveForSubscribers extends AbstractNotification ([ + const wasConfidentialVideoForNotification = new Set([ VideoPrivacy.PRIVATE, - VideoPrivacy.UNLISTED, - VideoPrivacy.INTERNAL + VideoPrivacy.UNLISTED ]).has(oldPrivacy) - if (wasConfidentialVideo) { + if (wasConfidentialVideoForNotification) { jobs.push({ type: 'notify', payload: {