From 0af97dd444a37767eb0d8ed1500a4e5e20f105fa Mon Sep 17 00:00:00 2001 From: Julian Lam Date: Wed, 24 Jan 2024 22:59:09 -0500 Subject: [PATCH] fix: send full as:Image object for icon and image in mocked actor object --- src/activitypub/mocks.js | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/src/activitypub/mocks.js b/src/activitypub/mocks.js index 2b979eccc5..0aa93f045b 100644 --- a/src/activitypub/mocks.js +++ b/src/activitypub/mocks.js @@ -1,6 +1,7 @@ 'use strict'; const nconf = require('nconf'); +const mime = require('mime'); const db = require('../database'); const user = require('../user'); @@ -118,9 +119,27 @@ Mocks.post = async (objects) => { }; Mocks.actor = async (uid) => { - const { username, userslug, displayname: name, aboutme, picture, 'cover:url': cover } = await user.getUserData(uid); + let { username, userslug, displayname: name, aboutme, picture, 'cover:url': cover } = await user.getUserData(uid); const publicKey = await activitypub.getPublicKey(uid); + if (picture) { + const imagePath = await user.getLocalAvatarPath(uid); + picture = { + type: 'Image', + mediaType: mime.getType(imagePath), + url: `${nconf.get('url')}${picture}`, + }; + } + + if (cover) { + const imagePath = await user.getLocalCoverPath(uid); + cover = { + type: 'Image', + mediaType: mime.getType(imagePath), + url: `${nconf.get('url')}${cover}`, + }; + } + return { '@context': [ 'https://www.w3.org/ns/activitystreams', @@ -137,8 +156,8 @@ Mocks.actor = async (uid) => { name, preferredUsername: username, summary: aboutme, - icon: picture ? `${nconf.get('url')}${picture}` : null, - image: cover ? `${nconf.get('url')}${cover}` : null, + icon: picture, + image: cover, publicKey: { id: `${nconf.get('url')}/user/${userslug}#key`,