aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2020-05-19 10:48:50 +0200
committerChocobozzz <chocobozzz@cpy.re>2020-05-29 09:21:26 +0200
commit8adf0a767f0816465ac3a8f4a6c63f53dd05fe3d (patch)
tree6633e5e17a2c64d670aab2a7bcf9b46f76cea32f /server/models
parent923ff87da2761fd88a8ca269ac1ef403abb583d2 (diff)
downloadPeerTube-8adf0a767f0816465ac3a8f4a6c63f53dd05fe3d.tar.gz
PeerTube-8adf0a767f0816465ac3a8f4a6c63f53dd05fe3d.tar.zst
PeerTube-8adf0a767f0816465ac3a8f4a6c63f53dd05fe3d.zip
Fix comments deleted display
Diffstat (limited to 'server/models')
-rw-r--r--server/models/video/video-comment.ts52
1 files changed, 42 insertions, 10 deletions
diff --git a/server/models/video/video-comment.ts b/server/models/video/video-comment.ts
index 7c890ce6d..dfeb1c4e7 100644
--- a/server/models/video/video-comment.ts
+++ b/server/models/video/video-comment.ts
@@ -24,13 +24,14 @@ import {
24 MCommentOwnerVideoReply 24 MCommentOwnerVideoReply
25} from '../../typings/models/video' 25} from '../../typings/models/video'
26import { AccountModel } from '../account/account' 26import { AccountModel } from '../account/account'
27import { ActorModel } from '../activitypub/actor' 27import { ActorModel, unusedActorAttributesForAPI } from '../activitypub/actor'
28import { buildBlockedAccountSQL, buildLocalAccountIdsIn, getCommentSort, throwIfNotValid } from '../utils' 28import { buildBlockedAccountSQL, buildLocalAccountIdsIn, getCommentSort, throwIfNotValid } from '../utils'
29import { VideoModel } from './video' 29import { VideoModel } from './video'
30import { VideoChannelModel } from './video-channel' 30import { VideoChannelModel } from './video-channel'
31 31
32enum ScopeNames { 32enum ScopeNames {
33 WITH_ACCOUNT = 'WITH_ACCOUNT', 33 WITH_ACCOUNT = 'WITH_ACCOUNT',
34 WITH_ACCOUNT_FOR_API = 'WITH_ACCOUNT_FOR_API',
34 WITH_IN_REPLY_TO = 'WITH_IN_REPLY_TO', 35 WITH_IN_REPLY_TO = 'WITH_IN_REPLY_TO',
35 WITH_VIDEO = 'WITH_VIDEO', 36 WITH_VIDEO = 'WITH_VIDEO',
36 ATTRIBUTES_FOR_API = 'ATTRIBUTES_FOR_API' 37 ATTRIBUTES_FOR_API = 'ATTRIBUTES_FOR_API'
@@ -82,6 +83,22 @@ enum ScopeNames {
82 } 83 }
83 ] 84 ]
84 }, 85 },
86 [ScopeNames.WITH_ACCOUNT_FOR_API]: {
87 include: [
88 {
89 model: AccountModel.unscoped(),
90 include: [
91 {
92 attributes: {
93 exclude: unusedActorAttributesForAPI
94 },
95 model: ActorModel, // Default scope includes avatar and server
96 required: true
97 }
98 ]
99 }
100 ]
101 },
85 [ScopeNames.WITH_IN_REPLY_TO]: { 102 [ScopeNames.WITH_IN_REPLY_TO]: {
86 include: [ 103 include: [
87 { 104 {
@@ -275,18 +292,33 @@ export class VideoCommentModel extends Model<VideoCommentModel> {
275 limit: count, 292 limit: count,
276 order: getCommentSort(sort), 293 order: getCommentSort(sort),
277 where: { 294 where: {
278 videoId, 295 [Op.and]: [
279 inReplyToCommentId: null, 296 {
280 accountId: { 297 videoId
281 [Op.notIn]: Sequelize.literal( 298 },
282 '(' + buildBlockedAccountSQL(serverAccountId, userAccountId) + ')' 299 {
283 ) 300 inReplyToCommentId: null
284 } 301 },
302 {
303 [Op.or]: [
304 {
305 accountId: {
306 [Op.notIn]: Sequelize.literal(
307 '(' + buildBlockedAccountSQL(serverAccountId, userAccountId) + ')'
308 )
309 }
310 },
311 {
312 accountId: null
313 }
314 ]
315 }
316 ]
285 } 317 }
286 } 318 }
287 319
288 const scopes: (string | ScopeOptions)[] = [ 320 const scopes: (string | ScopeOptions)[] = [
289 ScopeNames.WITH_ACCOUNT, 321 ScopeNames.WITH_ACCOUNT_FOR_API,
290 { 322 {
291 method: [ ScopeNames.ATTRIBUTES_FOR_API, serverAccountId, userAccountId ] 323 method: [ ScopeNames.ATTRIBUTES_FOR_API, serverAccountId, userAccountId ]
292 } 324 }
@@ -328,7 +360,7 @@ export class VideoCommentModel extends Model<VideoCommentModel> {
328 } 360 }
329 361
330 const scopes: any[] = [ 362 const scopes: any[] = [
331 ScopeNames.WITH_ACCOUNT, 363 ScopeNames.WITH_ACCOUNT_FOR_API,
332 { 364 {
333 method: [ ScopeNames.ATTRIBUTES_FOR_API, serverAccountId, userAccountId ] 365 method: [ ScopeNames.ATTRIBUTES_FOR_API, serverAccountId, userAccountId ]
334 } 366 }