diff options
Diffstat (limited to 'server/models/video/video-comment.ts')
-rw-r--r-- | server/models/video/video-comment.ts | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/server/models/video/video-comment.ts b/server/models/video/video-comment.ts index dbb2fe429..fffa4bb57 100644 --- a/server/models/video/video-comment.ts +++ b/server/models/video/video-comment.ts | |||
@@ -208,7 +208,7 @@ export class VideoCommentModel extends Model<VideoCommentModel> { | |||
208 | .findOne(query) | 208 | .findOne(query) |
209 | } | 209 | } |
210 | 210 | ||
211 | static loadByUrl (url: string, t?: Sequelize.Transaction) { | 211 | static loadByUrlAndPopulateAccount (url: string, t?: Sequelize.Transaction) { |
212 | const query: IFindOptions<VideoCommentModel> = { | 212 | const query: IFindOptions<VideoCommentModel> = { |
213 | where: { | 213 | where: { |
214 | url | 214 | url |
@@ -217,10 +217,10 @@ export class VideoCommentModel extends Model<VideoCommentModel> { | |||
217 | 217 | ||
218 | if (t !== undefined) query.transaction = t | 218 | if (t !== undefined) query.transaction = t |
219 | 219 | ||
220 | return VideoCommentModel.findOne(query) | 220 | return VideoCommentModel.scope([ ScopeNames.WITH_ACCOUNT ]).findOne(query) |
221 | } | 221 | } |
222 | 222 | ||
223 | static loadByUrlAndPopulateAccount (url: string, t?: Sequelize.Transaction) { | 223 | static loadByUrlAndPopulateReplyAndVideo (url: string, t?: Sequelize.Transaction) { |
224 | const query: IFindOptions<VideoCommentModel> = { | 224 | const query: IFindOptions<VideoCommentModel> = { |
225 | where: { | 225 | where: { |
226 | url | 226 | url |
@@ -229,7 +229,7 @@ export class VideoCommentModel extends Model<VideoCommentModel> { | |||
229 | 229 | ||
230 | if (t !== undefined) query.transaction = t | 230 | if (t !== undefined) query.transaction = t |
231 | 231 | ||
232 | return VideoCommentModel.scope([ ScopeNames.WITH_ACCOUNT ]).findOne(query) | 232 | return VideoCommentModel.scope([ ScopeNames.WITH_IN_REPLY_TO, ScopeNames.WITH_VIDEO ]).findOne(query) |
233 | } | 233 | } |
234 | 234 | ||
235 | static listThreadsForApi (videoId: number, start: number, count: number, sort: string) { | 235 | static listThreadsForApi (videoId: number, start: number, count: number, sort: string) { |
@@ -271,9 +271,9 @@ export class VideoCommentModel extends Model<VideoCommentModel> { | |||
271 | }) | 271 | }) |
272 | } | 272 | } |
273 | 273 | ||
274 | static listThreadParentComments (comment: VideoCommentModel, t: Sequelize.Transaction) { | 274 | static listThreadParentComments (comment: VideoCommentModel, t: Sequelize.Transaction, order: 'ASC' | 'DESC' = 'ASC') { |
275 | const query = { | 275 | const query = { |
276 | order: [ [ 'createdAt', 'ASC' ] ], | 276 | order: [ [ 'createdAt', order ] ], |
277 | where: { | 277 | where: { |
278 | [ Sequelize.Op.or ]: [ | 278 | [ Sequelize.Op.or ]: [ |
279 | { id: comment.getThreadId() }, | 279 | { id: comment.getThreadId() }, |
@@ -281,6 +281,9 @@ export class VideoCommentModel extends Model<VideoCommentModel> { | |||
281 | ], | 281 | ], |
282 | id: { | 282 | id: { |
283 | [ Sequelize.Op.ne ]: comment.id | 283 | [ Sequelize.Op.ne ]: comment.id |
284 | }, | ||
285 | createdAt: { | ||
286 | [ Sequelize.Op.lt ]: comment.createdAt | ||
284 | } | 287 | } |
285 | }, | 288 | }, |
286 | transaction: t | 289 | transaction: t |