2018-04-01 12:18:36 +02:00
|
|
|
import renderImage from './image';
|
|
|
|
import renderKey from './key';
|
2018-04-02 06:15:53 +02:00
|
|
|
import config from '../../../config';
|
2018-05-31 11:34:15 +02:00
|
|
|
import { ILocalUser } from '../../../models/user';
|
2018-06-26 11:34:17 +02:00
|
|
|
import toHtml from '../../../mfm/html';
|
|
|
|
import parse from '../../../mfm/parse';
|
2018-04-01 12:18:36 +02:00
|
|
|
|
2018-05-31 11:34:15 +02:00
|
|
|
export default (user: ILocalUser) => {
|
2018-04-08 08:15:22 +02:00
|
|
|
const id = `${config.url}/users/${user._id}`;
|
2018-04-01 12:18:36 +02:00
|
|
|
|
|
|
|
return {
|
2018-06-23 12:16:50 +02:00
|
|
|
type: user.isBot ? 'Service' : 'Person',
|
2018-04-01 12:18:36 +02:00
|
|
|
id,
|
|
|
|
inbox: `${id}/inbox`,
|
|
|
|
outbox: `${id}/outbox`,
|
2018-04-23 08:37:27 +02:00
|
|
|
sharedInbox: `${config.url}/inbox`,
|
2018-04-08 11:21:02 +02:00
|
|
|
url: `${config.url}/@${user.username}`,
|
2018-04-01 12:18:36 +02:00
|
|
|
preferredUsername: user.username,
|
|
|
|
name: user.name,
|
2018-06-26 11:34:17 +02:00
|
|
|
summary: toHtml(parse(user.description)),
|
2018-06-18 07:28:43 +02:00
|
|
|
icon: user.avatarId && renderImage(user.avatarId),
|
|
|
|
image: user.bannerId && renderImage(user.bannerId),
|
2018-05-31 11:34:15 +02:00
|
|
|
manuallyApprovesFollowers: user.isLocked,
|
2018-04-01 12:18:36 +02:00
|
|
|
publicKey: renderKey(user)
|
|
|
|
};
|
|
|
|
};
|