aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models/video/video.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-01-04 11:19:16 +0100
committerChocobozzz <me@florianbigard.com>2018-01-04 11:19:16 +0100
commit4cb6d4578893db310297d7e118ce2fb7ecb952a3 (patch)
treea89a2e2062ba7bb91e922f07a7950ee51e090ccf /server/models/video/video.ts
parentcf117aaafc1e9ae1ab4c388fc5d2e5ba9349efee (diff)
downloadPeerTube-4cb6d4578893db310297d7e118ce2fb7ecb952a3.tar.gz
PeerTube-4cb6d4578893db310297d7e118ce2fb7ecb952a3.tar.zst
PeerTube-4cb6d4578893db310297d7e118ce2fb7ecb952a3.zip
Add ability to delete comments
Diffstat (limited to 'server/models/video/video.ts')
-rw-r--r--server/models/video/video.ts46
1 files changed, 39 insertions, 7 deletions
diff --git a/server/models/video/video.ts b/server/models/video/video.ts
index c4b716cd2..4d15c2a50 100644
--- a/server/models/video/video.ts
+++ b/server/models/video/video.ts
@@ -43,7 +43,8 @@ import { VideoTagModel } from './video-tag'
43 43
44enum ScopeNames { 44enum ScopeNames {
45 AVAILABLE_FOR_LIST = 'AVAILABLE_FOR_LIST', 45 AVAILABLE_FOR_LIST = 'AVAILABLE_FOR_LIST',
46 WITH_ACCOUNT = 'WITH_ACCOUNT', 46 WITH_ACCOUNT_API = 'WITH_ACCOUNT_API',
47 WITH_ACCOUNT_DETAILS = 'WITH_ACCOUNT_DETAILS',
47 WITH_TAGS = 'WITH_TAGS', 48 WITH_TAGS = 'WITH_TAGS',
48 WITH_FILES = 'WITH_FILES', 49 WITH_FILES = 'WITH_FILES',
49 WITH_SHARES = 'WITH_SHARES', 50 WITH_SHARES = 'WITH_SHARES',
@@ -62,7 +63,35 @@ enum ScopeNames {
62 privacy: VideoPrivacy.PUBLIC 63 privacy: VideoPrivacy.PUBLIC
63 } 64 }
64 }, 65 },
65 [ScopeNames.WITH_ACCOUNT]: { 66 [ScopeNames.WITH_ACCOUNT_API]: {
67 include: [
68 {
69 model: () => VideoChannelModel.unscoped(),
70 required: true,
71 include: [
72 {
73 attributes: [ 'name' ],
74 model: () => AccountModel.unscoped(),
75 required: true,
76 include: [
77 {
78 attributes: [ 'serverId' ],
79 model: () => ActorModel.unscoped(),
80 required: true,
81 include: [
82 {
83 model: () => ServerModel.unscoped(),
84 required: false
85 }
86 ]
87 }
88 ]
89 }
90 ]
91 }
92 ]
93 },
94 [ScopeNames.WITH_ACCOUNT_DETAILS]: {
66 include: [ 95 include: [
67 { 96 {
68 model: () => VideoChannelModel, 97 model: () => VideoChannelModel,
@@ -146,6 +175,9 @@ enum ScopeNames {
146 }, 175 },
147 { 176 {
148 fields: [ 'channelId' ] 177 fields: [ 'channelId' ]
178 },
179 {
180 fields: [ 'id', 'privacy' ]
149 } 181 }
150 ] 182 ]
151}) 183})
@@ -461,7 +493,7 @@ export class VideoModel extends Model<VideoModel> {
461 order: [ getSort(sort) ] 493 order: [ getSort(sort) ]
462 } 494 }
463 495
464 return VideoModel.scope([ ScopeNames.AVAILABLE_FOR_LIST, ScopeNames.WITH_ACCOUNT ]) 496 return VideoModel.scope([ ScopeNames.AVAILABLE_FOR_LIST, ScopeNames.WITH_ACCOUNT_API ])
465 .findAndCountAll(query) 497 .findAndCountAll(query)
466 .then(({ rows, count }) => { 498 .then(({ rows, count }) => {
467 return { 499 return {
@@ -496,7 +528,7 @@ export class VideoModel extends Model<VideoModel> {
496 528
497 if (t !== undefined) query.transaction = t 529 if (t !== undefined) query.transaction = t
498 530
499 return VideoModel.scope([ ScopeNames.WITH_ACCOUNT, ScopeNames.WITH_FILES ]).findOne(query) 531 return VideoModel.scope([ ScopeNames.WITH_ACCOUNT_DETAILS, ScopeNames.WITH_FILES ]).findOne(query)
500 } 532 }
501 533
502 static loadByUUIDOrURL (uuid: string, url: string, t?: Sequelize.Transaction) { 534 static loadByUUIDOrURL (uuid: string, url: string, t?: Sequelize.Transaction) {
@@ -520,7 +552,7 @@ export class VideoModel extends Model<VideoModel> {
520 } 552 }
521 553
522 return VideoModel 554 return VideoModel
523 .scope([ ScopeNames.WITH_TAGS, ScopeNames.WITH_FILES, ScopeNames.WITH_ACCOUNT ]) 555 .scope([ ScopeNames.WITH_TAGS, ScopeNames.WITH_FILES, ScopeNames.WITH_ACCOUNT_DETAILS ])
524 .findById(id, options) 556 .findById(id, options)
525 } 557 }
526 558
@@ -545,7 +577,7 @@ export class VideoModel extends Model<VideoModel> {
545 } 577 }
546 578
547 return VideoModel 579 return VideoModel
548 .scope([ ScopeNames.WITH_TAGS, ScopeNames.WITH_FILES, ScopeNames.WITH_ACCOUNT ]) 580 .scope([ ScopeNames.WITH_TAGS, ScopeNames.WITH_FILES, ScopeNames.WITH_ACCOUNT_DETAILS ])
549 .findOne(options) 581 .findOne(options)
550 } 582 }
551 583
@@ -563,7 +595,7 @@ export class VideoModel extends Model<VideoModel> {
563 ScopeNames.WITH_SHARES, 595 ScopeNames.WITH_SHARES,
564 ScopeNames.WITH_TAGS, 596 ScopeNames.WITH_TAGS,
565 ScopeNames.WITH_FILES, 597 ScopeNames.WITH_FILES,
566 ScopeNames.WITH_ACCOUNT, 598 ScopeNames.WITH_ACCOUNT_DETAILS,
567 ScopeNames.WITH_COMMENTS 599 ScopeNames.WITH_COMMENTS
568 ]) 600 ])
569 .findOne(options) 601 .findOne(options)