aboutsummaryrefslogtreecommitdiffhomepage
path: root/server
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2019-01-08 11:26:41 +0100
committerChocobozzz <chocobozzz@cpy.re>2019-01-09 11:15:15 +0100
commit2f1548fda32c3ba9e53913270394eedfacd55986 (patch)
treeafee28df36a9e00f921603d9091e5d08d5818159 /server
parentf7cc67b455a12ccae9b0ea16876d166720364357 (diff)
downloadPeerTube-2f1548fda32c3ba9e53913270394eedfacd55986.tar.gz
PeerTube-2f1548fda32c3ba9e53913270394eedfacd55986.tar.zst
PeerTube-2f1548fda32c3ba9e53913270394eedfacd55986.zip
Add notifications in the client
Diffstat (limited to 'server')
-rw-r--r--server/controllers/api/users/my-notifications.ts15
-rw-r--r--server/helpers/custom-validators/misc.ts6
-rw-r--r--server/helpers/custom-validators/user-notifications.ts8
-rw-r--r--server/initializers/migrations/0315-user-notifications.ts2
-rw-r--r--server/lib/notifier.ts4
-rw-r--r--server/lib/user.ts18
-rw-r--r--server/middlewares/validators/user-notifications.ts5
-rw-r--r--server/models/account/user-notification.ts6
-rw-r--r--server/tests/api/check-params/user-notifications.ts51
-rw-r--r--server/tests/api/check-params/users.ts3
-rw-r--r--server/tests/api/users/user-notifications.ts50
-rw-r--r--server/tests/api/users/users.ts4
12 files changed, 120 insertions, 52 deletions
diff --git a/server/controllers/api/users/my-notifications.ts b/server/controllers/api/users/my-notifications.ts
index d74d26add..76cf97587 100644
--- a/server/controllers/api/users/my-notifications.ts
+++ b/server/controllers/api/users/my-notifications.ts
@@ -45,6 +45,11 @@ myNotificationsRouter.post('/me/notifications/read',
45 asyncMiddleware(markAsReadUserNotifications) 45 asyncMiddleware(markAsReadUserNotifications)
46) 46)
47 47
48myNotificationsRouter.post('/me/notifications/read-all',
49 authenticate,
50 asyncMiddleware(markAsReadAllUserNotifications)
51)
52
48export { 53export {
49 myNotificationsRouter 54 myNotificationsRouter
50} 55}
@@ -70,7 +75,7 @@ async function updateNotificationSettings (req: express.Request, res: express.Re
70 myVideoImportFinished: body.myVideoImportFinished, 75 myVideoImportFinished: body.myVideoImportFinished,
71 newFollow: body.newFollow, 76 newFollow: body.newFollow,
72 newUserRegistration: body.newUserRegistration, 77 newUserRegistration: body.newUserRegistration,
73 commentMention: body.commentMention, 78 commentMention: body.commentMention
74 } 79 }
75 80
76 await UserNotificationSettingModel.update(values, query) 81 await UserNotificationSettingModel.update(values, query)
@@ -93,3 +98,11 @@ async function markAsReadUserNotifications (req: express.Request, res: express.R
93 98
94 return res.status(204).end() 99 return res.status(204).end()
95} 100}
101
102async function markAsReadAllUserNotifications (req: express.Request, res: express.Response) {
103 const user: UserModel = res.locals.oauth.token.User
104
105 await UserNotificationModel.markAllAsRead(user.id)
106
107 return res.status(204).end()
108}
diff --git a/server/helpers/custom-validators/misc.ts b/server/helpers/custom-validators/misc.ts
index a093e3e1b..b6f0ebe6f 100644
--- a/server/helpers/custom-validators/misc.ts
+++ b/server/helpers/custom-validators/misc.ts
@@ -9,8 +9,8 @@ function isArray (value: any) {
9 return Array.isArray(value) 9 return Array.isArray(value)
10} 10}
11 11
12function isIntArray (value: any) { 12function isNotEmptyIntArray (value: any) {
13 return Array.isArray(value) && value.every(v => validator.isInt('' + v)) 13 return Array.isArray(value) && value.every(v => validator.isInt('' + v)) && value.length !== 0
14} 14}
15 15
16function isDateValid (value: string) { 16function isDateValid (value: string) {
@@ -82,7 +82,7 @@ function isFileValid (
82 82
83export { 83export {
84 exists, 84 exists,
85 isIntArray, 85 isNotEmptyIntArray,
86 isArray, 86 isArray,
87 isIdValid, 87 isIdValid,
88 isUUIDValid, 88 isUUIDValid,
diff --git a/server/helpers/custom-validators/user-notifications.ts b/server/helpers/custom-validators/user-notifications.ts
index 4fb5d922d..02ea3bbc2 100644
--- a/server/helpers/custom-validators/user-notifications.ts
+++ b/server/helpers/custom-validators/user-notifications.ts
@@ -9,8 +9,12 @@ function isUserNotificationTypeValid (value: any) {
9 9
10function isUserNotificationSettingValid (value: any) { 10function isUserNotificationSettingValid (value: any) {
11 return exists(value) && 11 return exists(value) &&
12 validator.isInt('' + value) && 12 validator.isInt('' + value) && (
13 UserNotificationSettingValue[ value ] !== undefined 13 value === UserNotificationSettingValue.NONE ||
14 value === UserNotificationSettingValue.WEB ||
15 value === UserNotificationSettingValue.EMAIL ||
16 value === (UserNotificationSettingValue.WEB | UserNotificationSettingValue.EMAIL)
17 )
14} 18}
15 19
16export { 20export {
diff --git a/server/initializers/migrations/0315-user-notifications.ts b/server/initializers/migrations/0315-user-notifications.ts
index 34f9fd193..8284c58a0 100644
--- a/server/initializers/migrations/0315-user-notifications.ts
+++ b/server/initializers/migrations/0315-user-notifications.ts
@@ -31,7 +31,7 @@ PRIMARY KEY ("id"))
31 '("newVideoFromSubscription", "newCommentOnMyVideo", "videoAbuseAsModerator", "blacklistOnMyVideo", ' + 31 '("newVideoFromSubscription", "newCommentOnMyVideo", "videoAbuseAsModerator", "blacklistOnMyVideo", ' +
32 '"myVideoPublished", "myVideoImportFinished", "newUserRegistration", "newFollow", "commentMention", ' + 32 '"myVideoPublished", "myVideoImportFinished", "newUserRegistration", "newFollow", "commentMention", ' +
33 '"userId", "createdAt", "updatedAt") ' + 33 '"userId", "createdAt", "updatedAt") ' +
34 '(SELECT 2, 2, 4, 4, 2, 2, 2, 2, 2, id, NOW(), NOW() FROM "user")' 34 '(SELECT 1, 1, 3, 3, 1, 1, 1, 1, 1, id, NOW(), NOW() FROM "user")'
35 35
36 await utils.sequelize.query(query) 36 await utils.sequelize.query(query)
37 } 37 }
diff --git a/server/lib/notifier.ts b/server/lib/notifier.ts
index 2c51d7101..d1b331346 100644
--- a/server/lib/notifier.ts
+++ b/server/lib/notifier.ts
@@ -436,11 +436,11 @@ class Notifier {
436 private isEmailEnabled (user: UserModel, value: UserNotificationSettingValue) { 436 private isEmailEnabled (user: UserModel, value: UserNotificationSettingValue) {
437 if (CONFIG.SIGNUP.REQUIRES_EMAIL_VERIFICATION === true && user.emailVerified !== true) return false 437 if (CONFIG.SIGNUP.REQUIRES_EMAIL_VERIFICATION === true && user.emailVerified !== true) return false
438 438
439 return value === UserNotificationSettingValue.EMAIL || value === UserNotificationSettingValue.WEB_NOTIFICATION_AND_EMAIL 439 return value & UserNotificationSettingValue.EMAIL
440 } 440 }
441 441
442 private isWebNotificationEnabled (value: UserNotificationSettingValue) { 442 private isWebNotificationEnabled (value: UserNotificationSettingValue) {
443 return value === UserNotificationSettingValue.WEB_NOTIFICATION || value === UserNotificationSettingValue.WEB_NOTIFICATION_AND_EMAIL 443 return value & UserNotificationSettingValue.WEB
444 } 444 }
445 445
446 static get Instance () { 446 static get Instance () {
diff --git a/server/lib/user.ts b/server/lib/user.ts
index 9e24e85a0..a39ef6c3d 100644
--- a/server/lib/user.ts
+++ b/server/lib/user.ts
@@ -98,15 +98,15 @@ export {
98function createDefaultUserNotificationSettings (user: UserModel, t: Sequelize.Transaction | undefined) { 98function createDefaultUserNotificationSettings (user: UserModel, t: Sequelize.Transaction | undefined) {
99 const values: UserNotificationSetting & { userId: number } = { 99 const values: UserNotificationSetting & { userId: number } = {
100 userId: user.id, 100 userId: user.id,
101 newVideoFromSubscription: UserNotificationSettingValue.WEB_NOTIFICATION, 101 newVideoFromSubscription: UserNotificationSettingValue.WEB,
102 newCommentOnMyVideo: UserNotificationSettingValue.WEB_NOTIFICATION, 102 newCommentOnMyVideo: UserNotificationSettingValue.WEB,
103 myVideoImportFinished: UserNotificationSettingValue.WEB_NOTIFICATION, 103 myVideoImportFinished: UserNotificationSettingValue.WEB,
104 myVideoPublished: UserNotificationSettingValue.WEB_NOTIFICATION, 104 myVideoPublished: UserNotificationSettingValue.WEB,
105 videoAbuseAsModerator: UserNotificationSettingValue.WEB_NOTIFICATION_AND_EMAIL, 105 videoAbuseAsModerator: UserNotificationSettingValue.WEB | UserNotificationSettingValue.EMAIL,
106 blacklistOnMyVideo: UserNotificationSettingValue.WEB_NOTIFICATION_AND_EMAIL, 106 blacklistOnMyVideo: UserNotificationSettingValue.WEB | UserNotificationSettingValue.EMAIL,
107 newUserRegistration: UserNotificationSettingValue.WEB_NOTIFICATION, 107 newUserRegistration: UserNotificationSettingValue.WEB,
108 commentMention: UserNotificationSettingValue.WEB_NOTIFICATION, 108 commentMention: UserNotificationSettingValue.WEB,
109 newFollow: UserNotificationSettingValue.WEB_NOTIFICATION 109 newFollow: UserNotificationSettingValue.WEB
110 } 110 }
111 111
112 return UserNotificationSettingModel.create(values, { transaction: t }) 112 return UserNotificationSettingModel.create(values, { transaction: t })
diff --git a/server/middlewares/validators/user-notifications.ts b/server/middlewares/validators/user-notifications.ts
index 1c31f0a73..46486e081 100644
--- a/server/middlewares/validators/user-notifications.ts
+++ b/server/middlewares/validators/user-notifications.ts
@@ -4,7 +4,7 @@ import { body, query } from 'express-validator/check'
4import { logger } from '../../helpers/logger' 4import { logger } from '../../helpers/logger'
5import { areValidationErrors } from './utils' 5import { areValidationErrors } from './utils'
6import { isUserNotificationSettingValid } from '../../helpers/custom-validators/user-notifications' 6import { isUserNotificationSettingValid } from '../../helpers/custom-validators/user-notifications'
7import { isIntArray } from '../../helpers/custom-validators/misc' 7import { isNotEmptyIntArray } from '../../helpers/custom-validators/misc'
8 8
9const listUserNotificationsValidator = [ 9const listUserNotificationsValidator = [
10 query('unread') 10 query('unread')
@@ -42,7 +42,8 @@ const updateNotificationSettingsValidator = [
42 42
43const markAsReadUserNotificationsValidator = [ 43const markAsReadUserNotificationsValidator = [
44 body('ids') 44 body('ids')
45 .custom(isIntArray).withMessage('Should have a valid notification ids to mark as read'), 45 .optional()
46 .custom(isNotEmptyIntArray).withMessage('Should have a valid notification ids to mark as read'),
46 47
47 (req: express.Request, res: express.Response, next: express.NextFunction) => { 48 (req: express.Request, res: express.Response, next: express.NextFunction) => {
48 logger.debug('Checking markAsReadUserNotificationsValidator parameters', { parameters: req.body }) 49 logger.debug('Checking markAsReadUserNotificationsValidator parameters', { parameters: req.body })
diff --git a/server/models/account/user-notification.ts b/server/models/account/user-notification.ts
index 79afce600..9e4f982a3 100644
--- a/server/models/account/user-notification.ts
+++ b/server/models/account/user-notification.ts
@@ -290,6 +290,12 @@ export class UserNotificationModel extends Model<UserNotificationModel> {
290 return UserNotificationModel.update({ read: true }, query) 290 return UserNotificationModel.update({ read: true }, query)
291 } 291 }
292 292
293 static markAllAsRead (userId: number) {
294 const query = { where: { userId } }
295
296 return UserNotificationModel.update({ read: true }, query)
297 }
298
293 toFormattedJSON (): UserNotification { 299 toFormattedJSON (): UserNotification {
294 const video = this.Video ? Object.assign(this.formatVideo(this.Video), { 300 const video = this.Video ? Object.assign(this.formatVideo(this.Video), {
295 channel: { 301 channel: {
diff --git a/server/tests/api/check-params/user-notifications.ts b/server/tests/api/check-params/user-notifications.ts
index 635f5c9a3..714f481e9 100644
--- a/server/tests/api/check-params/user-notifications.ts
+++ b/server/tests/api/check-params/user-notifications.ts
@@ -100,6 +100,16 @@ describe('Test user notifications API validators', function () {
100 url: server.url, 100 url: server.url,
101 path, 101 path,
102 fields: { 102 fields: {
103 ids: [ ]
104 },
105 token: server.accessToken,
106 statusCodeExpected: 400
107 })
108
109 await makePostBodyRequest({
110 url: server.url,
111 path,
112 fields: {
103 ids: 5 113 ids: 5
104 }, 114 },
105 token: server.accessToken, 115 token: server.accessToken,
@@ -131,18 +141,39 @@ describe('Test user notifications API validators', function () {
131 }) 141 })
132 }) 142 })
133 143
144 describe('When marking as read my notifications', function () {
145 const path = '/api/v1/users/me/notifications/read-all'
146
147 it('Should fail with a non authenticated user', async function () {
148 await makePostBodyRequest({
149 url: server.url,
150 path,
151 statusCodeExpected: 401
152 })
153 })
154
155 it('Should succeed with the correct parameters', async function () {
156 await makePostBodyRequest({
157 url: server.url,
158 path,
159 token: server.accessToken,
160 statusCodeExpected: 204
161 })
162 })
163 })
164
134 describe('When updating my notification settings', function () { 165 describe('When updating my notification settings', function () {
135 const path = '/api/v1/users/me/notification-settings' 166 const path = '/api/v1/users/me/notification-settings'
136 const correctFields: UserNotificationSetting = { 167 const correctFields: UserNotificationSetting = {
137 newVideoFromSubscription: UserNotificationSettingValue.WEB_NOTIFICATION, 168 newVideoFromSubscription: UserNotificationSettingValue.WEB,
138 newCommentOnMyVideo: UserNotificationSettingValue.WEB_NOTIFICATION, 169 newCommentOnMyVideo: UserNotificationSettingValue.WEB,
139 videoAbuseAsModerator: UserNotificationSettingValue.WEB_NOTIFICATION, 170 videoAbuseAsModerator: UserNotificationSettingValue.WEB,
140 blacklistOnMyVideo: UserNotificationSettingValue.WEB_NOTIFICATION, 171 blacklistOnMyVideo: UserNotificationSettingValue.WEB,
141 myVideoImportFinished: UserNotificationSettingValue.WEB_NOTIFICATION, 172 myVideoImportFinished: UserNotificationSettingValue.WEB,
142 myVideoPublished: UserNotificationSettingValue.WEB_NOTIFICATION, 173 myVideoPublished: UserNotificationSettingValue.WEB,
143 commentMention: UserNotificationSettingValue.WEB_NOTIFICATION, 174 commentMention: UserNotificationSettingValue.WEB,
144 newFollow: UserNotificationSettingValue.WEB_NOTIFICATION, 175 newFollow: UserNotificationSettingValue.WEB,
145 newUserRegistration: UserNotificationSettingValue.WEB_NOTIFICATION 176 newUserRegistration: UserNotificationSettingValue.WEB
146 } 177 }
147 178
148 it('Should fail with missing fields', async function () { 179 it('Should fail with missing fields', async function () {
@@ -150,7 +181,7 @@ describe('Test user notifications API validators', function () {
150 url: server.url, 181 url: server.url,
151 path, 182 path,
152 token: server.accessToken, 183 token: server.accessToken,
153 fields: { newVideoFromSubscription: UserNotificationSettingValue.WEB_NOTIFICATION }, 184 fields: { newVideoFromSubscription: UserNotificationSettingValue.WEB },
154 statusCodeExpected: 400 185 statusCodeExpected: 400
155 }) 186 })
156 }) 187 })
diff --git a/server/tests/api/check-params/users.ts b/server/tests/api/check-params/users.ts
index f8044cbd4..a3e8e2e9c 100644
--- a/server/tests/api/check-params/users.ts
+++ b/server/tests/api/check-params/users.ts
@@ -485,11 +485,10 @@ describe('Test users API validators', function () {
485 email: 'email@example.com', 485 email: 'email@example.com',
486 emailVerified: true, 486 emailVerified: true,
487 videoQuota: 42, 487 videoQuota: 42,
488 role: UserRole.MODERATOR 488 role: UserRole.USER
489 } 489 }
490 490
491 await makePutBodyRequest({ url: server.url, path: path + userId, token: server.accessToken, fields, statusCodeExpected: 204 }) 491 await makePutBodyRequest({ url: server.url, path: path + userId, token: server.accessToken, fields, statusCodeExpected: 204 })
492 userAccessToken = await userLogin(server, user)
493 }) 492 })
494 }) 493 })
495 494
diff --git a/server/tests/api/users/user-notifications.ts b/server/tests/api/users/user-notifications.ts
index ae77b4db2..ad68d8e69 100644
--- a/server/tests/api/users/user-notifications.ts
+++ b/server/tests/api/users/user-notifications.ts
@@ -37,7 +37,8 @@ import {
37 getLastNotification, 37 getLastNotification,
38 getUserNotifications, 38 getUserNotifications,
39 markAsReadNotifications, 39 markAsReadNotifications,
40 updateMyNotificationSettings 40 updateMyNotificationSettings,
41 markAsReadAllNotifications
41} from '../../../../shared/utils/users/user-notifications' 42} from '../../../../shared/utils/users/user-notifications'
42import { 43import {
43 User, 44 User,
@@ -88,15 +89,15 @@ describe('Test users notifications', function () {
88 let channelId: number 89 let channelId: number
89 90
90 const allNotificationSettings: UserNotificationSetting = { 91 const allNotificationSettings: UserNotificationSetting = {
91 newVideoFromSubscription: UserNotificationSettingValue.WEB_NOTIFICATION_AND_EMAIL, 92 newVideoFromSubscription: UserNotificationSettingValue.WEB | UserNotificationSettingValue.EMAIL,
92 newCommentOnMyVideo: UserNotificationSettingValue.WEB_NOTIFICATION_AND_EMAIL, 93 newCommentOnMyVideo: UserNotificationSettingValue.WEB | UserNotificationSettingValue.EMAIL,
93 videoAbuseAsModerator: UserNotificationSettingValue.WEB_NOTIFICATION_AND_EMAIL, 94 videoAbuseAsModerator: UserNotificationSettingValue.WEB | UserNotificationSettingValue.EMAIL,
94 blacklistOnMyVideo: UserNotificationSettingValue.WEB_NOTIFICATION_AND_EMAIL, 95 blacklistOnMyVideo: UserNotificationSettingValue.WEB | UserNotificationSettingValue.EMAIL,
95 myVideoImportFinished: UserNotificationSettingValue.WEB_NOTIFICATION_AND_EMAIL, 96 myVideoImportFinished: UserNotificationSettingValue.WEB | UserNotificationSettingValue.EMAIL,
96 myVideoPublished: UserNotificationSettingValue.WEB_NOTIFICATION_AND_EMAIL, 97 myVideoPublished: UserNotificationSettingValue.WEB | UserNotificationSettingValue.EMAIL,
97 commentMention: UserNotificationSettingValue.WEB_NOTIFICATION_AND_EMAIL, 98 commentMention: UserNotificationSettingValue.WEB | UserNotificationSettingValue.EMAIL,
98 newFollow: UserNotificationSettingValue.WEB_NOTIFICATION_AND_EMAIL, 99 newFollow: UserNotificationSettingValue.WEB | UserNotificationSettingValue.EMAIL,
99 newUserRegistration: UserNotificationSettingValue.WEB_NOTIFICATION_AND_EMAIL 100 newUserRegistration: UserNotificationSettingValue.WEB | UserNotificationSettingValue.EMAIL
100 } 101 }
101 102
102 before(async function () { 103 before(async function () {
@@ -174,7 +175,10 @@ describe('Test users notifications', function () {
174 }) 175 })
175 176
176 it('Should send a new video notification if the user follows the local video publisher', async function () { 177 it('Should send a new video notification if the user follows the local video publisher', async function () {
178 this.timeout(10000)
179
177 await addUserSubscription(servers[0].url, userAccessToken, 'root_channel@localhost:9001') 180 await addUserSubscription(servers[0].url, userAccessToken, 'root_channel@localhost:9001')
181 await waitJobs(servers)
178 182
179 const { name, uuid } = await uploadVideoByLocalAccount(servers) 183 const { name, uuid } = await uploadVideoByLocalAccount(servers)
180 await checkNewVideoFromSubscription(baseParams, name, uuid, 'presence') 184 await checkNewVideoFromSubscription(baseParams, name, uuid, 'presence')
@@ -184,6 +188,7 @@ describe('Test users notifications', function () {
184 this.timeout(50000) // Server 2 has transcoding enabled 188 this.timeout(50000) // Server 2 has transcoding enabled
185 189
186 await addUserSubscription(servers[0].url, userAccessToken, 'root_channel@localhost:9002') 190 await addUserSubscription(servers[0].url, userAccessToken, 'root_channel@localhost:9002')
191 await waitJobs(servers)
187 192
188 const { name, uuid } = await uploadVideoByRemoteAccount(servers) 193 const { name, uuid } = await uploadVideoByRemoteAccount(servers)
189 await checkNewVideoFromSubscription(baseParams, name, uuid, 'presence') 194 await checkNewVideoFromSubscription(baseParams, name, uuid, 'presence')
@@ -822,8 +827,9 @@ describe('Test users notifications', function () {
822 }) 827 })
823 828
824 it('Should notify when a local channel is following one of our channel', async function () { 829 it('Should notify when a local channel is following one of our channel', async function () {
825 await addUserSubscription(servers[0].url, servers[0].accessToken, 'user_1_channel@localhost:9001') 830 this.timeout(10000)
826 831
832 await addUserSubscription(servers[0].url, servers[0].accessToken, 'user_1_channel@localhost:9001')
827 await waitJobs(servers) 833 await waitJobs(servers)
828 834
829 await checkNewActorFollow(baseParams, 'channel', 'root', 'super root name', myChannelName, 'presence') 835 await checkNewActorFollow(baseParams, 'channel', 'root', 'super root name', myChannelName, 'presence')
@@ -832,8 +838,9 @@ describe('Test users notifications', function () {
832 }) 838 })
833 839
834 it('Should notify when a remote channel is following one of our channel', async function () { 840 it('Should notify when a remote channel is following one of our channel', async function () {
835 await addUserSubscription(servers[1].url, servers[1].accessToken, 'user_1_channel@localhost:9001') 841 this.timeout(10000)
836 842
843 await addUserSubscription(servers[1].url, servers[1].accessToken, 'user_1_channel@localhost:9001')
837 await waitJobs(servers) 844 await waitJobs(servers)
838 845
839 await checkNewActorFollow(baseParams, 'channel', 'root', 'super root 2 name', myChannelName, 'presence') 846 await checkNewActorFollow(baseParams, 'channel', 'root', 'super root 2 name', myChannelName, 'presence')
@@ -895,6 +902,15 @@ describe('Test users notifications', function () {
895 expect(notification.read).to.be.false 902 expect(notification.read).to.be.false
896 } 903 }
897 }) 904 })
905
906 it('Should mark as read all notifications', async function () {
907 await markAsReadAllNotifications(servers[ 0 ].url, userAccessToken)
908
909 const res = await getUserNotifications(servers[ 0 ].url, userAccessToken, 0, 10, true)
910
911 expect(res.body.total).to.equal(0)
912 expect(res.body.data).to.have.lengthOf(0)
913 })
898 }) 914 })
899 915
900 describe('Notification settings', function () { 916 describe('Notification settings', function () {
@@ -928,13 +944,13 @@ describe('Test users notifications', function () {
928 944
929 it('Should only have web notifications', async function () { 945 it('Should only have web notifications', async function () {
930 await updateMyNotificationSettings(servers[0].url, userAccessToken, immutableAssign(allNotificationSettings, { 946 await updateMyNotificationSettings(servers[0].url, userAccessToken, immutableAssign(allNotificationSettings, {
931 newVideoFromSubscription: UserNotificationSettingValue.WEB_NOTIFICATION 947 newVideoFromSubscription: UserNotificationSettingValue.WEB
932 })) 948 }))
933 949
934 { 950 {
935 const res = await getMyUserInformation(servers[0].url, userAccessToken) 951 const res = await getMyUserInformation(servers[0].url, userAccessToken)
936 const info = res.body as User 952 const info = res.body as User
937 expect(info.notificationSettings.newVideoFromSubscription).to.equal(UserNotificationSettingValue.WEB_NOTIFICATION) 953 expect(info.notificationSettings.newVideoFromSubscription).to.equal(UserNotificationSettingValue.WEB)
938 } 954 }
939 955
940 const { name, uuid } = await uploadVideoByLocalAccount(servers) 956 const { name, uuid } = await uploadVideoByLocalAccount(servers)
@@ -976,13 +992,15 @@ describe('Test users notifications', function () {
976 992
977 it('Should have email and web notifications', async function () { 993 it('Should have email and web notifications', async function () {
978 await updateMyNotificationSettings(servers[0].url, userAccessToken, immutableAssign(allNotificationSettings, { 994 await updateMyNotificationSettings(servers[0].url, userAccessToken, immutableAssign(allNotificationSettings, {
979 newVideoFromSubscription: UserNotificationSettingValue.WEB_NOTIFICATION_AND_EMAIL 995 newVideoFromSubscription: UserNotificationSettingValue.WEB | UserNotificationSettingValue.EMAIL
980 })) 996 }))
981 997
982 { 998 {
983 const res = await getMyUserInformation(servers[0].url, userAccessToken) 999 const res = await getMyUserInformation(servers[0].url, userAccessToken)
984 const info = res.body as User 1000 const info = res.body as User
985 expect(info.notificationSettings.newVideoFromSubscription).to.equal(UserNotificationSettingValue.WEB_NOTIFICATION_AND_EMAIL) 1001 expect(info.notificationSettings.newVideoFromSubscription).to.equal(
1002 UserNotificationSettingValue.WEB | UserNotificationSettingValue.EMAIL
1003 )
986 } 1004 }
987 1005
988 const { name, uuid } = await uploadVideoByLocalAccount(servers) 1006 const { name, uuid } = await uploadVideoByLocalAccount(servers)
diff --git a/server/tests/api/users/users.ts b/server/tests/api/users/users.ts
index 4914c8ed5..ad98ab1c7 100644
--- a/server/tests/api/users/users.ts
+++ b/server/tests/api/users/users.ts
@@ -501,10 +501,6 @@ describe('Test users', function () {
501 accessTokenUser = await userLogin(server, user) 501 accessTokenUser = await userLogin(server, user)
502 }) 502 })
503 503
504 it('Should not be able to delete a user by a moderator', async function () {
505 await removeUser(server.url, 2, accessTokenUser, 403)
506 })
507
508 it('Should be able to list video blacklist by a moderator', async function () { 504 it('Should be able to list video blacklist by a moderator', async function () {
509 await getBlacklistedVideosList(server.url, accessTokenUser) 505 await getBlacklistedVideosList(server.url, accessTokenUser)
510 }) 506 })