aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib/activitypub/actor.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/lib/activitypub/actor.ts')
-rw-r--r--server/lib/activitypub/actor.ts35
1 files changed, 25 insertions, 10 deletions
diff --git a/server/lib/activitypub/actor.ts b/server/lib/activitypub/actor.ts
index 917fed6ec..eec951d4e 100644
--- a/server/lib/activitypub/actor.ts
+++ b/server/lib/activitypub/actor.ts
@@ -170,7 +170,13 @@ async function updateActorInstance (actorInstance: ActorModel, attributes: Activ
170 } 170 }
171} 171}
172 172
173type ImageInfo = { name: string, onDisk?: boolean, fileUrl: string } 173type ImageInfo = {
174 name: string
175 fileUrl: string
176 height: number
177 width: number
178 onDisk?: boolean
179}
174async function updateActorImageInstance (actor: MActorImages, type: ActorImageType, imageInfo: ImageInfo | null, t: Transaction) { 180async function updateActorImageInstance (actor: MActorImages, type: ActorImageType, imageInfo: ImageInfo | null, t: Transaction) {
175 const oldImageModel = type === ActorImageType.AVATAR 181 const oldImageModel = type === ActorImageType.AVATAR
176 ? actor.Avatar 182 ? actor.Avatar
@@ -194,7 +200,9 @@ async function updateActorImageInstance (actor: MActorImages, type: ActorImageTy
194 filename: imageInfo.name, 200 filename: imageInfo.name,
195 onDisk: imageInfo.onDisk ?? false, 201 onDisk: imageInfo.onDisk ?? false,
196 fileUrl: imageInfo.fileUrl, 202 fileUrl: imageInfo.fileUrl,
197 type: type 203 height: imageInfo.height,
204 width: imageInfo.width,
205 type
198 }, { transaction: t }) 206 }, { transaction: t })
199 207
200 setActorImage(actor, type, imageModel) 208 setActorImage(actor, type, imageModel)
@@ -257,6 +265,8 @@ function getImageInfoIfExists (actorJSON: ActivityPubActor, type: ActorImageType
257 return { 265 return {
258 name: uuidv4() + extension, 266 name: uuidv4() + extension,
259 fileUrl: icon.url, 267 fileUrl: icon.url,
268 height: icon.height,
269 width: icon.width,
260 type 270 type
261 } 271 }
262} 272}
@@ -408,6 +418,8 @@ function saveActorAndServerAndModelIfNotExist (
408 const avatar = await ActorImageModel.create({ 418 const avatar = await ActorImageModel.create({
409 filename: result.avatar.name, 419 filename: result.avatar.name,
410 fileUrl: result.avatar.fileUrl, 420 fileUrl: result.avatar.fileUrl,
421 width: result.avatar.width,
422 height: result.avatar.height,
411 onDisk: false, 423 onDisk: false,
412 type: ActorImageType.AVATAR 424 type: ActorImageType.AVATAR
413 }, { transaction: t }) 425 }, { transaction: t })
@@ -420,6 +432,8 @@ function saveActorAndServerAndModelIfNotExist (
420 const banner = await ActorImageModel.create({ 432 const banner = await ActorImageModel.create({
421 filename: result.banner.name, 433 filename: result.banner.name,
422 fileUrl: result.banner.fileUrl, 434 fileUrl: result.banner.fileUrl,
435 width: result.banner.width,
436 height: result.banner.height,
423 onDisk: false, 437 onDisk: false,
424 type: ActorImageType.BANNER 438 type: ActorImageType.BANNER
425 }, { transaction: t }) 439 }, { transaction: t })
@@ -470,20 +484,21 @@ function saveActorAndServerAndModelIfNotExist (
470 } 484 }
471} 485}
472 486
487type ImageResult = {
488 name: string
489 fileUrl: string
490 height: number
491 width: number
492}
493
473type FetchRemoteActorResult = { 494type FetchRemoteActorResult = {
474 actor: MActor 495 actor: MActor
475 name: string 496 name: string
476 summary: string 497 summary: string
477 support?: string 498 support?: string
478 playlists?: string 499 playlists?: string
479 avatar?: { 500 avatar?: ImageResult
480 name: string 501 banner?: ImageResult
481 fileUrl: string
482 }
483 banner?: {
484 name: string
485 fileUrl: string
486 }
487 attributedTo: ActivityPubAttributedTo[] 502 attributedTo: ActivityPubAttributedTo[]
488} 503}
489async function fetchRemoteActor (actorUrl: string): Promise<{ statusCode?: number, result: FetchRemoteActorResult }> { 504async function fetchRemoteActor (actorUrl: string): Promise<{ statusCode?: number, result: FetchRemoteActorResult }> {