diff options
Diffstat (limited to 'server/controllers/api')
-rw-r--r-- | server/controllers/api/users/my-notifications.ts | 12 |
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' | |||
14 | import { UserNotificationModel } from '../../../models/account/user-notification' | 14 | import { UserNotificationModel } from '../../../models/account/user-notification' |
15 | import { meRouter } from './me' | 15 | import { meRouter } from './me' |
16 | import { | 16 | import { |
17 | listUserNotificationsValidator, | ||
17 | markAsReadUserNotificationsValidator, | 18 | markAsReadUserNotificationsValidator, |
18 | updateNotificationSettingsValidator | 19 | updateNotificationSettingsValidator |
19 | } from '../../../middlewares/validators/user-notifications' | 20 | } from '../../../middlewares/validators/user-notifications' |
20 | import { UserNotificationSetting } from '../../../../shared/models/users' | 21 | import { UserNotificationSetting, UserNotificationSettingValue } from '../../../../shared/models/users' |
21 | import { UserNotificationSettingModel } from '../../../models/account/user-notification-setting' | 22 | import { UserNotificationSettingModel } from '../../../models/account/user-notification-setting' |
22 | 23 | ||
23 | const myNotificationsRouter = express.Router() | 24 | const 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 | |||
70 | async function listUserNotifications (req: express.Request, res: express.Response) { | 76 | async 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 | } |