1
0
Fork 0
mirror of https://github.com/Chocobozzz/PeerTube.git synced 2025-10-05 10:49:28 +02:00

Lazy load avatars

This commit is contained in:
Chocobozzz 2019-08-09 11:32:40 +02:00
parent c5407d7046
commit 557b13ae24
No known key found for this signature in database
GPG key ID: 583A612D890159BE
18 changed files with 324 additions and 92 deletions

View file

@ -6,7 +6,7 @@ import { sequelizeTypescript } from '../../../initializers'
import { AccountModel } from '../../../models/account/account'
import { ActorModel } from '../../../models/activitypub/actor'
import { VideoChannelModel } from '../../../models/video/video-channel'
import { fetchAvatarIfExists, updateActorAvatarInstance, updateActorInstance } from '../actor'
import { getAvatarInfoIfExists, updateActorAvatarInstance, updateActorInstance } from '../actor'
import { getOrCreateVideoAndAccountAndChannel, getOrCreateVideoChannelFromVideoObject, updateVideoFromAP } from '../videos'
import { sanitizeAndCheckVideoTorrentObject } from '../../../helpers/custom-validators/activitypub/videos'
import { isCacheFileObjectValid } from '../../../helpers/custom-validators/activitypub/cache-file'
@ -105,7 +105,7 @@ async function processUpdateActor (actor: ActorModel, activity: ActivityUpdate)
let accountOrChannelFieldsSave: object
// Fetch icon?
const avatarName = await fetchAvatarIfExists(actorAttributesToUpdate)
const avatarInfo = await getAvatarInfoIfExists(actorAttributesToUpdate)
try {
await sequelizeTypescript.transaction(async t => {
@ -118,8 +118,10 @@ async function processUpdateActor (actor: ActorModel, activity: ActivityUpdate)
await updateActorInstance(actor, actorAttributesToUpdate)
if (avatarName !== undefined) {
await updateActorAvatarInstance(actor, avatarName, t)
if (avatarInfo !== undefined) {
const avatarOptions = Object.assign({}, avatarInfo, { onDisk: false })
await updateActorAvatarInstance(actor, avatarOptions, t)
}
await actor.save({ transaction: t })