import { throwIfNotValid } from '../utils'
import { VideoChannelModel } from '../video/video-channel'
import { ActorFollowModel } from './actor-follow'
+import { VideoModel } from '../video/video'
enum ScopeNames {
FULL = 'FULL'
return ActorModel.unscoped().findById(id)
}
+ static loadAccountActorByVideoId (videoId: number, transaction: Sequelize.Transaction) {
+ const query = {
+ include: [
+ {
+ attributes: [ 'id' ],
+ model: AccountModel.unscoped(),
+ required: true,
+ include: [
+ {
+ attributes: [ 'id' ],
+ model: VideoChannelModel.unscoped(),
+ required: true,
+ include: {
+ attributes: [ 'id' ],
+ model: VideoModel.unscoped(),
+ required: true,
+ where: {
+ id: videoId
+ }
+ }
+ }
+ ]
+ }
+ ],
+ transaction
+ }
+
+ return ActorModel.unscoped().findOne(query as any) // FIXME: typings
+ }
+
static isActorUrlExist (url: string) {
const query = {
raw: true,
}
static loadByUrl (url: string, transaction?: Sequelize.Transaction) {
+ const query = {
+ where: {
+ url
+ },
+ transaction,
+ include: [
+ {
+ attributes: [ 'id' ],
+ model: AccountModel.unscoped(),
+ required: false
+ },
+ {
+ attributes: [ 'id' ],
+ model: VideoChannelModel.unscoped(),
+ required: false
+ }
+ ]
+ }
+
+ return ActorModel.unscoped().findOne(query)
+ }
+
+ static loadByUrlAndPopulateAccountAndChannel (url: string, transaction?: Sequelize.Transaction) {
const query = {
where: {
url