diff options
author | Chocobozzz <me@florianbigard.com> | 2020-04-07 15:27:41 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2020-04-07 15:32:20 +0200 |
commit | 8c9e7875269a990ed3000e1d4995d808e4ff50f7 (patch) | |
tree | 896f60aedf0fac0dc64b57ff76a63e7a718c0a5b /server/models/activitypub | |
parent | bc30363602ad504d784662a9373c0a114d05042c (diff) | |
download | PeerTube-8c9e7875269a990ed3000e1d4995d808e4ff50f7.tar.gz PeerTube-8c9e7875269a990ed3000e1d4995d808e4ff50f7.tar.zst PeerTube-8c9e7875269a990ed3000e1d4995d808e4ff50f7.zip |
Add ability to accept or not remote redundancies
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: { |