aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models/video
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2022-06-17 14:17:06 +0200
committerChocobozzz <me@florianbigard.com>2022-06-17 14:17:06 +0200
commitfba911e2c89708a166636e3a93fcd8fcbc3de7e1 (patch)
tree8ad1e9c9abf3b021e343ed35618aa5d606fe03e5 /server/models/video
parente69d1ed5cd4cc2b40914af98ffd8d54dff04cc9e (diff)
parentf27b7a750f1876632e84d594608d3d64ce974efc (diff)
downloadPeerTube-fba911e2c89708a166636e3a93fcd8fcbc3de7e1.tar.gz
PeerTube-fba911e2c89708a166636e3a93fcd8fcbc3de7e1.tar.zst
PeerTube-fba911e2c89708a166636e3a93fcd8fcbc3de7e1.zip
Merge branch 'release/4.2.0' into develop
Diffstat (limited to 'server/models/video')
-rw-r--r--server/models/video/video-share.ts25
1 files changed, 11 insertions, 14 deletions
diff --git a/server/models/video/video-share.ts b/server/models/video/video-share.ts
index ad95dec6e..ca63bb2d9 100644
--- a/server/models/video/video-share.ts
+++ b/server/models/video/video-share.ts
@@ -3,7 +3,7 @@ import { AllowNull, BelongsTo, Column, CreatedAt, DataType, ForeignKey, Is, Mode
3import { AttributesOnly } from '@shared/typescript-utils' 3import { AttributesOnly } from '@shared/typescript-utils'
4import { isActivityPubUrlValid } from '../../helpers/custom-validators/activitypub/misc' 4import { isActivityPubUrlValid } from '../../helpers/custom-validators/activitypub/misc'
5import { CONSTRAINTS_FIELDS } from '../../initializers/constants' 5import { CONSTRAINTS_FIELDS } from '../../initializers/constants'
6import { MActorDefault } from '../../types/models' 6import { MActorDefault, MActorFollowersUrl, MActorId } from '../../types/models'
7import { MVideoShareActor, MVideoShareFull } from '../../types/models/video' 7import { MVideoShareActor, MVideoShareFull } from '../../types/models/video'
8import { ActorModel } from '../actor/actor' 8import { ActorModel } from '../actor/actor'
9import { buildLocalActorIdsIn, throwIfNotValid } from '../utils' 9import { buildLocalActorIdsIn, throwIfNotValid } from '../utils'
@@ -107,22 +107,19 @@ export class VideoShareModel extends Model<Partial<AttributesOnly<VideoShareMode
107 }) 107 })
108 } 108 }
109 109
110 static loadActorsByShare (videoId: number, t: Transaction): Promise<MActorDefault[]> { 110 static listActorIdsAndFollowerUrlsByShare (videoId: number, t: Transaction) {
111 const query = { 111 const query = `SELECT "actor"."id" AS "id", "actor"."followersUrl" AS "followersUrl" ` +
112 where: { 112 `FROM "videoShare" ` +
113 videoId 113 `INNER JOIN "actor" ON "actor"."id" = "videoShare"."actorId" ` +
114 }, 114 `WHERE "videoShare"."videoId" = :videoId`
115 include: [ 115
116 { 116 const options = {
117 model: ActorModel, 117 type: QueryTypes.SELECT as QueryTypes.SELECT,
118 required: true 118 replacements: { videoId },
119 }
120 ],
121 transaction: t 119 transaction: t
122 } 120 }
123 121
124 return VideoShareModel.scope(ScopeNames.FULL).findAll(query) 122 return VideoShareModel.sequelize.query<MActorId & MActorFollowersUrl>(query, options)
125 .then((res: MVideoShareFull[]) => res.map(r => r.Actor))
126 } 123 }
127 124
128 static loadActorsWhoSharedVideosOf (actorOwnerId: number, t: Transaction): Promise<MActorDefault[]> { 125 static loadActorsWhoSharedVideosOf (actorOwnerId: number, t: Transaction): Promise<MActorDefault[]> {