aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/controllers/api/users
diff options
context:
space:
mode:
Diffstat (limited to 'server/controllers/api/users')
-rw-r--r--server/controllers/api/users/my-notifications.ts12
1 files changed, 9 insertions, 3 deletions
diff --git a/server/controllers/api/users/my-notifications.ts b/server/controllers/api/users/my-notifications.ts
index cef1d237c..4b81777a4 100644
--- a/server/controllers/api/users/my-notifications.ts
+++ b/server/controllers/api/users/my-notifications.ts
@@ -14,10 +14,11 @@ import { getFormattedObjects } from '../../../helpers/utils'
14import { UserNotificationModel } from '../../../models/account/user-notification' 14import { UserNotificationModel } from '../../../models/account/user-notification'
15import { meRouter } from './me' 15import { meRouter } from './me'
16import { 16import {
17 listUserNotificationsValidator,
17 markAsReadUserNotificationsValidator, 18 markAsReadUserNotificationsValidator,
18 updateNotificationSettingsValidator 19 updateNotificationSettingsValidator
19} from '../../../middlewares/validators/user-notifications' 20} from '../../../middlewares/validators/user-notifications'
20import { UserNotificationSetting } from '../../../../shared/models/users' 21import { UserNotificationSetting, UserNotificationSettingValue } from '../../../../shared/models/users'
21import { UserNotificationSettingModel } from '../../../models/account/user-notification-setting' 22import { UserNotificationSettingModel } from '../../../models/account/user-notification-setting'
22 23
23const myNotificationsRouter = express.Router() 24const myNotificationsRouter = express.Router()
@@ -34,6 +35,7 @@ myNotificationsRouter.get('/me/notifications',
34 userNotificationsSortValidator, 35 userNotificationsSortValidator,
35 setDefaultSort, 36 setDefaultSort,
36 setDefaultPagination, 37 setDefaultPagination,
38 listUserNotificationsValidator,
37 asyncMiddleware(listUserNotifications) 39 asyncMiddleware(listUserNotifications)
38) 40)
39 41
@@ -61,7 +63,11 @@ async function updateNotificationSettings (req: express.Request, res: express.Re
61 63
62 await UserNotificationSettingModel.update({ 64 await UserNotificationSettingModel.update({
63 newVideoFromSubscription: body.newVideoFromSubscription, 65 newVideoFromSubscription: body.newVideoFromSubscription,
64 newCommentOnMyVideo: body.newCommentOnMyVideo 66 newCommentOnMyVideo: body.newCommentOnMyVideo,
67 videoAbuseAsModerator: body.videoAbuseAsModerator,
68 blacklistOnMyVideo: body.blacklistOnMyVideo,
69 myVideoPublished: body.myVideoPublished,
70 myVideoImportFinished: body.myVideoImportFinished
65 }, query) 71 }, query)
66 72
67 return res.status(204).end() 73 return res.status(204).end()
@@ -70,7 +76,7 @@ async function updateNotificationSettings (req: express.Request, res: express.Re
70async function listUserNotifications (req: express.Request, res: express.Response) { 76async function listUserNotifications (req: express.Request, res: express.Response) {
71 const user: UserModel = res.locals.oauth.token.User 77 const user: UserModel = res.locals.oauth.token.User
72 78
73 const resultList = await UserNotificationModel.listForApi(user.id, req.query.start, req.query.count, req.query.sort) 79 const resultList = await UserNotificationModel.listForApi(user.id, req.query.start, req.query.count, req.query.sort, req.query.unread)
74 80
75 return res.json(getFormattedObjects(resultList.data, resultList.total)) 81 return res.json(getFormattedObjects(resultList.data, resultList.total))
76} 82}