import { AttributesOnly } from '@shared/typescript-utils'
import { isActivityPubUrlValid } from '../../helpers/custom-validators/activitypub/misc'
import { CONSTRAINTS_FIELDS } from '../../initializers/constants'
-import { MActorDefault } from '../../types/models'
+import { MActorDefault, MActorFollowersUrl, MActorId } from '../../types/models'
import { MVideoShareActor, MVideoShareFull } from '../../types/models/video'
import { ActorModel } from '../actor/actor'
import { buildLocalActorIdsIn, throwIfNotValid } from '../utils'
})
}
- static loadActorsByShare (videoId: number, t: Transaction): Promise<MActorDefault[]> {
- const query = {
- where: {
- videoId
- },
- include: [
- {
- model: ActorModel,
- required: true
- }
- ],
+ static listActorIdsAndFollowerUrlsByShare (videoId: number, t: Transaction) {
+ const query = `SELECT "actor"."id" AS "id", "actor"."followersUrl" AS "followersUrl" ` +
+ `FROM "videoShare" ` +
+ `INNER JOIN "actor" ON "actor"."id" = "videoShare"."actorId" ` +
+ `WHERE "videoShare"."videoId" = :videoId`
+
+ const options = {
+ type: QueryTypes.SELECT as QueryTypes.SELECT,
+ replacements: { videoId },
transaction: t
}
- return VideoShareModel.scope(ScopeNames.FULL).findAll(query)
- .then((res: MVideoShareFull[]) => res.map(r => r.Actor))
+ return VideoShareModel.sequelize.query<MActorId & MActorFollowersUrl>(query, options)
}
static loadActorsWhoSharedVideosOf (actorOwnerId: number, t: Transaction): Promise<MActorDefault[]> {