Fix sharedInboxUrl list
This commit is contained in:
parent
ca309a9f64
commit
759f8a29e9
1 changed files with 19 additions and 10 deletions
|
@ -191,12 +191,13 @@ export class ActorFollowModel extends Model<ActorFollowModel> {
|
||||||
|
|
||||||
static listAcceptedFollowerSharedInboxUrls (actorIds: number[], t: Sequelize.Transaction) {
|
static listAcceptedFollowerSharedInboxUrls (actorIds: number[], t: Sequelize.Transaction) {
|
||||||
return ActorFollowModel.createListAcceptedFollowForApiQuery(
|
return ActorFollowModel.createListAcceptedFollowForApiQuery(
|
||||||
'DISTINCT(followers)',
|
'followers',
|
||||||
actorIds,
|
actorIds,
|
||||||
t,
|
t,
|
||||||
undefined,
|
undefined,
|
||||||
undefined,
|
undefined,
|
||||||
'sharedInboxUrl'
|
'sharedInboxUrl',
|
||||||
|
true
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -204,12 +205,15 @@ export class ActorFollowModel extends Model<ActorFollowModel> {
|
||||||
return ActorFollowModel.createListAcceptedFollowForApiQuery('following', actorIds, t, start, count)
|
return ActorFollowModel.createListAcceptedFollowForApiQuery('following', actorIds, t, start, count)
|
||||||
}
|
}
|
||||||
|
|
||||||
private static async createListAcceptedFollowForApiQuery (type: 'followers' | 'following' | 'DISTINCT(followers)',
|
private static async createListAcceptedFollowForApiQuery (
|
||||||
|
type: 'followers' | 'following',
|
||||||
actorIds: number[],
|
actorIds: number[],
|
||||||
t: Sequelize.Transaction,
|
t: Sequelize.Transaction,
|
||||||
start?: number,
|
start?: number,
|
||||||
count?: number,
|
count?: number,
|
||||||
columnUrl = 'url') {
|
columnUrl = 'url',
|
||||||
|
distinct = false
|
||||||
|
) {
|
||||||
let firstJoin: string
|
let firstJoin: string
|
||||||
let secondJoin: string
|
let secondJoin: string
|
||||||
|
|
||||||
|
@ -221,10 +225,15 @@ export class ActorFollowModel extends Model<ActorFollowModel> {
|
||||||
secondJoin = 'targetActorId'
|
secondJoin = 'targetActorId'
|
||||||
}
|
}
|
||||||
|
|
||||||
const selections = [ '"Follows"."' + columnUrl + '" AS "url"', 'COUNT(*) AS "total"' ]
|
const selections: string[] = []
|
||||||
|
if (distinct === true) selections.push('DISTINCT("Follows"."' + columnUrl + '") AS "url"')
|
||||||
|
else selections.push('"Follows"."' + columnUrl + '" AS "url"')
|
||||||
|
|
||||||
|
selections.push('COUNT(*) AS "total"')
|
||||||
|
|
||||||
const tasks: Bluebird<any>[] = []
|
const tasks: Bluebird<any>[] = []
|
||||||
|
|
||||||
for (const selection of selections) {
|
for (let selection of selections) {
|
||||||
let query = 'SELECT ' + selection + ' FROM "actor" ' +
|
let query = 'SELECT ' + selection + ' FROM "actor" ' +
|
||||||
'INNER JOIN "actorFollow" ON "actorFollow"."' + firstJoin + '" = "actor"."id" ' +
|
'INNER JOIN "actorFollow" ON "actorFollow"."' + firstJoin + '" = "actor"."id" ' +
|
||||||
'INNER JOIN "actor" AS "Follows" ON "actorFollow"."' + secondJoin + '" = "Follows"."id" ' +
|
'INNER JOIN "actor" AS "Follows" ON "actorFollow"."' + secondJoin + '" = "Follows"."id" ' +
|
||||||
|
|
Loading…
Reference in a new issue