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:
parent
c5407d7046
commit
557b13ae24
18 changed files with 324 additions and 92 deletions
|
@ -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 })
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue