aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJosh Morel <morel.josh@hotmail.com>2019-02-06 06:14:45 -0500
committerChocobozzz <chocobozzz@cpy.re>2019-02-07 14:49:28 +0100
commitf7effe8dc7c641388f7edbcaad716fc16321d794 (patch)
tree8831663b7f0aae469630a7f8b5ae5350d395c1cf
parent552dd3306fe867d8be30508ef9f30a1738241082 (diff)
downloadPeerTube-f7effe8dc7c641388f7edbcaad716fc16321d794.tar.gz
PeerTube-f7effe8dc7c641388f7edbcaad716fc16321d794.tar.zst
PeerTube-f7effe8dc7c641388f7edbcaad716fc16321d794.zip
don't notify prior to scheduled update
also increase timeouts on user-notification test
-rw-r--r--server/lib/job-queue/handlers/video-file.ts10
-rw-r--r--server/tests/api/users/user-notifications.ts38
2 files changed, 44 insertions, 4 deletions
diff --git a/server/lib/job-queue/handlers/video-file.ts b/server/lib/job-queue/handlers/video-file.ts
index 593e43cc5..217d666b6 100644
--- a/server/lib/job-queue/handlers/video-file.ts
+++ b/server/lib/job-queue/handlers/video-file.ts
@@ -91,7 +91,8 @@ async function onVideoFileTranscoderOrImportSuccess (video: VideoModel) {
91 return { videoDatabase, videoPublished } 91 return { videoDatabase, videoPublished }
92 }) 92 })
93 93
94 if (videoPublished) { 94 // don't notify prior to scheduled video update
95 if (videoPublished && !videoDatabase.ScheduleVideoUpdate) {
95 Notifier.Instance.notifyOnNewVideo(videoDatabase) 96 Notifier.Instance.notifyOnNewVideo(videoDatabase)
96 Notifier.Instance.notifyOnPendingVideoPublished(videoDatabase) 97 Notifier.Instance.notifyOnPendingVideoPublished(videoDatabase)
97 } 98 }
@@ -149,8 +150,11 @@ async function onVideoFileOptimizerSuccess (videoArg: VideoModel, isNewVideo: bo
149 return { videoDatabase, videoPublished } 150 return { videoDatabase, videoPublished }
150 }) 151 })
151 152
152 if (isNewVideo) Notifier.Instance.notifyOnNewVideo(videoDatabase) 153 // don't notify prior to scheduled video update
153 if (videoPublished) Notifier.Instance.notifyOnPendingVideoPublished(videoDatabase) 154 if (!videoDatabase.ScheduleVideoUpdate) {
155 if (isNewVideo) Notifier.Instance.notifyOnNewVideo(videoDatabase)
156 if (videoPublished) Notifier.Instance.notifyOnPendingVideoPublished(videoDatabase)
157 }
154} 158}
155 159
156// --------------------------------------------------------------------------- 160// ---------------------------------------------------------------------------
diff --git a/server/tests/api/users/user-notifications.ts b/server/tests/api/users/user-notifications.ts
index 5260d64cc..317f68176 100644
--- a/server/tests/api/users/user-notifications.ts
+++ b/server/tests/api/users/user-notifications.ts
@@ -79,7 +79,7 @@ async function uploadVideoByLocalAccount (servers: ServerInfo[], additionalParam
79 return { uuid: res.body.video.uuid, name } 79 return { uuid: res.body.video.uuid, name }
80} 80}
81 81
82describe('Test users notifications', function () { 82describe.only('Test users notifications', function () {
83 let servers: ServerInfo[] = [] 83 let servers: ServerInfo[] = []
84 let userAccessToken: string 84 let userAccessToken: string
85 let userNotifications: UserNotification[] = [] 85 let userNotifications: UserNotification[] = []
@@ -165,6 +165,8 @@ describe('Test users notifications', function () {
165 }) 165 })
166 166
167 it('Should not send notifications if the user does not follow the video publisher', async function () { 167 it('Should not send notifications if the user does not follow the video publisher', async function () {
168 this.timeout(10000)
169
168 await uploadVideoByLocalAccount(servers) 170 await uploadVideoByLocalAccount(servers)
169 171
170 const notification = await getLastNotification(servers[ 0 ].url, userAccessToken) 172 const notification = await getLastNotification(servers[ 0 ].url, userAccessToken)
@@ -644,6 +646,8 @@ describe('Test users notifications', function () {
644 }) 646 })
645 647
646 it('Should not send a notification if transcoding is not enabled', async function () { 648 it('Should not send a notification if transcoding is not enabled', async function () {
649 this.timeout(10000)
650
647 const { name, uuid } = await uploadVideoByLocalAccount(servers) 651 const { name, uuid } = await uploadVideoByLocalAccount(servers)
648 await waitJobs(servers) 652 await waitJobs(servers)
649 653
@@ -717,6 +721,24 @@ describe('Test users notifications', function () {
717 await wait(6000) 721 await wait(6000)
718 await checkVideoIsPublished(baseParams, name, uuid, 'presence') 722 await checkVideoIsPublished(baseParams, name, uuid, 'presence')
719 }) 723 })
724
725 it('Should not send a notification before the video is published', async function () {
726 this.timeout(20000)
727
728 let updateAt = new Date(new Date().getTime() + 100000)
729
730 const data = {
731 privacy: VideoPrivacy.PRIVATE,
732 scheduleUpdate: {
733 updateAt: updateAt.toISOString(),
734 privacy: VideoPrivacy.PUBLIC
735 }
736 }
737 const { name, uuid } = await uploadVideoByRemoteAccount(servers, data)
738
739 await wait(6000)
740 await checkVideoIsPublished(baseParams, name, uuid, 'absence')
741 })
720 }) 742 })
721 743
722 describe('My video is imported', function () { 744 describe('My video is imported', function () {
@@ -781,6 +803,8 @@ describe('Test users notifications', function () {
781 }) 803 })
782 804
783 it('Should send a notification only to moderators when a user registers on the instance', async function () { 805 it('Should send a notification only to moderators when a user registers on the instance', async function () {
806 this.timeout(10000)
807
784 await registerUser(servers[0].url, 'user_45', 'password') 808 await registerUser(servers[0].url, 'user_45', 'password')
785 809
786 await waitJobs(servers) 810 await waitJobs(servers)
@@ -849,6 +873,8 @@ describe('Test users notifications', function () {
849 }) 873 })
850 874
851 it('Should notify when a local account is following one of our channel', async function () { 875 it('Should notify when a local account is following one of our channel', async function () {
876 this.timeout(10000)
877
852 await addUserSubscription(servers[0].url, servers[0].accessToken, 'user_1@localhost:9001') 878 await addUserSubscription(servers[0].url, servers[0].accessToken, 'user_1@localhost:9001')
853 879
854 await waitJobs(servers) 880 await waitJobs(servers)
@@ -857,6 +883,8 @@ describe('Test users notifications', function () {
857 }) 883 })
858 884
859 it('Should notify when a remote account is following one of our channel', async function () { 885 it('Should notify when a remote account is following one of our channel', async function () {
886 this.timeout(10000)
887
860 await addUserSubscription(servers[1].url, servers[1].accessToken, 'user_1@localhost:9001') 888 await addUserSubscription(servers[1].url, servers[1].accessToken, 'user_1@localhost:9001')
861 889
862 await waitJobs(servers) 890 await waitJobs(servers)
@@ -926,6 +954,8 @@ describe('Test users notifications', function () {
926 }) 954 })
927 955
928 it('Should not have notifications', async function () { 956 it('Should not have notifications', async function () {
957 this.timeout(10000)
958
929 await updateMyNotificationSettings(servers[0].url, userAccessToken, immutableAssign(allNotificationSettings, { 959 await updateMyNotificationSettings(servers[0].url, userAccessToken, immutableAssign(allNotificationSettings, {
930 newVideoFromSubscription: UserNotificationSettingValue.NONE 960 newVideoFromSubscription: UserNotificationSettingValue.NONE
931 })) 961 }))
@@ -943,6 +973,8 @@ describe('Test users notifications', function () {
943 }) 973 })
944 974
945 it('Should only have web notifications', async function () { 975 it('Should only have web notifications', async function () {
976 this.timeout(10000)
977
946 await updateMyNotificationSettings(servers[0].url, userAccessToken, immutableAssign(allNotificationSettings, { 978 await updateMyNotificationSettings(servers[0].url, userAccessToken, immutableAssign(allNotificationSettings, {
947 newVideoFromSubscription: UserNotificationSettingValue.WEB 979 newVideoFromSubscription: UserNotificationSettingValue.WEB
948 })) 980 }))
@@ -967,6 +999,8 @@ describe('Test users notifications', function () {
967 }) 999 })
968 1000
969 it('Should only have mail notifications', async function () { 1001 it('Should only have mail notifications', async function () {
1002 this.timeout(10000)
1003
970 await updateMyNotificationSettings(servers[0].url, userAccessToken, immutableAssign(allNotificationSettings, { 1004 await updateMyNotificationSettings(servers[0].url, userAccessToken, immutableAssign(allNotificationSettings, {
971 newVideoFromSubscription: UserNotificationSettingValue.EMAIL 1005 newVideoFromSubscription: UserNotificationSettingValue.EMAIL
972 })) 1006 }))
@@ -991,6 +1025,8 @@ describe('Test users notifications', function () {
991 }) 1025 })
992 1026
993 it('Should have email and web notifications', async function () { 1027 it('Should have email and web notifications', async function () {
1028 this.timeout(10000)
1029
994 await updateMyNotificationSettings(servers[0].url, userAccessToken, immutableAssign(allNotificationSettings, { 1030 await updateMyNotificationSettings(servers[0].url, userAccessToken, immutableAssign(allNotificationSettings, {
995 newVideoFromSubscription: UserNotificationSettingValue.WEB | UserNotificationSettingValue.EMAIL 1031 newVideoFromSubscription: UserNotificationSettingValue.WEB | UserNotificationSettingValue.EMAIL
996 })) 1032 }))