This commit is contained in:
syuilo 2018-02-02 08:21:30 +09:00
parent 9a282e37be
commit 718060dc85
61 changed files with 132 additions and 119 deletions

View file

@ -3,7 +3,7 @@
*/
import $ from 'cafy';
import Post from '../../models/post';
import serialize from '../../serializers/post';
import { pack } from '../../models/post';
/**
* Show a context of a post
@ -60,5 +60,5 @@ module.exports = (params, user) => new Promise(async (res, rej) => {
// Serialize
res(await Promise.all(context.map(async post =>
await serialize(post, user))));
await pack(post, user))));
});

View file

@ -12,7 +12,7 @@ import Mute from '../../models/mute';
import DriveFile from '../../models/drive-file';
import Watching from '../../models/post-watching';
import ChannelWatching from '../../models/channel-watching';
import serialize from '../../serializers/post';
import { pack } from '../../models/post';
import notify from '../../common/notify';
import watch from '../../common/watch-post';
import event, { pushSw, publishChannelStream } from '../../event';
@ -224,7 +224,7 @@ module.exports = (params, user: IUser, app) => new Promise(async (res, rej) => {
});
// Serialize
const postObj = await serialize(post);
const postObj = await pack(post);
// Reponse
res({

View file

@ -4,7 +4,7 @@
import $ from 'cafy';
import Post from '../../models/post';
import getFriends from '../../common/get-friends';
import serialize from '../../serializers/post';
import { pack } from '../../models/post';
/**
* Get mentions of myself
@ -73,6 +73,6 @@ module.exports = (params, user) => new Promise(async (res, rej) => {
// Serialize
res(await Promise.all(mentions.map(async mention =>
await serialize(mention, user)
await pack(mention, user)
)));
});

View file

@ -4,7 +4,7 @@
import $ from 'cafy';
import Vote from '../../../models/poll-vote';
import Post from '../../../models/post';
import serialize from '../../../serializers/post';
import { pack } from '../../../models/post';
/**
* Get recommended polls
@ -56,5 +56,5 @@ module.exports = (params, user) => new Promise(async (res, rej) => {
// Serialize
res(await Promise.all(posts.map(async post =>
await serialize(post, user, { detail: true }))));
await pack(post, user, { detail: true }))));
});

View file

@ -4,7 +4,7 @@
import $ from 'cafy';
import Post from '../../models/post';
import Reaction from '../../models/post-reaction';
import serialize from '../../serializers/post-reaction';
import { pack } from '../../models/post-reaction';
/**
* Show reactions of a post
@ -54,5 +54,5 @@ module.exports = (params, user) => new Promise(async (res, rej) => {
// Serialize
res(await Promise.all(reactions.map(async reaction =>
await serialize(reaction, user))));
await pack(reaction, user))));
});

View file

@ -3,7 +3,7 @@
*/
import $ from 'cafy';
import Post from '../../models/post';
import serialize from '../../serializers/post';
import { pack } from '../../models/post';
/**
* Show a replies of a post
@ -50,5 +50,5 @@ module.exports = (params, user) => new Promise(async (res, rej) => {
// Serialize
res(await Promise.all(replies.map(async post =>
await serialize(post, user))));
await pack(post, user))));
});

View file

@ -3,7 +3,7 @@
*/
import $ from 'cafy';
import Post from '../../models/post';
import serialize from '../../serializers/post';
import { pack } from '../../models/post';
/**
* Show a reposts of a post
@ -70,5 +70,5 @@ module.exports = (params, user) => new Promise(async (res, rej) => {
// Serialize
res(await Promise.all(reposts.map(async post =>
await serialize(post, user))));
await pack(post, user))));
});

View file

@ -7,7 +7,7 @@ import Post from '../../models/post';
import User from '../../models/user';
import Mute from '../../models/mute';
import getFriends from '../../common/get-friends';
import serialize from '../../serializers/post';
import { pack } from '../../models/post';
/**
* Search a post
@ -351,5 +351,5 @@ async function search(
// Serialize
res(await Promise.all(posts.map(async post =>
await serialize(post, me))));
await pack(post, me))));
}

View file

@ -3,7 +3,7 @@
*/
import $ from 'cafy';
import Post from '../../models/post';
import serialize from '../../serializers/post';
import { pack } from '../../models/post';
/**
* Show a post
@ -27,7 +27,7 @@ module.exports = (params, user) => new Promise(async (res, rej) => {
}
// Serialize
res(await serialize(post, user, {
res(await pack(post, user, {
detail: true
}));
});

View file

@ -7,7 +7,7 @@ import Post from '../../models/post';
import Mute from '../../models/mute';
import ChannelWatching from '../../models/channel-watching';
import getFriends from '../../common/get-friends';
import serialize from '../../serializers/post';
import { pack } from '../../models/post';
/**
* Get timeline of myself
@ -128,5 +128,5 @@ module.exports = async (params, user, app) => {
});
// Serialize
return await Promise.all(timeline.map(post => serialize(post, user)));
return await Promise.all(timeline.map(post => pack(post, user)));
};

View file

@ -4,7 +4,7 @@
const ms = require('ms');
import $ from 'cafy';
import Post from '../../models/post';
import serialize from '../../serializers/post';
import { pack } from '../../models/post';
/**
* Get trend posts
@ -76,5 +76,5 @@ module.exports = (params, user) => new Promise(async (res, rej) => {
// Serialize
res(await Promise.all(posts.map(async post =>
await serialize(post, user, { detail: true }))));
await pack(post, user, { detail: true }))));
});