From aa55a4da422330fe2816f1764b64f6607a0ca4aa Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 24 Aug 2018 10:31:56 +0200 Subject: Infinite scroll to list our subscriptions --- server/models/activitypub/actor-follow.ts | 10 +++++--- server/models/activitypub/actor.ts | 42 ++----------------------------- 2 files changed, 8 insertions(+), 44 deletions(-) (limited to 'server') 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 { static loadByActorAndTargetNameAndHostForAPI (actorId: number, targetName: string, targetHost: string, t?: Sequelize.Transaction) { const actorFollowingPartInclude: IIncludeOptions = { - attributes: { - exclude: unusedActorAttributesForAPI - }, model: ActorModel, required: true, as: 'ActorFollowing', @@ -203,7 +200,12 @@ export class ActorFollowModel extends Model { actorId }, include: [ - actorFollowingPartInclude + actorFollowingPartInclude, + { + model: ActorModel, + required: true, + as: 'ActorFollower' + } ], transaction: t } 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 = [ 'outboxUrl', 'sharedInboxUrl', 'followersUrl', - 'followingUrl' + 'followingUrl', + 'url' ] @DefaultScope({ @@ -322,45 +323,6 @@ export class ActorModel extends Model { }) } - static async getActorsFollowerSharedInboxUrls (actors: ActorModel[], t: Sequelize.Transaction) { - const query = { - // attribute: [], - where: { - id: { - [Sequelize.Op.in]: actors.map(a => a.id) - } - }, - include: [ - { - // attributes: [ ], - model: ActorFollowModel.unscoped(), - required: true, - as: 'ActorFollowers', - where: { - state: 'accepted' - }, - include: [ - { - attributes: [ 'sharedInboxUrl' ], - model: ActorModel.unscoped(), - as: 'ActorFollower', - required: true - } - ] - } - ], - transaction: t - } - - const hash: { [ id: number ]: string[] } = {} - const res = await ActorModel.findAll(query) - for (const actor of res) { - hash[actor.id] = actor.ActorFollowers.map(follow => follow.ActorFollower.sharedInboxUrl) - } - - return hash - } - toFormattedJSON () { let avatar: Avatar = null if (this.Avatar) { -- cgit v1.2.3