aboutsummaryrefslogtreecommitdiffhomepage
path: root/server
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-08-24 10:31:56 +0200
committerChocobozzz <me@florianbigard.com>2018-08-27 09:41:54 +0200
commitaa55a4da422330fe2816f1764b64f6607a0ca4aa (patch)
tree39933a835cc13a685696178e374fe3ac8ba9003b /server
parentf37dc0dd14d9ce0b59c454c2c1b935fcbe9727e9 (diff)
downloadPeerTube-aa55a4da422330fe2816f1764b64f6607a0ca4aa.tar.gz
PeerTube-aa55a4da422330fe2816f1764b64f6607a0ca4aa.tar.zst
PeerTube-aa55a4da422330fe2816f1764b64f6607a0ca4aa.zip
Infinite scroll to list our subscriptions
Diffstat (limited to 'server')
-rw-r--r--server/models/activitypub/actor-follow.ts10
-rw-r--r--server/models/activitypub/actor.ts42
2 files changed, 8 insertions, 44 deletions
diff --git a/server/models/activitypub/actor-follow.ts b/server/models/activitypub/actor-follow.ts
index 81fcf7001..ebb2d47c2 100644
--- a/server/models/activitypub/actor-follow.ts
+++ b/server/models/activitypub/actor-follow.ts
@@ -169,9 +169,6 @@ export class ActorFollowModel extends Model<ActorFollowModel> {
169 169
170 static loadByActorAndTargetNameAndHostForAPI (actorId: number, targetName: string, targetHost: string, t?: Sequelize.Transaction) { 170 static loadByActorAndTargetNameAndHostForAPI (actorId: number, targetName: string, targetHost: string, t?: Sequelize.Transaction) {
171 const actorFollowingPartInclude: IIncludeOptions = { 171 const actorFollowingPartInclude: IIncludeOptions = {
172 attributes: {
173 exclude: unusedActorAttributesForAPI
174 },
175 model: ActorModel, 172 model: ActorModel,
176 required: true, 173 required: true,
177 as: 'ActorFollowing', 174 as: 'ActorFollowing',
@@ -203,7 +200,12 @@ export class ActorFollowModel extends Model<ActorFollowModel> {
203 actorId 200 actorId
204 }, 201 },
205 include: [ 202 include: [
206 actorFollowingPartInclude 203 actorFollowingPartInclude,
204 {
205 model: ActorModel,
206 required: true,
207 as: 'ActorFollower'
208 }
207 ], 209 ],
208 transaction: t 210 transaction: t
209 } 211 }
diff --git a/server/models/activitypub/actor.ts b/server/models/activitypub/actor.ts
index ec0b4b2d9..e16bd5d79 100644
--- a/server/models/activitypub/actor.ts
+++ b/server/models/activitypub/actor.ts
@@ -49,7 +49,8 @@ export const unusedActorAttributesForAPI = [
49 'outboxUrl', 49 'outboxUrl',
50 'sharedInboxUrl', 50 'sharedInboxUrl',
51 'followersUrl', 51 'followersUrl',
52 'followingUrl' 52 'followingUrl',
53 'url'
53] 54]
54 55
55@DefaultScope({ 56@DefaultScope({
@@ -322,45 +323,6 @@ export class ActorModel extends Model<ActorModel> {
322 }) 323 })
323 } 324 }
324 325
325 static async getActorsFollowerSharedInboxUrls (actors: ActorModel[], t: Sequelize.Transaction) {
326 const query = {
327 // attribute: [],
328 where: {
329 id: {
330 [Sequelize.Op.in]: actors.map(a => a.id)
331 }
332 },
333 include: [
334 {
335 // attributes: [ ],
336 model: ActorFollowModel.unscoped(),
337 required: true,
338 as: 'ActorFollowers',
339 where: {
340 state: 'accepted'
341 },
342 include: [
343 {
344 attributes: [ 'sharedInboxUrl' ],
345 model: ActorModel.unscoped(),
346 as: 'ActorFollower',
347 required: true
348 }
349 ]
350 }
351 ],
352 transaction: t
353 }
354
355 const hash: { [ id: number ]: string[] } = {}
356 const res = await ActorModel.findAll(query)
357 for (const actor of res) {
358 hash[actor.id] = actor.ActorFollowers.map(follow => follow.ActorFollower.sharedInboxUrl)
359 }
360
361 return hash
362 }
363
364 toFormattedJSON () { 326 toFormattedJSON () {
365 let avatar: Avatar = null 327 let avatar: Avatar = null
366 if (this.Avatar) { 328 if (this.Avatar) {