From 868fce62f86812759ccedccf7634236ac3701d9a Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 3 Jun 2021 18:10:56 +0200 Subject: fetch -> load avoid confusion with AP fetch functions --- server/lib/activitypub/actors/get.ts | 8 ++++---- server/lib/activitypub/actors/refresh.ts | 4 ++-- server/lib/activitypub/videos/get.ts | 8 ++++---- server/lib/activitypub/videos/refresh.ts | 4 ++-- 4 files changed, 12 insertions(+), 12 deletions(-) (limited to 'server/lib/activitypub') diff --git a/server/lib/activitypub/actors/get.ts b/server/lib/activitypub/actors/get.ts index e7e87a967..c7b49d6e4 100644 --- a/server/lib/activitypub/actors/get.ts +++ b/server/lib/activitypub/actors/get.ts @@ -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 { @@ -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)) { diff --git a/server/lib/activitypub/actors/refresh.ts b/server/lib/activitypub/actors/refresh.ts index 9f2289bfa..9758649a5 100644 --- a/server/lib/activitypub/actors/refresh.ts +++ b/server/lib/activitypub/actors/refresh.ts @@ -1,6 +1,6 @@ import { logger } from '@server/helpers/logger' import { PeerTubeRequestError } from '@server/helpers/requests' -import { ActorFetchByUrlType } from '@server/lib/model-loaders' +import { ActorLoadByUrlType } from '@server/lib/model-loaders' import { ActorModel } from '@server/models/actor/actor' import { MActorAccountChannelId, MActorFull } from '@server/types/models' import { HttpStatusCode } from '@shared/core-utils' @@ -10,7 +10,7 @@ import { getUrlFromWebfinger } from './webfinger' async function refreshActorIfNeeded ( actorArg: T, - fetchedType: ActorFetchByUrlType + fetchedType: ActorLoadByUrlType ): Promise<{ actor: T | MActorFull, refreshed: boolean }> { if (!actorArg.isOutdated()) return { actor: actorArg, refreshed: false } diff --git a/server/lib/activitypub/videos/get.ts b/server/lib/activitypub/videos/get.ts index 38ba4978c..5d1f92bba 100644 --- a/server/lib/activitypub/videos/get.ts +++ b/server/lib/activitypub/videos/get.ts @@ -1,7 +1,7 @@ import { getAPId } from '@server/helpers/activitypub' import { retryTransactionWrapper } from '@server/helpers/database-utils' import { JobQueue } from '@server/lib/job-queue' -import { fetchVideoByUrl, VideoFetchByUrlType } from '@server/lib/model-loaders' +import { loadVideoByUrl, VideoLoadByUrlType } from '@server/lib/model-loaders' import { MVideoAccountLightBlacklistAllFiles, MVideoImmutable, MVideoThumbnail } from '@server/types/models' import { refreshVideoIfNeeded } from './refresh' import { APVideoCreator, fetchRemoteVideo, SyncParam, syncVideoExternalAttributes } from './shared' @@ -47,7 +47,7 @@ async function getOrCreateAPVideo ( // Get video url const videoUrl = getAPId(options.videoObject) - let videoFromDatabase = await fetchVideoByUrl(videoUrl, fetchType) + let videoFromDatabase = await loadVideoByUrl(videoUrl, fetchType) if (videoFromDatabase) { if (allowRefresh === true) { @@ -71,7 +71,7 @@ async function getOrCreateAPVideo ( } catch (err) { // Maybe a concurrent getOrCreateAPVideo call created this video if (err.name === 'SequelizeUniqueConstraintError') { - const alreadyCreatedVideo = await fetchVideoByUrl(videoUrl, fetchType) + const alreadyCreatedVideo = await loadVideoByUrl(videoUrl, fetchType) if (alreadyCreatedVideo) return { video: alreadyCreatedVideo, created: false } } @@ -87,7 +87,7 @@ export { // --------------------------------------------------------------------------- -async function scheduleRefresh (video: MVideoThumbnail, fetchType: VideoFetchByUrlType, syncParam: SyncParam) { +async function scheduleRefresh (video: MVideoThumbnail, fetchType: VideoLoadByUrlType, syncParam: SyncParam) { if (!video.isOutdated()) return video const refreshOptions = { diff --git a/server/lib/activitypub/videos/refresh.ts b/server/lib/activitypub/videos/refresh.ts index f1a3a6fac..82b3b13bf 100644 --- a/server/lib/activitypub/videos/refresh.ts +++ b/server/lib/activitypub/videos/refresh.ts @@ -1,7 +1,7 @@ import { logger, loggerTagsFactory } from '@server/helpers/logger' import { PeerTubeRequestError } from '@server/helpers/requests' import { ActorFollowScoreCache } from '@server/lib/files-cache' -import { VideoFetchByUrlType } from '@server/lib/model-loaders' +import { VideoLoadByUrlType } from '@server/lib/model-loaders' import { VideoModel } from '@server/models/video/video' import { MVideoAccountLightBlacklistAllFiles, MVideoThumbnail } from '@server/types/models' import { HttpStatusCode } from '@shared/core-utils' @@ -10,7 +10,7 @@ import { APVideoUpdater } from './updater' async function refreshVideoIfNeeded (options: { video: MVideoThumbnail - fetchedType: VideoFetchByUrlType + fetchedType: VideoLoadByUrlType syncParam: SyncParam }): Promise { if (!options.video.isOutdated()) return options.video -- cgit v1.2.3