import { ActorModel, unusedActorAttributesForAPI } from './actor'
import { VideoChannelModel } from '../video/video-channel'
import { AccountModel } from '../account/account'
-import { IncludeOptions, Op, Transaction, QueryTypes } from 'sequelize'
+import { IncludeOptions, Op, QueryTypes, Transaction } from 'sequelize'
+import {
+ MActorFollowActorsDefault,
+ MActorFollowActorsDefaultSubscription,
+ MActorFollowFollowingHost,
+ MActorFollowFormattable,
+ MActorFollowSubscriptions
+} from '@server/typings/models'
@Table({
tableName: 'actorFollow',
if (numberOfActorFollowsRemoved) logger.info('Removed bad %d actor follows.', numberOfActorFollowsRemoved)
}
- static loadByActorAndTarget (actorId: number, targetActorId: number, t?: Transaction) {
+ static loadByActorAndTarget (actorId: number, targetActorId: number, t?: Transaction): Bluebird<MActorFollowActorsDefault> {
const query = {
where: {
actorId,
return ActorFollowModel.findOne(query)
}
- static loadByActorAndTargetNameAndHostForAPI (actorId: number, targetName: string, targetHost: string, t?: Transaction) {
+ static loadByActorAndTargetNameAndHostForAPI (
+ actorId: number,
+ targetName: string,
+ targetHost: string,
+ t?: Transaction
+ ): Bluebird<MActorFollowActorsDefaultSubscription> {
const actorFollowingPartInclude: IncludeOptions = {
model: ActorModel,
required: true,
})
}
- static listSubscribedIn (actorId: number, targets: { name: string, host?: string }[]) {
+ static listSubscribedIn (actorId: number, targets: { name: string, host?: string }[]): Bluebird<MActorFollowFollowingHost[]> {
const whereTab = targets
.map(t => {
if (t.host) {
]
}
- return ActorFollowModel.findAndCountAll(query)
+ return ActorFollowModel.findAndCountAll<MActorFollowActorsDefault>(query)
.then(({ rows, count }) => {
return {
data: rows,
]
}
- return ActorFollowModel.findAndCountAll(query)
+ return ActorFollowModel.findAndCountAll<MActorFollowActorsDefault>(query)
.then(({ rows, count }) => {
return {
data: rows,
]
}
- return ActorFollowModel.findAndCountAll(query)
+ return ActorFollowModel.findAndCountAll<MActorFollowSubscriptions>(query)
.then(({ rows, count }) => {
return {
data: rows.map(r => r.ActorFollowing.VideoChannel),
return ActorFollowModel.findAll(query)
}
- toFormattedJSON (): ActorFollow {
+ toFormattedJSON (this: MActorFollowFormattable): ActorFollow {
const follower = this.ActorFollower.toFormattedJSON()
const following = this.ActorFollowing.toFormattedJSON()