]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/lib/activitypub/actors/get.ts
Try to speed up AP update transaction
[github/Chocobozzz/PeerTube.git] / server / lib / activitypub / actors / get.ts
index e7e87a96740451c77365ce734f30efb1fee3bd01..de93aa9643f70689a20cd1a85e23175c3921d282 100644 (file)
@@ -3,7 +3,7 @@ import { checkUrlsSameHost, getAPId } from '@server/helpers/activitypub'
 import { retryTransactionWrapper } from '@server/helpers/database-utils'
 import { logger } from '@server/helpers/logger'
 import { JobQueue } from '@server/lib/job-queue'
-import { ActorFetchByUrlType, fetchActorByUrl } from '@server/lib/model-loaders'
+import { ActorLoadByUrlType, loadActorByUrl } from '@server/lib/model-loaders'
 import { MActor, MActorAccountChannelId, MActorAccountChannelIdActor, MActorAccountId, MActorFullActor } from '@server/types/models'
 import { ActivityPubActor } from '@shared/models'
 import { refreshActorIfNeeded } from './refresh'
@@ -25,7 +25,7 @@ function getOrCreateAPActor (
 
 async function getOrCreateAPActor (
   activityActor: string | ActivityPubActor,
-  fetchType: ActorFetchByUrlType = 'association-ids',
+  fetchType: ActorLoadByUrlType = 'association-ids',
   recurseIfNeeded = true,
   updateCollections = false
 ): Promise<MActorFullActor | MActorAccountChannelId> {
@@ -56,7 +56,7 @@ async function getOrCreateAPActor (
   if (actor.Account) (actor as MActorAccountChannelIdActor).Account.Actor = actor
   if (actor.VideoChannel) (actor as MActorAccountChannelIdActor).VideoChannel.Actor = actor
 
-  const { actor: actorRefreshed, refreshed } = await retryTransactionWrapper(refreshActorIfNeeded, actor, fetchType)
+  const { actor: actorRefreshed, refreshed } = await refreshActorIfNeeded(actor, fetchType)
   if (!actorRefreshed) throw new Error('Actor ' + actor.url + ' does not exist anymore.')
 
   await scheduleOutboxFetchIfNeeded(actor, created, refreshed, updateCollections)
@@ -73,8 +73,8 @@ export {
 
 // ---------------------------------------------------------------------------
 
-async function loadActorFromDB (actorUrl: string, fetchType: ActorFetchByUrlType) {
-  let actor = await fetchActorByUrl(actorUrl, fetchType)
+async function loadActorFromDB (actorUrl: string, fetchType: ActorLoadByUrlType) {
+  let actor = await loadActorByUrl(actorUrl, fetchType)
 
   // Orphan actor (not associated to an account of channel) so recreate it
   if (actor && (!actor.Account && !actor.VideoChannel)) {