From 8c9e7875269a990ed3000e1d4995d808e4ff50f7 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 7 Apr 2020 15:27:41 +0200 Subject: Add ability to accept or not remote redundancies --- server/models/activitypub/actor-follow.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'server/models/activitypub') 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 { MActorFollowSubscriptions } from '@server/typings/models' import { ActivityPubActorType } from '@shared/models' +import { VideoModel } from '@server/models/video/video' @Table({ tableName: 'actorFollow', @@ -151,6 +152,18 @@ export class ActorFollowModel extends Model { if (numberOfActorFollowsRemoved) logger.info('Removed bad %d actor follows.', numberOfActorFollowsRemoved) } + static isFollowedBy (actorId: number, followerActorId: number) { + const query = 'SELECT 1 FROM "actorFollow" WHERE "actorId" = $followerActorId AND "targetActorId" = $actorId LIMIT 1' + const options = { + type: QueryTypes.SELECT as QueryTypes.SELECT, + bind: { actorId, followerActorId }, + raw: true + } + + return VideoModel.sequelize.query(query, options) + .then(results => results.length === 1) + } + static loadByActorAndTarget (actorId: number, targetActorId: number, t?: Transaction): Bluebird { const query = { where: { -- cgit v1.2.3