This commit is contained in:
syuilo 2018-03-28 16:39:14 +09:00
parent 7d4d9dbaa6
commit 3d5cdb8d2d
237 changed files with 1661 additions and 1354 deletions

View file

@ -100,21 +100,21 @@ export const pack = async (
}
// Populate user
_post.user = packUser(_post.user_id, meId);
_post.user = packUser(_post.userId, meId);
// Populate app
if (_post.app_id) {
_post.app = packApp(_post.app_id);
if (_post.appId) {
_post.app = packApp(_post.appId);
}
// Populate channel
if (_post.channel_id) {
_post.channel = packChannel(_post.channel_id);
if (_post.channelId) {
_post.channel = packChannel(_post.channelId);
}
// Populate media
if (_post.media_ids) {
_post.media = Promise.all(_post.media_ids.map(fileId =>
if (_post.mediaIds) {
_post.media = Promise.all(_post.mediaIds.map(fileId =>
packFile(fileId)
));
}
@ -124,7 +124,7 @@ export const pack = async (
// Get previous post info
_post.prev = (async () => {
const prev = await Post.findOne({
user_id: _post.user_id,
userId: _post.userId,
_id: {
$lt: id
}
@ -142,7 +142,7 @@ export const pack = async (
// Get next post info
_post.next = (async () => {
const next = await Post.findOne({
user_id: _post.user_id,
userId: _post.userId,
_id: {
$gt: id
}
@ -157,16 +157,16 @@ export const pack = async (
return next ? next._id : null;
})();
if (_post.reply_id) {
if (_post.replyId) {
// Populate reply to post
_post.reply = pack(_post.reply_id, meId, {
_post.reply = pack(_post.replyId, meId, {
detail: false
});
}
if (_post.repost_id) {
if (_post.repostId) {
// Populate repost
_post.repost = pack(_post.repost_id, meId, {
_post.repost = pack(_post.repostId, meId, {
detail: _post.text == null
});
}
@ -176,8 +176,8 @@ export const pack = async (
_post.poll = (async (poll) => {
const vote = await Vote
.findOne({
user_id: meId,
post_id: id
userId: meId,
postId: id
});
if (vote != null) {
@ -196,9 +196,9 @@ export const pack = async (
_post.my_reaction = (async () => {
const reaction = await Reaction
.findOne({
user_id: meId,
post_id: id,
deleted_at: { $exists: false }
userId: meId,
postId: id,
deletedAt: { $exists: false }
});
if (reaction) {