mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-26 08:36:12 +01:00
fix: send full as:Image object for icon and image in mocked actor object
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const nconf = require('nconf');
|
const nconf = require('nconf');
|
||||||
|
const mime = require('mime');
|
||||||
|
|
||||||
const db = require('../database');
|
const db = require('../database');
|
||||||
const user = require('../user');
|
const user = require('../user');
|
||||||
@@ -118,9 +119,27 @@ Mocks.post = async (objects) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
Mocks.actor = async (uid) => {
|
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);
|
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 {
|
return {
|
||||||
'@context': [
|
'@context': [
|
||||||
'https://www.w3.org/ns/activitystreams',
|
'https://www.w3.org/ns/activitystreams',
|
||||||
@@ -137,8 +156,8 @@ Mocks.actor = async (uid) => {
|
|||||||
name,
|
name,
|
||||||
preferredUsername: username,
|
preferredUsername: username,
|
||||||
summary: aboutme,
|
summary: aboutme,
|
||||||
icon: picture ? `${nconf.get('url')}${picture}` : null,
|
icon: picture,
|
||||||
image: cover ? `${nconf.get('url')}${cover}` : null,
|
image: cover,
|
||||||
|
|
||||||
publicKey: {
|
publicKey: {
|
||||||
id: `${nconf.get('url')}/user/${userslug}#key`,
|
id: `${nconf.get('url')}/user/${userslug}#key`,
|
||||||
|
|||||||
Reference in New Issue
Block a user