X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Fmodels%2Factor%2Factor-follow.ts;h=127b29ad7edaf3d46e42d75565f9244e0aac499e;hb=e3d6c6434f570f77c0532f86c82f78bcafb399ec;hp=af1d85e9f8befbb44573edd2a8076452c898d83f;hpb=bae616273d455d225d131eb17c56db6c20a0b6b3;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/models/actor/actor-follow.ts b/server/models/actor/actor-follow.ts index af1d85e9f..127b29ad7 100644 --- a/server/models/actor/actor-follow.ts +++ b/server/models/actor/actor-follow.ts @@ -1,5 +1,5 @@ import { difference, values } from 'lodash' -import { Includeable, IncludeOptions, Op, QueryTypes, Transaction } from 'sequelize' +import { Attributes, FindOptions, Includeable, IncludeOptions, Op, QueryTypes, Transaction, WhereAttributeHash } from 'sequelize' import { AfterCreate, AfterDestroy, @@ -209,7 +209,9 @@ export class ActorFollowModel extends Model { + static loadByActorAndTargetNameAndHostForAPI (options: { + actorId: number + targetName: string + targetHost: string + state?: FollowState + transaction?: Transaction + }): Promise { + const { actorId, targetHost, targetName, state, transaction } = options + const actorFollowingPartInclude: IncludeOptions = { model: ActorModel, required: true, @@ -271,10 +276,11 @@ export class ActorFollowModel extends Model> = { actorId } + if (state) where.state = state + + const query: FindOptions> = { + where, include: [ actorFollowingPartInclude, { @@ -283,7 +289,7 @@ export class ActorFollowModel extends Model