Notify local users with internal video privacy
This commit is contained in:
parent
da992cbcab
commit
56d48fc41b
3 changed files with 25 additions and 20 deletions
|
@ -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 () {
|
||||
|
|
|
@ -19,7 +19,11 @@ export class NewVideoOrLiveForSubscribers extends AbstractNotification <MVideoAc
|
|||
}
|
||||
|
||||
isDisabled () {
|
||||
return this.payload.privacy !== VideoPrivacy.PUBLIC || this.payload.state !== VideoState.PUBLISHED || this.payload.isBlacklisted()
|
||||
if (this.payload.privacy !== VideoPrivacy.PUBLIC && this.payload.privacy !== VideoPrivacy.INTERNAL) return true
|
||||
if (this.payload.state !== VideoState.PUBLISHED) return true
|
||||
if (this.payload.isBlacklisted()) return true
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
getSetting (user: MUserWithNotificationSetting) {
|
||||
|
|
|
@ -156,13 +156,12 @@ export async function addVideoJobsAfterUpdate (options: {
|
|||
}
|
||||
})
|
||||
|
||||
const wasConfidentialVideo = new Set<VideoPrivacyType>([
|
||||
const wasConfidentialVideoForNotification = new Set<VideoPrivacyType>([
|
||||
VideoPrivacy.PRIVATE,
|
||||
VideoPrivacy.UNLISTED,
|
||||
VideoPrivacy.INTERNAL
|
||||
VideoPrivacy.UNLISTED
|
||||
]).has(oldPrivacy)
|
||||
|
||||
if (wasConfidentialVideo) {
|
||||
if (wasConfidentialVideoForNotification) {
|
||||
jobs.push({
|
||||
type: 'notify',
|
||||
payload: {
|
||||
|
|
Loading…
Add table
Reference in a new issue