diff options
Diffstat (limited to 'server/models/activitypub')
-rw-r--r-- | server/models/activitypub/actor-follow.ts | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/server/models/activitypub/actor-follow.ts b/server/models/activitypub/actor-follow.ts index 27643704e..5a8e450a5 100644 --- a/server/models/activitypub/actor-follow.ts +++ b/server/models/activitypub/actor-follow.ts | |||
@@ -36,6 +36,7 @@ import { | |||
36 | MActorFollowSubscriptions | 36 | MActorFollowSubscriptions |
37 | } from '@server/typings/models' | 37 | } from '@server/typings/models' |
38 | import { ActivityPubActorType } from '@shared/models' | 38 | import { ActivityPubActorType } from '@shared/models' |
39 | import { VideoModel } from '@server/models/video/video' | ||
39 | 40 | ||
40 | @Table({ | 41 | @Table({ |
41 | tableName: 'actorFollow', | 42 | tableName: 'actorFollow', |
@@ -151,6 +152,18 @@ export class ActorFollowModel extends Model<ActorFollowModel> { | |||
151 | if (numberOfActorFollowsRemoved) logger.info('Removed bad %d actor follows.', numberOfActorFollowsRemoved) | 152 | if (numberOfActorFollowsRemoved) logger.info('Removed bad %d actor follows.', numberOfActorFollowsRemoved) |
152 | } | 153 | } |
153 | 154 | ||
155 | static isFollowedBy (actorId: number, followerActorId: number) { | ||
156 | const query = 'SELECT 1 FROM "actorFollow" WHERE "actorId" = $followerActorId AND "targetActorId" = $actorId LIMIT 1' | ||
157 | const options = { | ||
158 | type: QueryTypes.SELECT as QueryTypes.SELECT, | ||
159 | bind: { actorId, followerActorId }, | ||
160 | raw: true | ||
161 | } | ||
162 | |||
163 | return VideoModel.sequelize.query(query, options) | ||
164 | .then(results => results.length === 1) | ||
165 | } | ||
166 | |||
154 | static loadByActorAndTarget (actorId: number, targetActorId: number, t?: Transaction): Bluebird<MActorFollowActorsDefault> { | 167 | static loadByActorAndTarget (actorId: number, targetActorId: number, t?: Transaction): Bluebird<MActorFollowActorsDefault> { |
155 | const query = { | 168 | const query = { |
156 | where: { | 169 | where: { |