diff options
author | Chocobozzz <me@florianbigard.com> | 2019-03-19 10:35:15 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2019-03-19 10:35:15 +0100 |
commit | dae86118ed5d4026d04acb9d0e36829b9ad8eb4e (patch) | |
tree | a5bf9c4487240bf75a9b328cad459a0587f90dea /server/controllers/api/videos/comment.ts | |
parent | e65c0c5b1fab9c3d93f51721b2458cf5cf471f20 (diff) | |
download | PeerTube-dae86118ed5d4026d04acb9d0e36829b9ad8eb4e.tar.gz PeerTube-dae86118ed5d4026d04acb9d0e36829b9ad8eb4e.tar.zst PeerTube-dae86118ed5d4026d04acb9d0e36829b9ad8eb4e.zip |
Cleanup express locals typings
Diffstat (limited to 'server/controllers/api/videos/comment.ts')
-rw-r--r-- | server/controllers/api/videos/comment.ts | 23 |
1 files changed, 11 insertions, 12 deletions
diff --git a/server/controllers/api/videos/comment.ts b/server/controllers/api/videos/comment.ts index 70c1148ba..176ee8bd4 100644 --- a/server/controllers/api/videos/comment.ts +++ b/server/controllers/api/videos/comment.ts | |||
@@ -8,7 +8,8 @@ import { buildFormattedCommentTree, createVideoComment } from '../../../lib/vide | |||
8 | import { | 8 | import { |
9 | asyncMiddleware, | 9 | asyncMiddleware, |
10 | asyncRetryTransactionMiddleware, | 10 | asyncRetryTransactionMiddleware, |
11 | authenticate, optionalAuthenticate, | 11 | authenticate, |
12 | optionalAuthenticate, | ||
12 | paginationValidator, | 13 | paginationValidator, |
13 | setDefaultPagination, | 14 | setDefaultPagination, |
14 | setDefaultSort | 15 | setDefaultSort |
@@ -21,11 +22,9 @@ import { | |||
21 | removeVideoCommentValidator, | 22 | removeVideoCommentValidator, |
22 | videoCommentThreadsSortValidator | 23 | videoCommentThreadsSortValidator |
23 | } from '../../../middlewares/validators' | 24 | } from '../../../middlewares/validators' |
24 | import { VideoModel } from '../../../models/video/video' | ||
25 | import { VideoCommentModel } from '../../../models/video/video-comment' | 25 | import { VideoCommentModel } from '../../../models/video/video-comment' |
26 | import { auditLoggerFactory, CommentAuditView, getAuditIdFromRes } from '../../../helpers/audit-logger' | 26 | import { auditLoggerFactory, CommentAuditView, getAuditIdFromRes } from '../../../helpers/audit-logger' |
27 | import { AccountModel } from '../../../models/account/account' | 27 | import { AccountModel } from '../../../models/account/account' |
28 | import { UserModel } from '../../../models/account/user' | ||
29 | import { Notifier } from '../../../lib/notifier' | 28 | import { Notifier } from '../../../lib/notifier' |
30 | 29 | ||
31 | const auditLogger = auditLoggerFactory('comments') | 30 | const auditLogger = auditLoggerFactory('comments') |
@@ -70,9 +69,9 @@ export { | |||
70 | 69 | ||
71 | // --------------------------------------------------------------------------- | 70 | // --------------------------------------------------------------------------- |
72 | 71 | ||
73 | async function listVideoThreads (req: express.Request, res: express.Response, next: express.NextFunction) { | 72 | async function listVideoThreads (req: express.Request, res: express.Response) { |
74 | const video = res.locals.video as VideoModel | 73 | const video = res.locals.video |
75 | const user: UserModel = res.locals.oauth ? res.locals.oauth.token.User : undefined | 74 | const user = res.locals.oauth ? res.locals.oauth.token.User : undefined |
76 | 75 | ||
77 | let resultList: ResultList<VideoCommentModel> | 76 | let resultList: ResultList<VideoCommentModel> |
78 | 77 | ||
@@ -88,9 +87,9 @@ async function listVideoThreads (req: express.Request, res: express.Response, ne | |||
88 | return res.json(getFormattedObjects(resultList.data, resultList.total)) | 87 | return res.json(getFormattedObjects(resultList.data, resultList.total)) |
89 | } | 88 | } |
90 | 89 | ||
91 | async function listVideoThreadComments (req: express.Request, res: express.Response, next: express.NextFunction) { | 90 | async function listVideoThreadComments (req: express.Request, res: express.Response) { |
92 | const video = res.locals.video as VideoModel | 91 | const video = res.locals.video |
93 | const user: UserModel = res.locals.oauth ? res.locals.oauth.token.User : undefined | 92 | const user = res.locals.oauth ? res.locals.oauth.token.User : undefined |
94 | 93 | ||
95 | let resultList: ResultList<VideoCommentModel> | 94 | let resultList: ResultList<VideoCommentModel> |
96 | 95 | ||
@@ -110,7 +109,7 @@ async function addVideoCommentThread (req: express.Request, res: express.Respons | |||
110 | const videoCommentInfo: VideoCommentCreate = req.body | 109 | const videoCommentInfo: VideoCommentCreate = req.body |
111 | 110 | ||
112 | const comment = await sequelizeTypescript.transaction(async t => { | 111 | const comment = await sequelizeTypescript.transaction(async t => { |
113 | const account = await AccountModel.load((res.locals.oauth.token.User as UserModel).Account.id, t) | 112 | const account = await AccountModel.load(res.locals.oauth.token.User.Account.id, t) |
114 | 113 | ||
115 | return createVideoComment({ | 114 | return createVideoComment({ |
116 | text: videoCommentInfo.text, | 115 | text: videoCommentInfo.text, |
@@ -132,7 +131,7 @@ async function addVideoCommentReply (req: express.Request, res: express.Response | |||
132 | const videoCommentInfo: VideoCommentCreate = req.body | 131 | const videoCommentInfo: VideoCommentCreate = req.body |
133 | 132 | ||
134 | const comment = await sequelizeTypescript.transaction(async t => { | 133 | const comment = await sequelizeTypescript.transaction(async t => { |
135 | const account = await AccountModel.load((res.locals.oauth.token.User as UserModel).Account.id, t) | 134 | const account = await AccountModel.load(res.locals.oauth.token.User.Account.id, t) |
136 | 135 | ||
137 | return createVideoComment({ | 136 | return createVideoComment({ |
138 | text: videoCommentInfo.text, | 137 | text: videoCommentInfo.text, |
@@ -149,7 +148,7 @@ async function addVideoCommentReply (req: express.Request, res: express.Response | |||
149 | } | 148 | } |
150 | 149 | ||
151 | async function removeVideoComment (req: express.Request, res: express.Response) { | 150 | async function removeVideoComment (req: express.Request, res: express.Response) { |
152 | const videoCommentInstance: VideoCommentModel = res.locals.videoComment | 151 | const videoCommentInstance = res.locals.videoComment |
153 | 152 | ||
154 | await sequelizeTypescript.transaction(async t => { | 153 | await sequelizeTypescript.transaction(async t => { |
155 | await videoCommentInstance.destroy({ transaction: t }) | 154 | await videoCommentInstance.destroy({ transaction: t }) |