]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/controllers/api/users/my-notifications.ts
Implement signup approval in server
[github/Chocobozzz/PeerTube.git] / server / controllers / api / users / my-notifications.ts
index f146284e4acc50b7f9c60155533214402b6e7076..6014cdbbf7abec8ff35c99a5c4bb7d218e0e87ca 100644 (file)
@@ -1,5 +1,8 @@
-import * as express from 'express'
 import 'multer'
+import express from 'express'
+import { UserNotificationModel } from '@server/models/user/user-notification'
+import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes'
+import { UserNotificationSetting } from '../../../../shared/models/users'
 import {
   asyncMiddleware,
   asyncRetryTransactionMiddleware,
@@ -9,16 +12,14 @@ import {
   setDefaultSort,
   userNotificationsSortValidator
 } from '../../../middlewares'
-import { getFormattedObjects } from '../../../helpers/utils'
-import { UserNotificationModel } from '../../../models/account/user-notification'
-import { meRouter } from './me'
 import {
   listUserNotificationsValidator,
   markAsReadUserNotificationsValidator,
   updateNotificationSettingsValidator
 } from '../../../middlewares/validators/user-notifications'
-import { UserNotificationSetting } from '../../../../shared/models/users'
-import { UserNotificationSettingModel } from '../../../models/account/user-notification-setting'
+import { UserNotificationSettingModel } from '../../../models/user/user-notification-setting'
+import { meRouter } from './me'
+import { getFormattedObjects } from '@server/helpers/utils'
 
 const myNotificationsRouter = express.Router()
 
@@ -68,7 +69,7 @@ async function updateNotificationSettings (req: express.Request, res: express.Re
   const values: UserNotificationSetting = {
     newVideoFromSubscription: body.newVideoFromSubscription,
     newCommentOnMyVideo: body.newCommentOnMyVideo,
-    videoAbuseAsModerator: body.videoAbuseAsModerator,
+    abuseAsModerator: body.abuseAsModerator,
     videoAutoBlacklistAsModerator: body.videoAutoBlacklistAsModerator,
     blacklistOnMyVideo: body.blacklistOnMyVideo,
     myVideoPublished: body.myVideoPublished,
@@ -76,12 +77,18 @@ async function updateNotificationSettings (req: express.Request, res: express.Re
     newFollow: body.newFollow,
     newUserRegistration: body.newUserRegistration,
     commentMention: body.commentMention,
-    newInstanceFollower: body.newInstanceFollower
+    newInstanceFollower: body.newInstanceFollower,
+    autoInstanceFollowing: body.autoInstanceFollowing,
+    abuseNewMessage: body.abuseNewMessage,
+    abuseStateChange: body.abuseStateChange,
+    newPeerTubeVersion: body.newPeerTubeVersion,
+    newPluginVersion: body.newPluginVersion,
+    myVideoStudioEditionFinished: body.myVideoStudioEditionFinished
   }
 
   await UserNotificationSettingModel.update(values, query)
 
-  return res.status(204).end()
+  return res.status(HttpStatusCode.NO_CONTENT_204).end()
 }
 
 async function listUserNotifications (req: express.Request, res: express.Response) {
@@ -97,7 +104,7 @@ async function markAsReadUserNotifications (req: express.Request, res: express.R
 
   await UserNotificationModel.markAsRead(user.id, req.body.ids)
 
-  return res.status(204).end()
+  return res.status(HttpStatusCode.NO_CONTENT_204).end()
 }
 
 async function markAsReadAllUserNotifications (req: express.Request, res: express.Response) {
@@ -105,5 +112,5 @@ async function markAsReadAllUserNotifications (req: express.Request, res: expres
 
   await UserNotificationModel.markAllAsRead(user.id)
 
-  return res.status(204).end()
+  return res.status(HttpStatusCode.NO_CONTENT_204).end()
 }