aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-01-09 18:13:00 +0100
committerChocobozzz <me@florianbigard.com>2018-01-09 18:13:00 +0100
commit759f8a29e95932023564ca98dcbc90d1acb92da0 (patch)
treef642c19706eaf22c39886e45ee83ac8046337c67
parentca309a9f6492f340295fee010ffa6dcc63fd76b4 (diff)
downloadPeerTube-759f8a29e95932023564ca98dcbc90d1acb92da0.tar.gz
PeerTube-759f8a29e95932023564ca98dcbc90d1acb92da0.tar.zst
PeerTube-759f8a29e95932023564ca98dcbc90d1acb92da0.zip
Fix sharedInboxUrl list
-rw-r--r--server/models/activitypub/actor-follow.ts29
1 files changed, 19 insertions, 10 deletions
diff --git a/server/models/activitypub/actor-follow.ts b/server/models/activitypub/actor-follow.ts
index c35c712ed..5fcc3449d 100644
--- a/server/models/activitypub/actor-follow.ts
+++ b/server/models/activitypub/actor-follow.ts
@@ -191,12 +191,13 @@ export class ActorFollowModel extends Model<ActorFollowModel> {
191 191
192 static listAcceptedFollowerSharedInboxUrls (actorIds: number[], t: Sequelize.Transaction) { 192 static listAcceptedFollowerSharedInboxUrls (actorIds: number[], t: Sequelize.Transaction) {
193 return ActorFollowModel.createListAcceptedFollowForApiQuery( 193 return ActorFollowModel.createListAcceptedFollowForApiQuery(
194 'DISTINCT(followers)', 194 'followers',
195 actorIds, 195 actorIds,
196 t, 196 t,
197 undefined, 197 undefined,
198 undefined, 198 undefined,
199 'sharedInboxUrl' 199 'sharedInboxUrl',
200 true
200 ) 201 )
201 } 202 }
202 203
@@ -204,12 +205,15 @@ export class ActorFollowModel extends Model<ActorFollowModel> {
204 return ActorFollowModel.createListAcceptedFollowForApiQuery('following', actorIds, t, start, count) 205 return ActorFollowModel.createListAcceptedFollowForApiQuery('following', actorIds, t, start, count)
205 } 206 }
206 207
207 private static async createListAcceptedFollowForApiQuery (type: 'followers' | 'following' | 'DISTINCT(followers)', 208 private static async createListAcceptedFollowForApiQuery (
208 actorIds: number[], 209 type: 'followers' | 'following',
209 t: Sequelize.Transaction, 210 actorIds: number[],
210 start?: number, 211 t: Sequelize.Transaction,
211 count?: number, 212 start?: number,
212 columnUrl = 'url') { 213 count?: number,
214 columnUrl = 'url',
215 distinct = false
216 ) {
213 let firstJoin: string 217 let firstJoin: string
214 let secondJoin: string 218 let secondJoin: string
215 219
@@ -221,10 +225,15 @@ export class ActorFollowModel extends Model<ActorFollowModel> {
221 secondJoin = 'targetActorId' 225 secondJoin = 'targetActorId'
222 } 226 }
223 227
224 const selections = [ '"Follows"."' + columnUrl + '" AS "url"', 'COUNT(*) AS "total"' ] 228 const selections: string[] = []
229 if (distinct === true) selections.push('DISTINCT("Follows"."' + columnUrl + '") AS "url"')
230 else selections.push('"Follows"."' + columnUrl + '" AS "url"')
231
232 selections.push('COUNT(*) AS "total"')
233
225 const tasks: Bluebird<any>[] = [] 234 const tasks: Bluebird<any>[] = []
226 235
227 for (const selection of selections) { 236 for (let selection of selections) {
228 let query = 'SELECT ' + selection + ' FROM "actor" ' + 237 let query = 'SELECT ' + selection + ' FROM "actor" ' +
229 'INNER JOIN "actorFollow" ON "actorFollow"."' + firstJoin + '" = "actor"."id" ' + 238 'INNER JOIN "actorFollow" ON "actorFollow"."' + firstJoin + '" = "actor"."id" ' +
230 'INNER JOIN "actor" AS "Follows" ON "actorFollow"."' + secondJoin + '" = "Follows"."id" ' + 239 'INNER JOIN "actor" AS "Follows" ON "actorFollow"."' + secondJoin + '" = "Follows"."id" ' +