aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-01-12 10:02:11 +0100
committerChocobozzz <me@florianbigard.com>2018-01-12 10:02:11 +0100
commit6502c3d43e512e968ad49f5a3bc9abc302471e18 (patch)
tree32f7a95080a7fa17198dc2556226dea5eb4c93b8 /server/models
parent9a8cbd8278a37ee414f17d7de7c7281123484ba1 (diff)
downloadPeerTube-6502c3d43e512e968ad49f5a3bc9abc302471e18.tar.gz
PeerTube-6502c3d43e512e968ad49f5a3bc9abc302471e18.tar.zst
PeerTube-6502c3d43e512e968ad49f5a3bc9abc302471e18.zip
Avoid making retried requests to dead followers
Diffstat (limited to 'server/models')
-rw-r--r--server/models/activitypub/actor-follow.ts28
-rw-r--r--server/models/activitypub/actor.ts3
2 files changed, 31 insertions, 0 deletions
diff --git a/server/models/activitypub/actor-follow.ts b/server/models/activitypub/actor-follow.ts
index 920c83d88..de5bb6f74 100644
--- a/server/models/activitypub/actor-follow.ts
+++ b/server/models/activitypub/actor-follow.ts
@@ -163,6 +163,34 @@ export class ActorFollowModel extends Model<ActorFollowModel> {
163 return ActorFollowModel.findOne(query) 163 return ActorFollowModel.findOne(query)
164 } 164 }
165 165
166 static loadByFollowerInbox (url: string, t?: Sequelize.Transaction) {
167 const query = {
168 where: {
169 state: 'accepted'
170 },
171 include: [
172 {
173 model: ActorModel,
174 required: true,
175 as: 'ActorFollower',
176 where: {
177 [Sequelize.Op.or]: [
178 {
179 inboxUrl: url
180 },
181 {
182 sharedInboxUrl: url
183 }
184 ]
185 }
186 }
187 ],
188 transaction: t
189 } as any // FIXME: typings does not work
190
191 return ActorFollowModel.findOne(query)
192 }
193
166 static listFollowingForApi (id: number, start: number, count: number, sort: string) { 194 static listFollowingForApi (id: number, start: number, count: number, sort: string) {
167 const query = { 195 const query = {
168 distinct: true, 196 distinct: true,
diff --git a/server/models/activitypub/actor.ts b/server/models/activitypub/actor.ts
index 6c74aa61b..17f69f7a7 100644
--- a/server/models/activitypub/actor.ts
+++ b/server/models/activitypub/actor.ts
@@ -68,6 +68,9 @@ enum ScopeNames {
68 { 68 {
69 fields: [ 'preferredUsername', 'serverId' ], 69 fields: [ 'preferredUsername', 'serverId' ],
70 unique: true 70 unique: true
71 },
72 {
73 fields: [ 'inboxUrl', 'sharedInboxUrl' ]
71 } 74 }
72 ] 75 ]
73}) 76})