diff options
author | Rigel Kent <sendmemail@rigelk.eu> | 2018-07-25 22:01:25 +0200 |
---|---|---|
committer | Rigel Kent <sendmemail@rigelk.eu> | 2018-07-25 22:01:25 +0200 |
commit | c1e791bad0b079af67398f6407221e6dcbb573dd (patch) | |
tree | 82e5944b4458dd35aa482a38f6b650eb93bb89ad /server/models/activitypub | |
parent | 5f7021c33d31c5255b995ae0ff86b5bbea4ea4b9 (diff) | |
download | PeerTube-c1e791bad0b079af67398f6407221e6dcbb573dd.tar.gz PeerTube-c1e791bad0b079af67398f6407221e6dcbb573dd.tar.zst PeerTube-c1e791bad0b079af67398f6407221e6dcbb573dd.zip |
expliciting type checks and predicates (server only)
Diffstat (limited to 'server/models/activitypub')
-rw-r--r-- | server/models/activitypub/actor-follow.ts | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/server/models/activitypub/actor-follow.ts b/server/models/activitypub/actor-follow.ts index b8ce6de1d..adec5e92b 100644 --- a/server/models/activitypub/actor-follow.ts +++ b/server/models/activitypub/actor-follow.ts | |||
@@ -111,7 +111,7 @@ export class ActorFollowModel extends Model<ActorFollowModel> { | |||
111 | if (numberOfActorFollowsRemoved) logger.info('Removed bad %d actor follows.', numberOfActorFollowsRemoved) | 111 | if (numberOfActorFollowsRemoved) logger.info('Removed bad %d actor follows.', numberOfActorFollowsRemoved) |
112 | } | 112 | } |
113 | 113 | ||
114 | static updateActorFollowsScore (goodInboxes: string[], badInboxes: string[], t: Sequelize.Transaction) { | 114 | static updateActorFollowsScore (goodInboxes: string[], badInboxes: string[], t: Sequelize.Transaction | undefined) { |
115 | if (goodInboxes.length === 0 && badInboxes.length === 0) return | 115 | if (goodInboxes.length === 0 && badInboxes.length === 0) return |
116 | 116 | ||
117 | logger.info('Updating %d good actor follows and %d bad actor follows scores.', goodInboxes.length, badInboxes.length) | 117 | logger.info('Updating %d good actor follows and %d bad actor follows scores.', goodInboxes.length, badInboxes.length) |
@@ -344,7 +344,7 @@ export class ActorFollowModel extends Model<ActorFollowModel> { | |||
344 | } | 344 | } |
345 | } | 345 | } |
346 | 346 | ||
347 | private static incrementScores (inboxUrls: string[], value: number, t: Sequelize.Transaction) { | 347 | private static incrementScores (inboxUrls: string[], value: number, t: Sequelize.Transaction | undefined) { |
348 | const inboxUrlsString = inboxUrls.map(url => `'${url}'`).join(',') | 348 | const inboxUrlsString = inboxUrls.map(url => `'${url}'`).join(',') |
349 | 349 | ||
350 | const query = `UPDATE "actorFollow" SET "score" = LEAST("score" + ${value}, ${ACTOR_FOLLOW_SCORE.MAX}) ` + | 350 | const query = `UPDATE "actorFollow" SET "score" = LEAST("score" + ${value}, ${ACTOR_FOLLOW_SCORE.MAX}) ` + |
@@ -354,10 +354,10 @@ export class ActorFollowModel extends Model<ActorFollowModel> { | |||
354 | 'WHERE "actor"."inboxUrl" IN (' + inboxUrlsString + ') OR "actor"."sharedInboxUrl" IN (' + inboxUrlsString + ')' + | 354 | 'WHERE "actor"."inboxUrl" IN (' + inboxUrlsString + ') OR "actor"."sharedInboxUrl" IN (' + inboxUrlsString + ')' + |
355 | ')' | 355 | ')' |
356 | 356 | ||
357 | const options = { | 357 | const options = t ? { |
358 | type: Sequelize.QueryTypes.BULKUPDATE, | 358 | type: Sequelize.QueryTypes.BULKUPDATE, |
359 | transaction: t | 359 | transaction: t |
360 | } | 360 | } : undefined |
361 | 361 | ||
362 | return ActorFollowModel.sequelize.query(query, options) | 362 | return ActorFollowModel.sequelize.query(query, options) |
363 | } | 363 | } |