1
0
forked from mirror/misskey
misskey/src/remote/activitypub/renderer/person.ts

37 lines
1.1 KiB
TypeScript
Raw Normal View History

2018-04-01 19:18:36 +09:00
import renderImage from './image';
import renderKey from './key';
2018-04-02 13:15:53 +09:00
import config from '../../../config';
2018-05-31 18:34:15 +09:00
import { ILocalUser } from '../../../models/user';
2018-06-26 18:34:17 +09:00
import toHtml from '../../../mfm/html';
import parse from '../../../mfm/parse';
2018-07-20 02:40:37 +09:00
import DriveFile from '../../../models/drive-file';
2018-04-01 19:18:36 +09:00
2018-07-20 02:40:37 +09:00
export default async (user: ILocalUser) => {
2018-04-08 15:15:22 +09:00
const id = `${config.url}/users/${user._id}`;
2018-04-01 19:18:36 +09:00
2018-07-20 02:40:37 +09:00
const [avatar, banner] = await Promise.all([
DriveFile.findOne({ _id: user.avatarId }),
DriveFile.findOne({ _id: user.bannerId })
]);
2018-04-01 19:18:36 +09:00
return {
2018-06-23 19:16:50 +09:00
type: user.isBot ? 'Service' : 'Person',
2018-04-01 19:18:36 +09:00
id,
inbox: `${id}/inbox`,
outbox: `${id}/outbox`,
2018-08-13 03:49:17 +09:00
followers: `${id}/followers`,
following: `${id}/following`,
2018-09-18 13:08:27 +09:00
featured: `${id}/collections/featured`,
2018-04-23 15:37:27 +09:00
sharedInbox: `${config.url}/inbox`,
2018-04-08 18:21:02 +09:00
url: `${config.url}/@${user.username}`,
2018-04-01 19:18:36 +09:00
preferredUsername: user.username,
name: user.name,
2018-06-26 18:34:17 +09:00
summary: toHtml(parse(user.description)),
2018-07-20 02:40:37 +09:00
icon: user.avatarId && renderImage(avatar),
image: user.bannerId && renderImage(banner),
2018-05-31 18:34:15 +09:00
manuallyApprovesFollowers: user.isLocked,
2018-08-22 09:16:52 +09:00
publicKey: renderKey(user),
isCat: user.isCat
2018-04-01 19:18:36 +09:00
};
};