aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/controllers
diff options
context:
space:
mode:
Diffstat (limited to 'server/controllers')
-rw-r--r--server/controllers/api/users/index.ts3
-rw-r--r--server/controllers/api/users/my-notifications.ts15
2 files changed, 13 insertions, 5 deletions
diff --git a/server/controllers/api/users/index.ts b/server/controllers/api/users/index.ts
index 98be46ea2..9e6a019f6 100644
--- a/server/controllers/api/users/index.ts
+++ b/server/controllers/api/users/index.ts
@@ -40,6 +40,7 @@ import { deleteUserToken } from '../../../lib/oauth-model'
40import { myBlocklistRouter } from './my-blocklist' 40import { myBlocklistRouter } from './my-blocklist'
41import { myVideosHistoryRouter } from './my-history' 41import { myVideosHistoryRouter } from './my-history'
42import { myNotificationsRouter } from './my-notifications' 42import { myNotificationsRouter } from './my-notifications'
43import { Notifier } from '../../../lib/notifier'
43 44
44const auditLogger = auditLoggerFactory('users') 45const auditLogger = auditLoggerFactory('users')
45 46
@@ -213,6 +214,8 @@ async function registerUser (req: express.Request, res: express.Response) {
213 await sendVerifyUserEmail(user) 214 await sendVerifyUserEmail(user)
214 } 215 }
215 216
217 Notifier.Instance.notifyOnNewUserRegistration(user)
218
216 return res.type('json').status(204).end() 219 return res.type('json').status(204).end()
217} 220}
218 221
diff --git a/server/controllers/api/users/my-notifications.ts b/server/controllers/api/users/my-notifications.ts
index 4b81777a4..d74d26add 100644
--- a/server/controllers/api/users/my-notifications.ts
+++ b/server/controllers/api/users/my-notifications.ts
@@ -18,7 +18,7 @@ import {
18 markAsReadUserNotificationsValidator, 18 markAsReadUserNotificationsValidator,
19 updateNotificationSettingsValidator 19 updateNotificationSettingsValidator
20} from '../../../middlewares/validators/user-notifications' 20} from '../../../middlewares/validators/user-notifications'
21import { UserNotificationSetting, UserNotificationSettingValue } from '../../../../shared/models/users' 21import { UserNotificationSetting } from '../../../../shared/models/users'
22import { UserNotificationSettingModel } from '../../../models/account/user-notification-setting' 22import { UserNotificationSettingModel } from '../../../models/account/user-notification-setting'
23 23
24const myNotificationsRouter = express.Router() 24const myNotificationsRouter = express.Router()
@@ -53,7 +53,7 @@ export {
53 53
54async function updateNotificationSettings (req: express.Request, res: express.Response) { 54async function updateNotificationSettings (req: express.Request, res: express.Response) {
55 const user: UserModel = res.locals.oauth.token.User 55 const user: UserModel = res.locals.oauth.token.User
56 const body: UserNotificationSetting = req.body 56 const body = req.body
57 57
58 const query = { 58 const query = {
59 where: { 59 where: {
@@ -61,14 +61,19 @@ async function updateNotificationSettings (req: express.Request, res: express.Re
61 } 61 }
62 } 62 }
63 63
64 await UserNotificationSettingModel.update({ 64 const values: UserNotificationSetting = {
65 newVideoFromSubscription: body.newVideoFromSubscription, 65 newVideoFromSubscription: body.newVideoFromSubscription,
66 newCommentOnMyVideo: body.newCommentOnMyVideo, 66 newCommentOnMyVideo: body.newCommentOnMyVideo,
67 videoAbuseAsModerator: body.videoAbuseAsModerator, 67 videoAbuseAsModerator: body.videoAbuseAsModerator,
68 blacklistOnMyVideo: body.blacklistOnMyVideo, 68 blacklistOnMyVideo: body.blacklistOnMyVideo,
69 myVideoPublished: body.myVideoPublished, 69 myVideoPublished: body.myVideoPublished,
70 myVideoImportFinished: body.myVideoImportFinished 70 myVideoImportFinished: body.myVideoImportFinished,
71 }, query) 71 newFollow: body.newFollow,
72 newUserRegistration: body.newUserRegistration,
73 commentMention: body.commentMention,
74 }
75
76 await UserNotificationSettingModel.update(values, query)
72 77
73 return res.status(204).end() 78 return res.status(204).end()
74} 79}