summaryrefslogtreecommitdiff
path: root/src/api/endpoints
diff options
context:
space:
mode:
authorsyuilo <syuilotan@yahoo.co.jp>2018-02-02 08:21:30 +0900
committersyuilo <syuilotan@yahoo.co.jp>2018-02-02 08:21:30 +0900
commit718060dc855e09f270b8e19c089ed3c3743665e0 (patch)
tree334ea8c7dcd04153da311cf6073407f6f14eb423 /src/api/endpoints
parentwip (diff)
downloadmisskey-718060dc855e09f270b8e19c089ed3c3743665e0.tar.gz
misskey-718060dc855e09f270b8e19c089ed3c3743665e0.tar.bz2
misskey-718060dc855e09f270b8e19c089ed3c3743665e0.zip
wip
Diffstat (limited to 'src/api/endpoints')
-rw-r--r--src/api/endpoints/app/create.ts4
-rw-r--r--src/api/endpoints/app/show.ts4
-rw-r--r--src/api/endpoints/auth/session/show.ts4
-rw-r--r--src/api/endpoints/auth/session/userkey.ts4
-rw-r--r--src/api/endpoints/channels.ts4
-rw-r--r--src/api/endpoints/channels/create.ts4
-rw-r--r--src/api/endpoints/channels/posts.ts4
-rw-r--r--src/api/endpoints/channels/show.ts4
-rw-r--r--src/api/endpoints/drive/files.ts4
-rw-r--r--src/api/endpoints/drive/files/create.ts4
-rw-r--r--src/api/endpoints/drive/files/find.ts4
-rw-r--r--src/api/endpoints/drive/files/show.ts4
-rw-r--r--src/api/endpoints/drive/files/update.ts4
-rw-r--r--src/api/endpoints/drive/files/upload_from_url.ts4
-rw-r--r--src/api/endpoints/drive/folders.ts4
-rw-r--r--src/api/endpoints/drive/folders/create.ts4
-rw-r--r--src/api/endpoints/drive/folders/find.ts4
-rw-r--r--src/api/endpoints/drive/folders/show.ts4
-rw-r--r--src/api/endpoints/drive/folders/update.ts4
-rw-r--r--src/api/endpoints/drive/stream.ts4
-rw-r--r--src/api/endpoints/i.ts4
-rw-r--r--src/api/endpoints/i/authorized_apps.ts4
-rw-r--r--src/api/endpoints/i/favorites.ts4
-rw-r--r--src/api/endpoints/i/notifications.ts4
-rw-r--r--src/api/endpoints/i/pin.ts4
-rw-r--r--src/api/endpoints/i/signin_history.ts4
-rw-r--r--src/api/endpoints/i/update.ts4
-rw-r--r--src/api/endpoints/messaging/history.ts4
-rw-r--r--src/api/endpoints/messaging/messages.ts4
-rw-r--r--src/api/endpoints/messaging/messages/create.ts4
-rw-r--r--src/api/endpoints/mute/list.ts4
-rw-r--r--src/api/endpoints/my/apps.ts4
-rw-r--r--src/api/endpoints/posts.ts4
-rw-r--r--src/api/endpoints/posts/context.ts4
-rw-r--r--src/api/endpoints/posts/create.ts4
-rw-r--r--src/api/endpoints/posts/mentions.ts4
-rw-r--r--src/api/endpoints/posts/polls/recommendation.ts4
-rw-r--r--src/api/endpoints/posts/reactions.ts4
-rw-r--r--src/api/endpoints/posts/replies.ts4
-rw-r--r--src/api/endpoints/posts/reposts.ts4
-rw-r--r--src/api/endpoints/posts/search.ts4
-rw-r--r--src/api/endpoints/posts/show.ts4
-rw-r--r--src/api/endpoints/posts/timeline.ts4
-rw-r--r--src/api/endpoints/posts/trend.ts4
-rw-r--r--src/api/endpoints/users.ts4
-rw-r--r--src/api/endpoints/users/followers.ts4
-rw-r--r--src/api/endpoints/users/following.ts4
-rw-r--r--src/api/endpoints/users/get_frequently_replied_users.ts4
-rw-r--r--src/api/endpoints/users/posts.ts4
-rw-r--r--src/api/endpoints/users/recommendation.ts4
-rw-r--r--src/api/endpoints/users/search.ts4
-rw-r--r--src/api/endpoints/users/search_by_username.ts4
-rw-r--r--src/api/endpoints/users/show.ts4
53 files changed, 106 insertions, 106 deletions
diff --git a/src/api/endpoints/app/create.ts b/src/api/endpoints/app/create.ts
index ca684de02d..320163ebd9 100644
--- a/src/api/endpoints/app/create.ts
+++ b/src/api/endpoints/app/create.ts
@@ -5,7 +5,7 @@ import rndstr from 'rndstr';
import $ from 'cafy';
import App from '../../models/app';
import { isValidNameId } from '../../models/app';
-import serialize from '../../serializers/app';
+import { pack } from '../../models/app';
/**
* @swagger
@@ -106,5 +106,5 @@ module.exports = async (params, user) => new Promise(async (res, rej) => {
});
// Response
- res(await serialize(app));
+ res(await pack(app));
});
diff --git a/src/api/endpoints/app/show.ts b/src/api/endpoints/app/show.ts
index 054aab8596..a3ef24717d 100644
--- a/src/api/endpoints/app/show.ts
+++ b/src/api/endpoints/app/show.ts
@@ -3,7 +3,7 @@
*/
import $ from 'cafy';
import App from '../../models/app';
-import serialize from '../../serializers/app';
+import { pack } from '../../models/app';
/**
* @swagger
@@ -67,7 +67,7 @@ module.exports = (params, user, _, isSecure) => new Promise(async (res, rej) =>
}
// Send response
- res(await serialize(app, user, {
+ res(await pack(app, user, {
includeSecret: isSecure && app.user_id.equals(user._id)
}));
});
diff --git a/src/api/endpoints/auth/session/show.ts b/src/api/endpoints/auth/session/show.ts
index ede8a67634..1fe3b873fe 100644
--- a/src/api/endpoints/auth/session/show.ts
+++ b/src/api/endpoints/auth/session/show.ts
@@ -3,7 +3,7 @@
*/
import $ from 'cafy';
import AuthSess from '../../../models/auth-session';
-import serialize from '../../../serializers/auth-session';
+import { pack } from '../../../models/auth-session';
/**
* @swagger
@@ -67,5 +67,5 @@ module.exports = (params, user) => new Promise(async (res, rej) => {
}
// Response
- res(await serialize(session, user));
+ res(await pack(session, user));
});
diff --git a/src/api/endpoints/auth/session/userkey.ts b/src/api/endpoints/auth/session/userkey.ts
index afd3250b04..fc989bf8c2 100644
--- a/src/api/endpoints/auth/session/userkey.ts
+++ b/src/api/endpoints/auth/session/userkey.ts
@@ -5,7 +5,7 @@ import $ from 'cafy';
import App from '../../../models/app';
import AuthSess from '../../../models/auth-session';
import AccessToken from '../../../models/access-token';
-import serialize from '../../../serializers/user';
+import { pack } from '../../../models/user';
/**
* @swagger
@@ -102,7 +102,7 @@ module.exports = (params) => new Promise(async (res, rej) => {
// Response
res({
access_token: accessToken.token,
- user: await serialize(session.user_id, null, {
+ user: await pack(session.user_id, null, {
detail: true
})
});
diff --git a/src/api/endpoints/channels.ts b/src/api/endpoints/channels.ts
index 14817d9bd8..92dcee83db 100644
--- a/src/api/endpoints/channels.ts
+++ b/src/api/endpoints/channels.ts
@@ -3,7 +3,7 @@
*/
import $ from 'cafy';
import Channel from '../models/channel';
-import serialize from '../serializers/channel';
+import { pack } from '../models/channel';
/**
* Get all channels
@@ -55,5 +55,5 @@ module.exports = (params, me) => new Promise(async (res, rej) => {
// Serialize
res(await Promise.all(channels.map(async channel =>
- await serialize(channel, me))));
+ await pack(channel, me))));
});
diff --git a/src/api/endpoints/channels/create.ts b/src/api/endpoints/channels/create.ts
index a8d7c29dc1..695b4515b3 100644
--- a/src/api/endpoints/channels/create.ts
+++ b/src/api/endpoints/channels/create.ts
@@ -4,7 +4,7 @@
import $ from 'cafy';
import Channel from '../../models/channel';
import Watching from '../../models/channel-watching';
-import serialize from '../../serializers/channel';
+import { pack } from '../../models/channel';
/**
* Create a channel
@@ -28,7 +28,7 @@ module.exports = async (params, user) => new Promise(async (res, rej) => {
});
// Response
- res(await serialize(channel));
+ res(await pack(channel));
// Create Watching
await Watching.insert({
diff --git a/src/api/endpoints/channels/posts.ts b/src/api/endpoints/channels/posts.ts
index 9c2d607edb..3feee51f76 100644
--- a/src/api/endpoints/channels/posts.ts
+++ b/src/api/endpoints/channels/posts.ts
@@ -4,7 +4,7 @@
import $ from 'cafy';
import { default as Channel, IChannel } from '../../models/channel';
import Post from '../../models/post';
-import serialize from '../../serializers/post';
+import { pack } from '../../models/post';
/**
* Show a posts of a channel
@@ -74,6 +74,6 @@ module.exports = (params, user) => new Promise(async (res, rej) => {
// Serialize
res(await Promise.all(posts.map(async (post) =>
- await serialize(post, user)
+ await pack(post, user)
)));
});
diff --git a/src/api/endpoints/channels/show.ts b/src/api/endpoints/channels/show.ts
index 8861e54594..89c48379a4 100644
--- a/src/api/endpoints/channels/show.ts
+++ b/src/api/endpoints/channels/show.ts
@@ -3,7 +3,7 @@
*/
import $ from 'cafy';
import { default as Channel, IChannel } from '../../models/channel';
-import serialize from '../../serializers/channel';
+import { pack } from '../../models/channel';
/**
* Show a channel
@@ -27,5 +27,5 @@ module.exports = (params, user) => new Promise(async (res, rej) => {
}
// Serialize
- res(await serialize(channel, user));
+ res(await pack(channel, user));
});
diff --git a/src/api/endpoints/drive/files.ts b/src/api/endpoints/drive/files.ts
index 3d5f81339a..3bd80e7282 100644
--- a/src/api/endpoints/drive/files.ts
+++ b/src/api/endpoints/drive/files.ts
@@ -3,7 +3,7 @@
*/
import $ from 'cafy';
import DriveFile from '../../models/drive-file';
-import serialize from '../../serializers/drive-file';
+import { pack } from '../../models/drive-file';
/**
* Get drive files
@@ -69,6 +69,6 @@ module.exports = async (params, user, app) => {
});
// Serialize
- const _files = await Promise.all(files.map(file => serialize(file)));
+ const _files = await Promise.all(files.map(file => pack(file)));
return _files;
};
diff --git a/src/api/endpoints/drive/files/create.ts b/src/api/endpoints/drive/files/create.ts
index 437348a1ef..6fa76d7e95 100644
--- a/src/api/endpoints/drive/files/create.ts
+++ b/src/api/endpoints/drive/files/create.ts
@@ -3,7 +3,7 @@
*/
import $ from 'cafy';
import { validateFileName } from '../../../models/drive-file';
-import serialize from '../../../serializers/drive-file';
+import { pack } from '../../../models/drive-file';
import create from '../../../common/add-file-to-drive';
/**
@@ -43,7 +43,7 @@ module.exports = async (file, params, user): Promise<any> => {
const driveFile = await create(user, file.path, name, null, folderId);
// Serialize
- return serialize(driveFile);
+ return pack(driveFile);
} catch (e) {
console.error(e);
diff --git a/src/api/endpoints/drive/files/find.ts b/src/api/endpoints/drive/files/find.ts
index a1cdf1643e..571aba81f4 100644
--- a/src/api/endpoints/drive/files/find.ts
+++ b/src/api/endpoints/drive/files/find.ts
@@ -3,7 +3,7 @@
*/
import $ from 'cafy';
import DriveFile from '../../../models/drive-file';
-import serialize from '../../../serializers/drive-file';
+import { pack } from '../../../models/drive-file';
/**
* Find a file(s)
@@ -31,5 +31,5 @@ module.exports = (params, user) => new Promise(async (res, rej) => {
// Serialize
res(await Promise.all(files.map(async file =>
- await serialize(file))));
+ await pack(file))));
});
diff --git a/src/api/endpoints/drive/files/show.ts b/src/api/endpoints/drive/files/show.ts
index 3c7cf774f9..00f69f1415 100644
--- a/src/api/endpoints/drive/files/show.ts
+++ b/src/api/endpoints/drive/files/show.ts
@@ -3,7 +3,7 @@
*/
import $ from 'cafy';
import DriveFile from '../../../models/drive-file';
-import serialize from '../../../serializers/drive-file';
+import { pack } from '../../../models/drive-file';
/**
* Show a file
@@ -29,7 +29,7 @@ module.exports = async (params, user) => {
}
// Serialize
- const _file = await serialize(file, {
+ const _file = await pack(file, {
detail: true
});
diff --git a/src/api/endpoints/drive/files/update.ts b/src/api/endpoints/drive/files/update.ts
index f39a420d6e..9ef8215b1a 100644
--- a/src/api/endpoints/drive/files/update.ts
+++ b/src/api/endpoints/drive/files/update.ts
@@ -5,7 +5,7 @@ import $ from 'cafy';
import DriveFolder from '../../../models/drive-folder';
import DriveFile from '../../../models/drive-file';
import { validateFileName } from '../../../models/drive-file';
-import serialize from '../../../serializers/drive-file';
+import { pack } from '../../../models/drive-file';
import { publishDriveStream } from '../../../event';
/**
@@ -67,7 +67,7 @@ module.exports = (params, user) => new Promise(async (res, rej) => {
});
// Serialize
- const fileObj = await serialize(file);
+ const fileObj = await pack(file);
// Response
res(fileObj);
diff --git a/src/api/endpoints/drive/files/upload_from_url.ts b/src/api/endpoints/drive/files/upload_from_url.ts
index 519e0bdf65..f0398bfc5d 100644
--- a/src/api/endpoints/drive/files/upload_from_url.ts
+++ b/src/api/endpoints/drive/files/upload_from_url.ts
@@ -4,7 +4,7 @@
import * as URL from 'url';
import $ from 'cafy';
import { validateFileName } from '../../../models/drive-file';
-import serialize from '../../../serializers/drive-file';
+import { pack } from '../../../models/drive-file';
import create from '../../../common/add-file-to-drive';
import * as debug from 'debug';
import * as tmp from 'tmp';
@@ -63,5 +63,5 @@ module.exports = async (params, user): Promise<any> => {
if (e) log(e.stack);
});
- return serialize(driveFile);
+ return pack(driveFile);
};
diff --git a/src/api/endpoints/drive/folders.ts b/src/api/endpoints/drive/folders.ts
index 7944e2c6a6..e650fb74aa 100644
--- a/src/api/endpoints/drive/folders.ts
+++ b/src/api/endpoints/drive/folders.ts
@@ -3,7 +3,7 @@
*/
import $ from 'cafy';
import DriveFolder from '../../models/drive-folder';
-import serialize from '../../serializers/drive-folder';
+import { pack } from '../../models/drive-folder';
/**
* Get drive folders
@@ -63,5 +63,5 @@ module.exports = (params, user, app) => new Promise(async (res, rej) => {
// Serialize
res(await Promise.all(folders.map(async folder =>
- await serialize(folder))));
+ await pack(folder))));
});
diff --git a/src/api/endpoints/drive/folders/create.ts b/src/api/endpoints/drive/folders/create.ts
index be847b2153..1953c09ee0 100644
--- a/src/api/endpoints/drive/folders/create.ts
+++ b/src/api/endpoints/drive/folders/create.ts
@@ -4,7 +4,7 @@
import $ from 'cafy';
import DriveFolder from '../../../models/drive-folder';
import { isValidFolderName } from '../../../models/drive-folder';
-import serialize from '../../../serializers/drive-folder';
+import { pack } from '../../../models/drive-folder';
import { publishDriveStream } from '../../../event';
/**
@@ -47,7 +47,7 @@ module.exports = (params, user) => new Promise(async (res, rej) => {
});
// Serialize
- const folderObj = await serialize(folder);
+ const folderObj = await pack(folder);
// Response
res(folderObj);
diff --git a/src/api/endpoints/drive/folders/find.ts b/src/api/endpoints/drive/folders/find.ts
index a5eb8e015d..caad45d740 100644
--- a/src/api/endpoints/drive/folders/find.ts
+++ b/src/api/endpoints/drive/folders/find.ts
@@ -3,7 +3,7 @@
*/
import $ from 'cafy';
import DriveFolder from '../../../models/drive-folder';
-import serialize from '../../../serializers/drive-folder';
+import { pack } from '../../../models/drive-folder';
/**
* Find a folder(s)
@@ -30,5 +30,5 @@ module.exports = (params, user) => new Promise(async (res, rej) => {
});
// Serialize
- res(await Promise.all(folders.map(folder => serialize(folder))));
+ res(await Promise.all(folders.map(folder => pack(folder))));
});
diff --git a/src/api/endpoints/drive/folders/show.ts b/src/api/endpoints/drive/folders/show.ts
index 9b1c04ca3c..fd3061ca54 100644
--- a/src/api/endpoints/drive/folders/show.ts
+++ b/src/api/endpoints/drive/folders/show.ts
@@ -3,7 +3,7 @@
*/
import $ from 'cafy';
import DriveFolder from '../../../models/drive-folder';
-import serialize from '../../../serializers/drive-folder';
+import { pack } from '../../../models/drive-folder';
/**
* Show a folder
@@ -29,7 +29,7 @@ module.exports = (params, user) => new Promise(async (res, rej) => {
}
// Serialize
- res(await serialize(folder, {
+ res(await pack(folder, {
detail: true
}));
});
diff --git a/src/api/endpoints/drive/folders/update.ts b/src/api/endpoints/drive/folders/update.ts
index ff673402ab..8f50a9d009 100644
--- a/src/api/endpoints/drive/folders/update.ts
+++ b/src/api/endpoints/drive/folders/update.ts
@@ -4,7 +4,7 @@
import $ from 'cafy';
import DriveFolder from '../../../models/drive-folder';
import { isValidFolderName } from '../../../models/drive-folder';
-import serialize from '../../../serializers/drive-folder';
+import { pack } from '../../../models/drive-folder';
import { publishDriveStream } from '../../../event';
/**
@@ -91,7 +91,7 @@ module.exports = (params, user) => new Promise(async (res, rej) => {
});
// Serialize
- const folderObj = await serialize(folder);
+ const folderObj = await pack(folder);
// Response
res(folderObj);
diff --git a/src/api/endpoints/drive/stream.ts b/src/api/endpoints/drive/stream.ts
index 5b0eb0a0d8..3527d70500 100644
--- a/src/api/endpoints/drive/stream.ts
+++ b/src/api/endpoints/drive/stream.ts
@@ -3,7 +3,7 @@
*/
import $ from 'cafy';
import DriveFile from '../../models/drive-file';
-import serialize from '../../serializers/drive-file';
+import { pack } from '../../models/drive-file';
/**
* Get drive stream
@@ -64,5 +64,5 @@ module.exports = (params, user) => new Promise(async (res, rej) => {
// Serialize
res(await Promise.all(files.map(async file =>
- await serialize(file))));
+ await pack(file))));
});
diff --git a/src/api/endpoints/i.ts b/src/api/endpoints/i.ts
index ae75f11d54..1b6c1e58de 100644
--- a/src/api/endpoints/i.ts
+++ b/src/api/endpoints/i.ts
@@ -2,7 +2,7 @@
* Module dependencies
*/
import User from '../models/user';
-import serialize from '../serializers/user';
+import { pack } from '../models/user';
/**
* Show myself
@@ -15,7 +15,7 @@ import serialize from '../serializers/user';
*/
module.exports = (params, user, _, isSecure) => new Promise(async (res, rej) => {
// Serialize
- res(await serialize(user, user, {
+ res(await pack(user, user, {
detail: true,
includeSecrets: isSecure
}));
diff --git a/src/api/endpoints/i/authorized_apps.ts b/src/api/endpoints/i/authorized_apps.ts
index 807ca5b1e7..40ce7a68c8 100644
--- a/src/api/endpoints/i/authorized_apps.ts
+++ b/src/api/endpoints/i/authorized_apps.ts
@@ -3,7 +3,7 @@
*/
import $ from 'cafy';
import AccessToken from '../../models/access-token';
-import serialize from '../../serializers/app';
+import { pack } from '../../models/app';
/**
* Get authorized apps of my account
@@ -39,5 +39,5 @@ module.exports = (params, user) => new Promise(async (res, rej) => {
// Serialize
res(await Promise.all(tokens.map(async token =>
- await serialize(token.app_id))));
+ await pack(token.app_id))));
});
diff --git a/src/api/endpoints/i/favorites.ts b/src/api/endpoints/i/favorites.ts
index a66eaa7546..eb464cf0f0 100644
--- a/src/api/endpoints/i/favorites.ts
+++ b/src/api/endpoints/i/favorites.ts
@@ -3,7 +3,7 @@
*/
import $ from 'cafy';
import Favorite from '../../models/favorite';
-import serialize from '../../serializers/post';
+import { pack } from '../../models/post';
/**
* Get followers of a user
@@ -39,6 +39,6 @@ module.exports = (params, user) => new Promise(async (res, rej) => {
// Serialize
res(await Promise.all(favorites.map(async favorite =>
- await serialize(favorite.post)
+ await pack(favorite.post)
)));
});
diff --git a/src/api/endpoints/i/notifications.ts b/src/api/endpoints/i/notifications.ts
index fb9be7f61b..688039a0dd 100644
--- a/src/api/endpoints/i/notifications.ts
+++ b/src/api/endpoints/i/notifications.ts
@@ -4,7 +4,7 @@
import $ from 'cafy';
import Notification from '../../models/notification';
import Mute from '../../models/mute';
-import serialize from '../../serializers/notification';
+import { pack } from '../../models/notification';
import getFriends from '../../common/get-friends';
import read from '../../common/read-notification';
@@ -101,7 +101,7 @@ module.exports = (params, user) => new Promise(async (res, rej) => {
// Serialize
res(await Promise.all(notifications.map(async notification =>
- await serialize(notification))));
+ await pack(notification))));
// Mark as read all
if (notifications.length > 0 && markAsRead) {
diff --git a/src/api/endpoints/i/pin.ts b/src/api/endpoints/i/pin.ts
index a94950d22b..ff546fc2bd 100644
--- a/src/api/endpoints/i/pin.ts
+++ b/src/api/endpoints/i/pin.ts
@@ -4,7 +4,7 @@
import $ from 'cafy';
import User from '../../models/user';
import Post from '../../models/post';
-import serialize from '../../serializers/user';
+import { pack } from '../../models/user';
/**
* Pin post
@@ -35,7 +35,7 @@ module.exports = async (params, user) => new Promise(async (res, rej) => {
});
// Serialize
- const iObj = await serialize(user, user, {
+ const iObj = await pack(user, user, {
detail: true
});
diff --git a/src/api/endpoints/i/signin_history.ts b/src/api/endpoints/i/signin_history.ts
index e38bfa4d98..3ab59b694d 100644
--- a/src/api/endpoints/i/signin_history.ts
+++ b/src/api/endpoints/i/signin_history.ts
@@ -3,7 +3,7 @@
*/
import $ from 'cafy';
import Signin from '../../models/signin';
-import serialize from '../../serializers/signin';
+import { pack } from '../../models/signin';
/**
* Get signin history of my account
@@ -58,5 +58,5 @@ module.exports = (params, user) => new Promise(async (res, rej) => {
// Serialize
res(await Promise.all(history.map(async record =>
- await serialize(record))));
+ await pack(record))));
});
diff --git a/src/api/endpoints/i/update.ts b/src/api/endpoints/i/update.ts
index c484c51a96..a138832e54 100644
--- a/src/api/endpoints/i/update.ts
+++ b/src/api/endpoints/i/update.ts
@@ -4,7 +4,7 @@
import $ from 'cafy';
import User from '../../models/user';
import { isValidName, isValidDescription, isValidLocation, isValidBirthday } from '../../models/user';
-import serialize from '../../serializers/user';
+import { pack } from '../../models/user';
import event from '../../event';
import config from '../../../conf';
@@ -65,7 +65,7 @@ module.exports = async (params, user, _, isSecure) => new Promise(async (res, re
});
// Serialize
- const iObj = await serialize(user, user, {
+ const iObj = await pack(user, user, {
detail: true,
includeSecrets: isSecure
});
diff --git a/src/api/endpoints/messaging/history.ts b/src/api/endpoints/messaging/history.ts
index f14740dff5..1683ca7a89 100644
--- a/src/api/endpoints/messaging/history.ts
+++ b/src/api/endpoints/messaging/history.ts
@@ -4,7 +4,7 @@
import $ from 'cafy';
import History from '../../models/messaging-history';
import Mute from '../../models/mute';
-import serialize from '../../serializers/messaging-message';
+import { pack } from '../../models/messaging-message';
/**
* Show messaging history
@@ -39,5 +39,5 @@ module.exports = (params, user) => new Promise(async (res, rej) => {
// Serialize
res(await Promise.all(history.map(async h =>
- await serialize(h.message, user))));
+ await pack(h.message, user))));
});
diff --git a/src/api/endpoints/messaging/messages.ts b/src/api/endpoints/messaging/messages.ts
index 3d3c6950a1..67ba5e9d6d 100644
--- a/src/api/endpoints/messaging/messages.ts
+++ b/src/api/endpoints/messaging/messages.ts
@@ -4,7 +4,7 @@
import $ from 'cafy';
import Message from '../../models/messaging-message';
import User from '../../models/user';
-import serialize from '../../serializers/messaging-message';
+import { pack } from '../../models/messaging-message';
import read from '../../common/read-messaging-message';
/**
@@ -87,7 +87,7 @@ module.exports = (params, user) => new Promise(async (res, rej) => {
// Serialize
res(await Promise.all(messages.map(async message =>
- await serialize(message, user, {
+ await pack(message, user, {
populateRecipient: false
}))));
diff --git a/src/api/endpoints/messaging/messages/create.ts b/src/api/endpoints/messaging/messages/create.ts
index 4e9d10197c..1b8a5f59e6 100644
--- a/src/api/endpoints/messaging/messages/create.ts
+++ b/src/api/endpoints/messaging/messages/create.ts
@@ -8,7 +8,7 @@ import History from '../../../models/messaging-history';
import User from '../../../models/user';
import Mute from '../../../models/mute';
import DriveFile from '../../../models/drive-file';
-import serialize from '../../../serializers/messaging-message';
+import { pack } from '../../../models/messaging-message';
import publishUserStream from '../../../event';
import { publishMessagingStream, publishMessagingIndexStream, pushSw } from '../../../event';
import config from '../../../../conf';
@@ -79,7 +79,7 @@ module.exports = (params, user) => new Promise(async (res, rej) => {
});
// Serialize
- const messageObj = await serialize(message);
+ const messageObj = await pack(message);
// Reponse
res(messageObj);
diff --git a/src/api/endpoints/mute/list.ts b/src/api/endpoints/mute/list.ts
index 740e19f0bb..19e3b157e6 100644
--- a/src/api/endpoints/mute/list.ts
+++ b/src/api/endpoints/mute/list.ts
@@ -3,7 +3,7 @@
*/
import $ from 'cafy';
import Mute from '../../models/mute';
-import serialize from '../../serializers/user';
+import { pack } from '../../models/user';
import getFriends from '../../common/get-friends';
/**
@@ -63,7 +63,7 @@ module.exports = (params, me) => new Promise(async (res, rej) => {
// Serialize
const users = await Promise.all(mutes.map(async m =>
- await serialize(m.mutee_id, me, { detail: true })));
+ await pack(m.mutee_id, me, { detail: true })));
// Response
res({
diff --git a/src/api/endpoints/my/apps.ts b/src/api/endpoints/my/apps.ts
index eb9c758768..fe583db86a 100644
--- a/src/api/endpoints/my/apps.ts
+++ b/src/api/endpoints/my/apps.ts
@@ -3,7 +3,7 @@
*/
import $ from 'cafy';
import App from '../../models/app';
-import serialize from '../../serializers/app';
+import { pack } from '../../models/app';
/**
* Get my apps
@@ -37,5 +37,5 @@ module.exports = (params, user) => new Promise(async (res, rej) => {
// Reply
res(await Promise.all(apps.map(async app =>
- await serialize(app))));
+ await pack(app))));
});
diff --git a/src/api/endpoints/posts.ts b/src/api/endpoints/posts.ts
index db166cd67a..d10c6ab408 100644
--- a/src/api/endpoints/posts.ts
+++ b/src/api/endpoints/posts.ts
@@ -3,7 +3,7 @@
*/
import $ from 'cafy';
import Post from '../models/post';
-import serialize from '../serializers/post';
+import { pack } from '../models/post';
/**
* Lists all posts
@@ -85,5 +85,5 @@ module.exports = (params) => new Promise(async (res, rej) => {
});
// Serialize
- res(await Promise.all(posts.map(async post => await serialize(post))));
+ res(await Promise.all(posts.map(async post => await pack(post))));
});
diff --git a/src/api/endpoints/posts/context.ts b/src/api/endpoints/posts/context.ts
index bad59a6bee..3051e7af17 100644
--- a/src/api/endpoints/posts/context.ts
+++ b/src/api/endpoints/posts/context.ts
@@ -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))));
});
diff --git a/src/api/endpoints/posts/create.ts b/src/api/endpoints/posts/create.ts
index a1d05c67c6..0fa52221f9 100644
--- a/src/api/endpoints/posts/create.ts
+++ b/src/api/endpoints/posts/create.ts
@@ -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({
diff --git a/src/api/endpoints/posts/mentions.ts b/src/api/endpoints/posts/mentions.ts
index 3bb4ec3fa0..7127db0ad1 100644
--- a/src/api/endpoints/posts/mentions.ts
+++ b/src/api/endpoints/posts/mentions.ts
@@ -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)
)));
});
diff --git a/src/api/endpoints/posts/polls/recommendation.ts b/src/api/endpoints/posts/polls/recommendation.ts
index 9c92d6cac4..5ccb754496 100644
--- a/src/api/endpoints/posts/polls/recommendation.ts
+++ b/src/api/endpoints/posts/polls/recommendation.ts
@@ -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 }))));
});
diff --git a/src/api/endpoints/posts/reactions.ts b/src/api/endpoints/posts/reactions.ts
index eab5d9b258..f60334df8a 100644
--- a/src/api/endpoints/posts/reactions.ts
+++ b/src/api/endpoints/posts/reactions.ts
@@ -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))));
});
diff --git a/src/api/endpoints/posts/replies.ts b/src/api/endpoints/posts/replies.ts
index 3fd6a46769..1442b8a4c5 100644
--- a/src/api/endpoints/posts/replies.ts
+++ b/src/api/endpoints/posts/replies.ts
@@ -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))));
});
diff --git a/src/api/endpoints/posts/reposts.ts b/src/api/endpoints/posts/reposts.ts
index bcc6163a11..0fbb0687b9 100644
--- a/src/api/endpoints/posts/reposts.ts
+++ b/src/api/endpoints/posts/reposts.ts
@@ -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))));
});
diff --git a/src/api/endpoints/posts/search.ts b/src/api/endpoints/posts/search.ts
index 31c9a8d3c8..6e26f55390 100644
--- a/src/api/endpoints/posts/search.ts
+++ b/src/api/endpoints/posts/search.ts
@@ -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))));
}
diff --git a/src/api/endpoints/posts/show.ts b/src/api/endpoints/posts/show.ts
index 5bfe4f6605..c312449710 100644
--- a/src/api/endpoints/posts/show.ts
+++ b/src/api/endpoints/posts/show.ts
@@ -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
}));
});
diff --git a/src/api/endpoints/posts/timeline.ts b/src/api/endpoints/posts/timeline.ts
index da7ffd0c14..c41cfdb8bd 100644
--- a/src/api/endpoints/posts/timeline.ts
+++ b/src/api/endpoints/posts/timeline.ts
@@ -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)));
};
diff --git a/src/api/endpoints/posts/trend.ts b/src/api/endpoints/posts/trend.ts
index 64a195dff1..b2b1d327a8 100644
--- a/src/api/endpoints/posts/trend.ts
+++ b/src/api/endpoints/posts/trend.ts
@@ -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 }))));
});
diff --git a/src/api/endpoints/users.ts b/src/api/endpoints/users.ts
index f3c9b66a5e..ba33b1aeb7 100644
--- a/src/api/endpoints/users.ts
+++ b/src/api/endpoints/users.ts
@@ -3,7 +3,7 @@
*/
import $ from 'cafy';
import User from '../models/user';
-import serialize from '../serializers/user';
+import { pack } from '../models/user';
/**
* Lists all users
@@ -55,5 +55,5 @@ module.exports = (params, me) => new Promise(async (res, rej) => {
// Serialize
res(await Promise.all(users.map(async user =>
- await serialize(user, me))));
+ await pack(user, me))));
});
diff --git a/src/api/endpoints/users/followers.ts b/src/api/endpoints/users/followers.ts
index 4905323ba5..b0fb83c683 100644
--- a/src/api/endpoints/users/followers.ts
+++ b/src/api/endpoints/users/followers.ts
@@ -4,7 +4,7 @@
import $ from 'cafy';
import User from '../../models/user';
import Following from '../../models/following';
-import serialize from '../../serializers/user';
+import { pack } from '../../models/user';
import getFriends from '../../common/get-friends';
/**
@@ -82,7 +82,7 @@ module.exports = (params, me) => new Promise(async (res, rej) => {
// Serialize
const users = await Promise.all(following.map(async f =>
- await serialize(f.follower_id, me, { detail: true })));
+ await pack(f.follower_id, me, { detail: true })));
// Response
res({
diff --git a/src/api/endpoints/users/following.ts b/src/api/endpoints/users/following.ts
index dc2ff49bbe..8e88431e92 100644
--- a/src/api/endpoints/users/following.ts
+++ b/src/api/endpoints/users/following.ts
@@ -4,7 +4,7 @@
import $ from 'cafy';
import User from '../../models/user';
import Following from '../../models/following';
-import serialize from '../../serializers/user';
+import { pack } from '../../models/user';
import getFriends from '../../common/get-friends';
/**
@@ -82,7 +82,7 @@ module.exports = (params, me) => new Promise(async (res, rej) => {
// Serialize
const users = await Promise.all(following.map(async f =>
- await serialize(f.followee_id, me, { detail: true })));
+ await pack(f.followee_id, me, { detail: true })));
// Response
res({
diff --git a/src/api/endpoints/users/get_frequently_replied_users.ts b/src/api/endpoints/users/get_frequently_replied_users.ts
index a8add623d4..3cbc761322 100644
--- a/src/api/endpoints/users/get_frequently_replied_users.ts
+++ b/src/api/endpoints/users/get_frequently_replied_users.ts
@@ -4,7 +4,7 @@
import $ from 'cafy';
import Post from '../../models/post';
import User from '../../models/user';
-import serialize from '../../serializers/user';
+import { pack } from '../../models/user';
module.exports = (params, me) => new Promise(async (res, rej) => {
// Get 'user_id' parameter
@@ -91,7 +91,7 @@ module.exports = (params, me) => new Promise(async (res, rej) => {
// Make replies object (includes weights)
const repliesObj = await Promise.all(topRepliedUsers.map(async (user) => ({
- user: await serialize(user, me, { detail: true }),
+ user: await pack(user, me, { detail: true }),
weight: repliedUsers[user] / peak
})));
diff --git a/src/api/endpoints/users/posts.ts b/src/api/endpoints/users/posts.ts
index 0d8384a43d..1f3db3cf79 100644
--- a/src/api/endpoints/users/posts.ts
+++ b/src/api/endpoints/users/posts.ts
@@ -4,7 +4,7 @@
import $ from 'cafy';
import Post from '../../models/post';
import User from '../../models/user';
-import serialize from '../../serializers/post';
+import { pack } from '../../models/post';
/**
* Get posts of a user
@@ -124,6 +124,6 @@ module.exports = (params, me) => new Promise(async (res, rej) => {
// Serialize
res(await Promise.all(posts.map(async (post) =>
- await serialize(post, me)
+ await pack(post, me)
)));
});
diff --git a/src/api/endpoints/users/recommendation.ts b/src/api/endpoints/users/recommendation.ts
index 731d68a7b1..b80fd63ce7 100644
--- a/src/api/endpoints/users/recommendation.ts
+++ b/src/api/endpoints/users/recommendation.ts
@@ -4,7 +4,7 @@
const ms = require('ms');
import $ from 'cafy';
import User from '../../models/user';
-import serialize from '../../serializers/user';
+import { pack } from '../../models/user';
import getFriends from '../../common/get-friends';
/**
@@ -44,5 +44,5 @@ module.exports = (params, me) => new Promise(async (res, rej) => {
// Serialize
res(await Promise.all(users.map(async user =>
- await serialize(user, me, { detail: true }))));
+ await pack(user, me, { detail: true }))));
});
diff --git a/src/api/endpoints/users/search.ts b/src/api/endpoints/users/search.ts
index 73a5db47e2..213038403b 100644
--- a/src/api/endpoints/users/search.ts
+++ b/src/api/endpoints/users/search.ts
@@ -4,7 +4,7 @@
import * as mongo from 'mongodb';
import $ from 'cafy';
import User from '../../models/user';
-import serialize from '../../serializers/user';
+import { pack } from '../../models/user';
import config from '../../../conf';
const escapeRegexp = require('escape-regexp');
@@ -94,6 +94,6 @@ async function byElasticsearch(res, rej, me, query, offset, max) {
// Serialize
res(await Promise.all(users.map(async user =>
- await serialize(user, me, { detail: true }))));
+ await pack(user, me, { detail: true }))));
});
}
diff --git a/src/api/endpoints/users/search_by_username.ts b/src/api/endpoints/users/search_by_username.ts
index 7f2f42f0a6..63e206b1f2 100644
--- a/src/api/endpoints/users/search_by_username.ts
+++ b/src/api/endpoints/users/search_by_username.ts
@@ -3,7 +3,7 @@
*/
import $ from 'cafy';
import User from '../../models/user';
-import serialize from '../../serializers/user';
+import { pack } from '../../models/user';
/**
* Search a user by username
@@ -35,5 +35,5 @@ module.exports = (params, me) => new Promise(async (res, rej) => {
// Serialize
res(await Promise.all(users.map(async user =>
- await serialize(user, me, { detail: true }))));
+ await pack(user, me, { detail: true }))));
});
diff --git a/src/api/endpoints/users/show.ts b/src/api/endpoints/users/show.ts
index 8e74b0fe3f..a51cb619d4 100644
--- a/src/api/endpoints/users/show.ts
+++ b/src/api/endpoints/users/show.ts
@@ -3,7 +3,7 @@
*/
import $ from 'cafy';
import User from '../../models/user';
-import serialize from '../../serializers/user';
+import { pack } from '../../models/user';
/**
* Show a user
@@ -41,7 +41,7 @@ module.exports = (params, me) => new Promise(async (res, rej) => {
}
// Send response
- res(await serialize(user, me, {
+ res(await pack(user, me, {
detail: true
}));
});