diff options
author | Chocobozzz <me@florianbigard.com> | 2019-08-09 11:32:40 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2019-08-09 11:32:40 +0200 |
commit | 557b13ae24019d9ab214bbea7eaa0f892c8f4b05 (patch) | |
tree | aa32396531acf93e3dfdb29880177813039ed77f /server/lib/activitypub/process | |
parent | c5407d7046168abb4098df1408e7aa84519cb61a (diff) | |
download | PeerTube-557b13ae24019d9ab214bbea7eaa0f892c8f4b05.tar.gz PeerTube-557b13ae24019d9ab214bbea7eaa0f892c8f4b05.tar.zst PeerTube-557b13ae24019d9ab214bbea7eaa0f892c8f4b05.zip |
Lazy load avatars
Diffstat (limited to 'server/lib/activitypub/process')
-rw-r--r-- | server/lib/activitypub/process/process-update.ts | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/server/lib/activitypub/process/process-update.ts b/server/lib/activitypub/process/process-update.ts index e3c862221..414f9e375 100644 --- a/server/lib/activitypub/process/process-update.ts +++ b/server/lib/activitypub/process/process-update.ts | |||
@@ -6,7 +6,7 @@ import { sequelizeTypescript } from '../../../initializers' | |||
6 | import { AccountModel } from '../../../models/account/account' | 6 | import { AccountModel } from '../../../models/account/account' |
7 | import { ActorModel } from '../../../models/activitypub/actor' | 7 | import { ActorModel } from '../../../models/activitypub/actor' |
8 | import { VideoChannelModel } from '../../../models/video/video-channel' | 8 | import { VideoChannelModel } from '../../../models/video/video-channel' |
9 | import { fetchAvatarIfExists, updateActorAvatarInstance, updateActorInstance } from '../actor' | 9 | import { getAvatarInfoIfExists, updateActorAvatarInstance, updateActorInstance } from '../actor' |
10 | import { getOrCreateVideoAndAccountAndChannel, getOrCreateVideoChannelFromVideoObject, updateVideoFromAP } from '../videos' | 10 | import { getOrCreateVideoAndAccountAndChannel, getOrCreateVideoChannelFromVideoObject, updateVideoFromAP } from '../videos' |
11 | import { sanitizeAndCheckVideoTorrentObject } from '../../../helpers/custom-validators/activitypub/videos' | 11 | import { sanitizeAndCheckVideoTorrentObject } from '../../../helpers/custom-validators/activitypub/videos' |
12 | import { isCacheFileObjectValid } from '../../../helpers/custom-validators/activitypub/cache-file' | 12 | import { isCacheFileObjectValid } from '../../../helpers/custom-validators/activitypub/cache-file' |
@@ -105,7 +105,7 @@ async function processUpdateActor (actor: ActorModel, activity: ActivityUpdate) | |||
105 | let accountOrChannelFieldsSave: object | 105 | let accountOrChannelFieldsSave: object |
106 | 106 | ||
107 | // Fetch icon? | 107 | // Fetch icon? |
108 | const avatarName = await fetchAvatarIfExists(actorAttributesToUpdate) | 108 | const avatarInfo = await getAvatarInfoIfExists(actorAttributesToUpdate) |
109 | 109 | ||
110 | try { | 110 | try { |
111 | await sequelizeTypescript.transaction(async t => { | 111 | await sequelizeTypescript.transaction(async t => { |
@@ -118,8 +118,10 @@ async function processUpdateActor (actor: ActorModel, activity: ActivityUpdate) | |||
118 | 118 | ||
119 | await updateActorInstance(actor, actorAttributesToUpdate) | 119 | await updateActorInstance(actor, actorAttributesToUpdate) |
120 | 120 | ||
121 | if (avatarName !== undefined) { | 121 | if (avatarInfo !== undefined) { |
122 | await updateActorAvatarInstance(actor, avatarName, t) | 122 | const avatarOptions = Object.assign({}, avatarInfo, { onDisk: false }) |
123 | |||
124 | await updateActorAvatarInstance(actor, avatarOptions, t) | ||
123 | } | 125 | } |
124 | 126 | ||
125 | await actor.save({ transaction: t }) | 127 | await actor.save({ transaction: t }) |