diff options
author | Chocobozzz <me@florianbigard.com> | 2022-06-17 14:17:06 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2022-06-17 14:17:06 +0200 |
commit | fba911e2c89708a166636e3a93fcd8fcbc3de7e1 (patch) | |
tree | 8ad1e9c9abf3b021e343ed35618aa5d606fe03e5 /server/models/video | |
parent | e69d1ed5cd4cc2b40914af98ffd8d54dff04cc9e (diff) | |
parent | f27b7a750f1876632e84d594608d3d64ce974efc (diff) | |
download | PeerTube-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.ts | 25 |
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 | |||
3 | import { AttributesOnly } from '@shared/typescript-utils' | 3 | import { AttributesOnly } from '@shared/typescript-utils' |
4 | import { isActivityPubUrlValid } from '../../helpers/custom-validators/activitypub/misc' | 4 | import { isActivityPubUrlValid } from '../../helpers/custom-validators/activitypub/misc' |
5 | import { CONSTRAINTS_FIELDS } from '../../initializers/constants' | 5 | import { CONSTRAINTS_FIELDS } from '../../initializers/constants' |
6 | import { MActorDefault } from '../../types/models' | 6 | import { MActorDefault, MActorFollowersUrl, MActorId } from '../../types/models' |
7 | import { MVideoShareActor, MVideoShareFull } from '../../types/models/video' | 7 | import { MVideoShareActor, MVideoShareFull } from '../../types/models/video' |
8 | import { ActorModel } from '../actor/actor' | 8 | import { ActorModel } from '../actor/actor' |
9 | import { buildLocalActorIdsIn, throwIfNotValid } from '../utils' | 9 | import { 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[]> { |