This commit is contained in:
syuilo
2018-04-05 19:19:00 +09:00
parent fd87a63e57
commit 2a80fdeafe
3 changed files with 38 additions and 25 deletions

View File

@ -2,11 +2,14 @@ import renderDocument from './document';
import renderHashtag from './hashtag';
import config from '../../../config';
import DriveFile from '../../../models/drive-file';
import Post from '../../../models/post';
import User from '../../../models/user';
import Post, { IPost } from '../../../models/post';
import User, { IUser } from '../../../models/user';
export default async (user: IUser, post: IPost) => {
const promisedFiles = post.mediaIds
? DriveFile.find({ _id: { $in: post.mediaIds } })
: Promise.resolve([]);
export default async (user, post) => {
const promisedFiles = DriveFile.find({ _id: { $in: post.mediaIds } });
let inReplyTo;
if (post.replyId) {
@ -39,6 +42,6 @@ export default async (user, post) => {
cc: `${attributedTo}/followers`,
inReplyTo,
attachment: (await promisedFiles).map(renderDocument),
tag: post.tags.map(renderHashtag)
tag: (post.tags || []).map(renderHashtag)
};
};