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'
async function getOrCreateAPActor (
activityActor: string | ActivityPubActor,
- fetchType: ActorFetchByUrlType = 'association-ids',
+ fetchType: ActorLoadByUrlType = 'association-ids',
recurseIfNeeded = true,
updateCollections = false
): Promise<MActorFullActor | MActorAccountChannelId> {
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)
// ---------------------------------------------------------------------------
-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)) {