36 lines
1.0 KiB
TypeScript
36 lines
1.0 KiB
TypeScript
import renderImage from './image';
|
|
import renderKey from './key';
|
|
import config from '../../../config';
|
|
import { ILocalUser } from '../../../models/user';
|
|
import toHtml from '../../../mfm/html';
|
|
import parse from '../../../mfm/parse';
|
|
import DriveFile from '../../../models/drive-file';
|
|
|
|
export default async (user: ILocalUser) => {
|
|
const id = `${config.url}/users/${user._id}`;
|
|
|
|
const [avatar, banner] = await Promise.all([
|
|
DriveFile.findOne({ _id: user.avatarId }),
|
|
DriveFile.findOne({ _id: user.bannerId })
|
|
]);
|
|
|
|
return {
|
|
type: user.isBot ? 'Service' : 'Person',
|
|
id,
|
|
inbox: `${id}/inbox`,
|
|
outbox: `${id}/outbox`,
|
|
followers: `${id}/followers`,
|
|
following: `${id}/following`,
|
|
sharedInbox: `${config.url}/inbox`,
|
|
url: `${config.url}/@${user.username}`,
|
|
preferredUsername: user.username,
|
|
name: user.name,
|
|
summary: toHtml(parse(user.description)),
|
|
icon: user.avatarId && renderImage(avatar),
|
|
image: user.bannerId && renderImage(banner),
|
|
manuallyApprovesFollowers: user.isLocked,
|
|
publicKey: renderKey(user),
|
|
isCat: user.isCat
|
|
};
|
|
};
|