mirror of
https://iceshrimp.dev/limepotato/jormungandr-bite.git
synced 2024-11-27 04:17:51 -07:00
wip
This commit is contained in:
parent
2f645d59db
commit
8462a74938
61 changed files with 132 additions and 119 deletions
|
@ -12,7 +12,7 @@ import prominence = require('prominence');
|
||||||
|
|
||||||
import DriveFile, { getGridFSBucket } from '../models/drive-file';
|
import DriveFile, { getGridFSBucket } from '../models/drive-file';
|
||||||
import DriveFolder from '../models/drive-folder';
|
import DriveFolder from '../models/drive-folder';
|
||||||
import serialize from '../serializers/drive-file';
|
import { pack } from '../models/drive-file';
|
||||||
import event, { publishDriveStream } from '../event';
|
import event, { publishDriveStream } from '../event';
|
||||||
import config from '../../conf';
|
import config from '../../conf';
|
||||||
|
|
||||||
|
@ -282,7 +282,7 @@ export default (user: any, file: string | stream.Readable, ...args) => new Promi
|
||||||
log(`drive file has been created ${file._id}`);
|
log(`drive file has been created ${file._id}`);
|
||||||
resolve(file);
|
resolve(file);
|
||||||
|
|
||||||
serialize(file).then(serializedFile => {
|
pack(file).then(serializedFile => {
|
||||||
// Publish drive_file_created event
|
// Publish drive_file_created event
|
||||||
event(user._id, 'drive_file_created', serializedFile);
|
event(user._id, 'drive_file_created', serializedFile);
|
||||||
publishDriveStream(user._id, 'file_created', serializedFile);
|
publishDriveStream(user._id, 'file_created', serializedFile);
|
||||||
|
|
|
@ -2,7 +2,7 @@ import * as mongo from 'mongodb';
|
||||||
import Notification from '../models/notification';
|
import Notification from '../models/notification';
|
||||||
import Mute from '../models/mute';
|
import Mute from '../models/mute';
|
||||||
import event from '../event';
|
import event from '../event';
|
||||||
import serialize from '../serializers/notification';
|
import { pack } from '../models/notification';
|
||||||
|
|
||||||
export default (
|
export default (
|
||||||
notifiee: mongo.ObjectID,
|
notifiee: mongo.ObjectID,
|
||||||
|
@ -27,7 +27,7 @@ export default (
|
||||||
|
|
||||||
// Publish notification event
|
// Publish notification event
|
||||||
event(notifiee, 'notification',
|
event(notifiee, 'notification',
|
||||||
await serialize(notification));
|
await pack(notification));
|
||||||
|
|
||||||
// 3秒経っても(今回作成した)通知が既読にならなかったら「未読の通知がありますよ」イベントを発行する
|
// 3秒経っても(今回作成した)通知が既読にならなかったら「未読の通知がありますよ」イベントを発行する
|
||||||
setTimeout(async () => {
|
setTimeout(async () => {
|
||||||
|
@ -44,7 +44,7 @@ export default (
|
||||||
}
|
}
|
||||||
//#endregion
|
//#endregion
|
||||||
|
|
||||||
event(notifiee, 'unread_notification', await serialize(notification));
|
event(notifiee, 'unread_notification', await pack(notification));
|
||||||
}
|
}
|
||||||
}, 3000);
|
}, 3000);
|
||||||
});
|
});
|
||||||
|
|
|
@ -5,7 +5,7 @@ import rndstr from 'rndstr';
|
||||||
import $ from 'cafy';
|
import $ from 'cafy';
|
||||||
import App from '../../models/app';
|
import App from '../../models/app';
|
||||||
import { isValidNameId } from '../../models/app';
|
import { isValidNameId } from '../../models/app';
|
||||||
import serialize from '../../serializers/app';
|
import { pack } from '../../models/app';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @swagger
|
* @swagger
|
||||||
|
@ -106,5 +106,5 @@ module.exports = async (params, user) => new Promise(async (res, rej) => {
|
||||||
});
|
});
|
||||||
|
|
||||||
// Response
|
// Response
|
||||||
res(await serialize(app));
|
res(await pack(app));
|
||||||
});
|
});
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
*/
|
*/
|
||||||
import $ from 'cafy';
|
import $ from 'cafy';
|
||||||
import App from '../../models/app';
|
import App from '../../models/app';
|
||||||
import serialize from '../../serializers/app';
|
import { pack } from '../../models/app';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @swagger
|
* @swagger
|
||||||
|
@ -67,7 +67,7 @@ module.exports = (params, user, _, isSecure) => new Promise(async (res, rej) =>
|
||||||
}
|
}
|
||||||
|
|
||||||
// Send response
|
// Send response
|
||||||
res(await serialize(app, user, {
|
res(await pack(app, user, {
|
||||||
includeSecret: isSecure && app.user_id.equals(user._id)
|
includeSecret: isSecure && app.user_id.equals(user._id)
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
*/
|
*/
|
||||||
import $ from 'cafy';
|
import $ from 'cafy';
|
||||||
import AuthSess from '../../../models/auth-session';
|
import AuthSess from '../../../models/auth-session';
|
||||||
import serialize from '../../../serializers/auth-session';
|
import { pack } from '../../../models/auth-session';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @swagger
|
* @swagger
|
||||||
|
@ -67,5 +67,5 @@ module.exports = (params, user) => new Promise(async (res, rej) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Response
|
// Response
|
||||||
res(await serialize(session, user));
|
res(await pack(session, user));
|
||||||
});
|
});
|
||||||
|
|
|
@ -5,7 +5,7 @@ import $ from 'cafy';
|
||||||
import App from '../../../models/app';
|
import App from '../../../models/app';
|
||||||
import AuthSess from '../../../models/auth-session';
|
import AuthSess from '../../../models/auth-session';
|
||||||
import AccessToken from '../../../models/access-token';
|
import AccessToken from '../../../models/access-token';
|
||||||
import serialize from '../../../serializers/user';
|
import { pack } from '../../../models/user';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @swagger
|
* @swagger
|
||||||
|
@ -102,7 +102,7 @@ module.exports = (params) => new Promise(async (res, rej) => {
|
||||||
// Response
|
// Response
|
||||||
res({
|
res({
|
||||||
access_token: accessToken.token,
|
access_token: accessToken.token,
|
||||||
user: await serialize(session.user_id, null, {
|
user: await pack(session.user_id, null, {
|
||||||
detail: true
|
detail: true
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
*/
|
*/
|
||||||
import $ from 'cafy';
|
import $ from 'cafy';
|
||||||
import Channel from '../models/channel';
|
import Channel from '../models/channel';
|
||||||
import serialize from '../serializers/channel';
|
import { pack } from '../models/channel';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get all channels
|
* Get all channels
|
||||||
|
@ -55,5 +55,5 @@ module.exports = (params, me) => new Promise(async (res, rej) => {
|
||||||
|
|
||||||
// Serialize
|
// Serialize
|
||||||
res(await Promise.all(channels.map(async channel =>
|
res(await Promise.all(channels.map(async channel =>
|
||||||
await serialize(channel, me))));
|
await pack(channel, me))));
|
||||||
});
|
});
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
import $ from 'cafy';
|
import $ from 'cafy';
|
||||||
import Channel from '../../models/channel';
|
import Channel from '../../models/channel';
|
||||||
import Watching from '../../models/channel-watching';
|
import Watching from '../../models/channel-watching';
|
||||||
import serialize from '../../serializers/channel';
|
import { pack } from '../../models/channel';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a channel
|
* Create a channel
|
||||||
|
@ -28,7 +28,7 @@ module.exports = async (params, user) => new Promise(async (res, rej) => {
|
||||||
});
|
});
|
||||||
|
|
||||||
// Response
|
// Response
|
||||||
res(await serialize(channel));
|
res(await pack(channel));
|
||||||
|
|
||||||
// Create Watching
|
// Create Watching
|
||||||
await Watching.insert({
|
await Watching.insert({
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
import $ from 'cafy';
|
import $ from 'cafy';
|
||||||
import { default as Channel, IChannel } from '../../models/channel';
|
import { default as Channel, IChannel } from '../../models/channel';
|
||||||
import Post from '../../models/post';
|
import Post from '../../models/post';
|
||||||
import serialize from '../../serializers/post';
|
import { pack } from '../../models/post';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Show a posts of a channel
|
* Show a posts of a channel
|
||||||
|
@ -74,6 +74,6 @@ module.exports = (params, user) => new Promise(async (res, rej) => {
|
||||||
|
|
||||||
// Serialize
|
// Serialize
|
||||||
res(await Promise.all(posts.map(async (post) =>
|
res(await Promise.all(posts.map(async (post) =>
|
||||||
await serialize(post, user)
|
await pack(post, user)
|
||||||
)));
|
)));
|
||||||
});
|
});
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
*/
|
*/
|
||||||
import $ from 'cafy';
|
import $ from 'cafy';
|
||||||
import { default as Channel, IChannel } from '../../models/channel';
|
import { default as Channel, IChannel } from '../../models/channel';
|
||||||
import serialize from '../../serializers/channel';
|
import { pack } from '../../models/channel';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Show a channel
|
* Show a channel
|
||||||
|
@ -27,5 +27,5 @@ module.exports = (params, user) => new Promise(async (res, rej) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Serialize
|
// Serialize
|
||||||
res(await serialize(channel, user));
|
res(await pack(channel, user));
|
||||||
});
|
});
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
*/
|
*/
|
||||||
import $ from 'cafy';
|
import $ from 'cafy';
|
||||||
import DriveFile from '../../models/drive-file';
|
import DriveFile from '../../models/drive-file';
|
||||||
import serialize from '../../serializers/drive-file';
|
import { pack } from '../../models/drive-file';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get drive files
|
* Get drive files
|
||||||
|
@ -69,6 +69,6 @@ module.exports = async (params, user, app) => {
|
||||||
});
|
});
|
||||||
|
|
||||||
// Serialize
|
// Serialize
|
||||||
const _files = await Promise.all(files.map(file => serialize(file)));
|
const _files = await Promise.all(files.map(file => pack(file)));
|
||||||
return _files;
|
return _files;
|
||||||
};
|
};
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
*/
|
*/
|
||||||
import $ from 'cafy';
|
import $ from 'cafy';
|
||||||
import { validateFileName } from '../../../models/drive-file';
|
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 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);
|
const driveFile = await create(user, file.path, name, null, folderId);
|
||||||
|
|
||||||
// Serialize
|
// Serialize
|
||||||
return serialize(driveFile);
|
return pack(driveFile);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(e);
|
console.error(e);
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
*/
|
*/
|
||||||
import $ from 'cafy';
|
import $ from 'cafy';
|
||||||
import DriveFile from '../../../models/drive-file';
|
import DriveFile from '../../../models/drive-file';
|
||||||
import serialize from '../../../serializers/drive-file';
|
import { pack } from '../../../models/drive-file';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Find a file(s)
|
* Find a file(s)
|
||||||
|
@ -31,5 +31,5 @@ module.exports = (params, user) => new Promise(async (res, rej) => {
|
||||||
|
|
||||||
// Serialize
|
// Serialize
|
||||||
res(await Promise.all(files.map(async file =>
|
res(await Promise.all(files.map(async file =>
|
||||||
await serialize(file))));
|
await pack(file))));
|
||||||
});
|
});
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
*/
|
*/
|
||||||
import $ from 'cafy';
|
import $ from 'cafy';
|
||||||
import DriveFile from '../../../models/drive-file';
|
import DriveFile from '../../../models/drive-file';
|
||||||
import serialize from '../../../serializers/drive-file';
|
import { pack } from '../../../models/drive-file';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Show a file
|
* Show a file
|
||||||
|
@ -29,7 +29,7 @@ module.exports = async (params, user) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Serialize
|
// Serialize
|
||||||
const _file = await serialize(file, {
|
const _file = await pack(file, {
|
||||||
detail: true
|
detail: true
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ import $ from 'cafy';
|
||||||
import DriveFolder from '../../../models/drive-folder';
|
import DriveFolder from '../../../models/drive-folder';
|
||||||
import DriveFile from '../../../models/drive-file';
|
import DriveFile from '../../../models/drive-file';
|
||||||
import { validateFileName } 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';
|
import { publishDriveStream } from '../../../event';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -67,7 +67,7 @@ module.exports = (params, user) => new Promise(async (res, rej) => {
|
||||||
});
|
});
|
||||||
|
|
||||||
// Serialize
|
// Serialize
|
||||||
const fileObj = await serialize(file);
|
const fileObj = await pack(file);
|
||||||
|
|
||||||
// Response
|
// Response
|
||||||
res(fileObj);
|
res(fileObj);
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
import * as URL from 'url';
|
import * as URL from 'url';
|
||||||
import $ from 'cafy';
|
import $ from 'cafy';
|
||||||
import { validateFileName } from '../../../models/drive-file';
|
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 create from '../../../common/add-file-to-drive';
|
||||||
import * as debug from 'debug';
|
import * as debug from 'debug';
|
||||||
import * as tmp from 'tmp';
|
import * as tmp from 'tmp';
|
||||||
|
@ -63,5 +63,5 @@ module.exports = async (params, user): Promise<any> => {
|
||||||
if (e) log(e.stack);
|
if (e) log(e.stack);
|
||||||
});
|
});
|
||||||
|
|
||||||
return serialize(driveFile);
|
return pack(driveFile);
|
||||||
};
|
};
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
*/
|
*/
|
||||||
import $ from 'cafy';
|
import $ from 'cafy';
|
||||||
import DriveFolder from '../../models/drive-folder';
|
import DriveFolder from '../../models/drive-folder';
|
||||||
import serialize from '../../serializers/drive-folder';
|
import { pack } from '../../models/drive-folder';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get drive folders
|
* Get drive folders
|
||||||
|
@ -63,5 +63,5 @@ module.exports = (params, user, app) => new Promise(async (res, rej) => {
|
||||||
|
|
||||||
// Serialize
|
// Serialize
|
||||||
res(await Promise.all(folders.map(async folder =>
|
res(await Promise.all(folders.map(async folder =>
|
||||||
await serialize(folder))));
|
await pack(folder))));
|
||||||
});
|
});
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
import $ from 'cafy';
|
import $ from 'cafy';
|
||||||
import DriveFolder from '../../../models/drive-folder';
|
import DriveFolder from '../../../models/drive-folder';
|
||||||
import { isValidFolderName } 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';
|
import { publishDriveStream } from '../../../event';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -47,7 +47,7 @@ module.exports = (params, user) => new Promise(async (res, rej) => {
|
||||||
});
|
});
|
||||||
|
|
||||||
// Serialize
|
// Serialize
|
||||||
const folderObj = await serialize(folder);
|
const folderObj = await pack(folder);
|
||||||
|
|
||||||
// Response
|
// Response
|
||||||
res(folderObj);
|
res(folderObj);
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
*/
|
*/
|
||||||
import $ from 'cafy';
|
import $ from 'cafy';
|
||||||
import DriveFolder from '../../../models/drive-folder';
|
import DriveFolder from '../../../models/drive-folder';
|
||||||
import serialize from '../../../serializers/drive-folder';
|
import { pack } from '../../../models/drive-folder';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Find a folder(s)
|
* Find a folder(s)
|
||||||
|
@ -30,5 +30,5 @@ module.exports = (params, user) => new Promise(async (res, rej) => {
|
||||||
});
|
});
|
||||||
|
|
||||||
// Serialize
|
// Serialize
|
||||||
res(await Promise.all(folders.map(folder => serialize(folder))));
|
res(await Promise.all(folders.map(folder => pack(folder))));
|
||||||
});
|
});
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
*/
|
*/
|
||||||
import $ from 'cafy';
|
import $ from 'cafy';
|
||||||
import DriveFolder from '../../../models/drive-folder';
|
import DriveFolder from '../../../models/drive-folder';
|
||||||
import serialize from '../../../serializers/drive-folder';
|
import { pack } from '../../../models/drive-folder';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Show a folder
|
* Show a folder
|
||||||
|
@ -29,7 +29,7 @@ module.exports = (params, user) => new Promise(async (res, rej) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Serialize
|
// Serialize
|
||||||
res(await serialize(folder, {
|
res(await pack(folder, {
|
||||||
detail: true
|
detail: true
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
import $ from 'cafy';
|
import $ from 'cafy';
|
||||||
import DriveFolder from '../../../models/drive-folder';
|
import DriveFolder from '../../../models/drive-folder';
|
||||||
import { isValidFolderName } 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';
|
import { publishDriveStream } from '../../../event';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -91,7 +91,7 @@ module.exports = (params, user) => new Promise(async (res, rej) => {
|
||||||
});
|
});
|
||||||
|
|
||||||
// Serialize
|
// Serialize
|
||||||
const folderObj = await serialize(folder);
|
const folderObj = await pack(folder);
|
||||||
|
|
||||||
// Response
|
// Response
|
||||||
res(folderObj);
|
res(folderObj);
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
*/
|
*/
|
||||||
import $ from 'cafy';
|
import $ from 'cafy';
|
||||||
import DriveFile from '../../models/drive-file';
|
import DriveFile from '../../models/drive-file';
|
||||||
import serialize from '../../serializers/drive-file';
|
import { pack } from '../../models/drive-file';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get drive stream
|
* Get drive stream
|
||||||
|
@ -64,5 +64,5 @@ module.exports = (params, user) => new Promise(async (res, rej) => {
|
||||||
|
|
||||||
// Serialize
|
// Serialize
|
||||||
res(await Promise.all(files.map(async file =>
|
res(await Promise.all(files.map(async file =>
|
||||||
await serialize(file))));
|
await pack(file))));
|
||||||
});
|
});
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
* Module dependencies
|
* Module dependencies
|
||||||
*/
|
*/
|
||||||
import User from '../models/user';
|
import User from '../models/user';
|
||||||
import serialize from '../serializers/user';
|
import { pack } from '../models/user';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Show myself
|
* Show myself
|
||||||
|
@ -15,7 +15,7 @@ import serialize from '../serializers/user';
|
||||||
*/
|
*/
|
||||||
module.exports = (params, user, _, isSecure) => new Promise(async (res, rej) => {
|
module.exports = (params, user, _, isSecure) => new Promise(async (res, rej) => {
|
||||||
// Serialize
|
// Serialize
|
||||||
res(await serialize(user, user, {
|
res(await pack(user, user, {
|
||||||
detail: true,
|
detail: true,
|
||||||
includeSecrets: isSecure
|
includeSecrets: isSecure
|
||||||
}));
|
}));
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
*/
|
*/
|
||||||
import $ from 'cafy';
|
import $ from 'cafy';
|
||||||
import AccessToken from '../../models/access-token';
|
import AccessToken from '../../models/access-token';
|
||||||
import serialize from '../../serializers/app';
|
import { pack } from '../../models/app';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get authorized apps of my account
|
* Get authorized apps of my account
|
||||||
|
@ -39,5 +39,5 @@ module.exports = (params, user) => new Promise(async (res, rej) => {
|
||||||
|
|
||||||
// Serialize
|
// Serialize
|
||||||
res(await Promise.all(tokens.map(async token =>
|
res(await Promise.all(tokens.map(async token =>
|
||||||
await serialize(token.app_id))));
|
await pack(token.app_id))));
|
||||||
});
|
});
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
*/
|
*/
|
||||||
import $ from 'cafy';
|
import $ from 'cafy';
|
||||||
import Favorite from '../../models/favorite';
|
import Favorite from '../../models/favorite';
|
||||||
import serialize from '../../serializers/post';
|
import { pack } from '../../models/post';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get followers of a user
|
* Get followers of a user
|
||||||
|
@ -39,6 +39,6 @@ module.exports = (params, user) => new Promise(async (res, rej) => {
|
||||||
|
|
||||||
// Serialize
|
// Serialize
|
||||||
res(await Promise.all(favorites.map(async favorite =>
|
res(await Promise.all(favorites.map(async favorite =>
|
||||||
await serialize(favorite.post)
|
await pack(favorite.post)
|
||||||
)));
|
)));
|
||||||
});
|
});
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
import $ from 'cafy';
|
import $ from 'cafy';
|
||||||
import Notification from '../../models/notification';
|
import Notification from '../../models/notification';
|
||||||
import Mute from '../../models/mute';
|
import Mute from '../../models/mute';
|
||||||
import serialize from '../../serializers/notification';
|
import { pack } from '../../models/notification';
|
||||||
import getFriends from '../../common/get-friends';
|
import getFriends from '../../common/get-friends';
|
||||||
import read from '../../common/read-notification';
|
import read from '../../common/read-notification';
|
||||||
|
|
||||||
|
@ -101,7 +101,7 @@ module.exports = (params, user) => new Promise(async (res, rej) => {
|
||||||
|
|
||||||
// Serialize
|
// Serialize
|
||||||
res(await Promise.all(notifications.map(async notification =>
|
res(await Promise.all(notifications.map(async notification =>
|
||||||
await serialize(notification))));
|
await pack(notification))));
|
||||||
|
|
||||||
// Mark as read all
|
// Mark as read all
|
||||||
if (notifications.length > 0 && markAsRead) {
|
if (notifications.length > 0 && markAsRead) {
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
import $ from 'cafy';
|
import $ from 'cafy';
|
||||||
import User from '../../models/user';
|
import User from '../../models/user';
|
||||||
import Post from '../../models/post';
|
import Post from '../../models/post';
|
||||||
import serialize from '../../serializers/user';
|
import { pack } from '../../models/user';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Pin post
|
* Pin post
|
||||||
|
@ -35,7 +35,7 @@ module.exports = async (params, user) => new Promise(async (res, rej) => {
|
||||||
});
|
});
|
||||||
|
|
||||||
// Serialize
|
// Serialize
|
||||||
const iObj = await serialize(user, user, {
|
const iObj = await pack(user, user, {
|
||||||
detail: true
|
detail: true
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
*/
|
*/
|
||||||
import $ from 'cafy';
|
import $ from 'cafy';
|
||||||
import Signin from '../../models/signin';
|
import Signin from '../../models/signin';
|
||||||
import serialize from '../../serializers/signin';
|
import { pack } from '../../models/signin';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get signin history of my account
|
* Get signin history of my account
|
||||||
|
@ -58,5 +58,5 @@ module.exports = (params, user) => new Promise(async (res, rej) => {
|
||||||
|
|
||||||
// Serialize
|
// Serialize
|
||||||
res(await Promise.all(history.map(async record =>
|
res(await Promise.all(history.map(async record =>
|
||||||
await serialize(record))));
|
await pack(record))));
|
||||||
});
|
});
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
import $ from 'cafy';
|
import $ from 'cafy';
|
||||||
import User from '../../models/user';
|
import User from '../../models/user';
|
||||||
import { isValidName, isValidDescription, isValidLocation, isValidBirthday } 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 event from '../../event';
|
||||||
import config from '../../../conf';
|
import config from '../../../conf';
|
||||||
|
|
||||||
|
@ -65,7 +65,7 @@ module.exports = async (params, user, _, isSecure) => new Promise(async (res, re
|
||||||
});
|
});
|
||||||
|
|
||||||
// Serialize
|
// Serialize
|
||||||
const iObj = await serialize(user, user, {
|
const iObj = await pack(user, user, {
|
||||||
detail: true,
|
detail: true,
|
||||||
includeSecrets: isSecure
|
includeSecrets: isSecure
|
||||||
});
|
});
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
import $ from 'cafy';
|
import $ from 'cafy';
|
||||||
import History from '../../models/messaging-history';
|
import History from '../../models/messaging-history';
|
||||||
import Mute from '../../models/mute';
|
import Mute from '../../models/mute';
|
||||||
import serialize from '../../serializers/messaging-message';
|
import { pack } from '../../models/messaging-message';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Show messaging history
|
* Show messaging history
|
||||||
|
@ -39,5 +39,5 @@ module.exports = (params, user) => new Promise(async (res, rej) => {
|
||||||
|
|
||||||
// Serialize
|
// Serialize
|
||||||
res(await Promise.all(history.map(async h =>
|
res(await Promise.all(history.map(async h =>
|
||||||
await serialize(h.message, user))));
|
await pack(h.message, user))));
|
||||||
});
|
});
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
import $ from 'cafy';
|
import $ from 'cafy';
|
||||||
import Message from '../../models/messaging-message';
|
import Message from '../../models/messaging-message';
|
||||||
import User from '../../models/user';
|
import User from '../../models/user';
|
||||||
import serialize from '../../serializers/messaging-message';
|
import { pack } from '../../models/messaging-message';
|
||||||
import read from '../../common/read-messaging-message';
|
import read from '../../common/read-messaging-message';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -87,7 +87,7 @@ module.exports = (params, user) => new Promise(async (res, rej) => {
|
||||||
|
|
||||||
// Serialize
|
// Serialize
|
||||||
res(await Promise.all(messages.map(async message =>
|
res(await Promise.all(messages.map(async message =>
|
||||||
await serialize(message, user, {
|
await pack(message, user, {
|
||||||
populateRecipient: false
|
populateRecipient: false
|
||||||
}))));
|
}))));
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@ import History from '../../../models/messaging-history';
|
||||||
import User from '../../../models/user';
|
import User from '../../../models/user';
|
||||||
import Mute from '../../../models/mute';
|
import Mute from '../../../models/mute';
|
||||||
import DriveFile from '../../../models/drive-file';
|
import DriveFile from '../../../models/drive-file';
|
||||||
import serialize from '../../../serializers/messaging-message';
|
import { pack } from '../../../models/messaging-message';
|
||||||
import publishUserStream from '../../../event';
|
import publishUserStream from '../../../event';
|
||||||
import { publishMessagingStream, publishMessagingIndexStream, pushSw } from '../../../event';
|
import { publishMessagingStream, publishMessagingIndexStream, pushSw } from '../../../event';
|
||||||
import config from '../../../../conf';
|
import config from '../../../../conf';
|
||||||
|
@ -79,7 +79,7 @@ module.exports = (params, user) => new Promise(async (res, rej) => {
|
||||||
});
|
});
|
||||||
|
|
||||||
// Serialize
|
// Serialize
|
||||||
const messageObj = await serialize(message);
|
const messageObj = await pack(message);
|
||||||
|
|
||||||
// Reponse
|
// Reponse
|
||||||
res(messageObj);
|
res(messageObj);
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
*/
|
*/
|
||||||
import $ from 'cafy';
|
import $ from 'cafy';
|
||||||
import Mute from '../../models/mute';
|
import Mute from '../../models/mute';
|
||||||
import serialize from '../../serializers/user';
|
import { pack } from '../../models/user';
|
||||||
import getFriends from '../../common/get-friends';
|
import getFriends from '../../common/get-friends';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -63,7 +63,7 @@ module.exports = (params, me) => new Promise(async (res, rej) => {
|
||||||
|
|
||||||
// Serialize
|
// Serialize
|
||||||
const users = await Promise.all(mutes.map(async m =>
|
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
|
// Response
|
||||||
res({
|
res({
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
*/
|
*/
|
||||||
import $ from 'cafy';
|
import $ from 'cafy';
|
||||||
import App from '../../models/app';
|
import App from '../../models/app';
|
||||||
import serialize from '../../serializers/app';
|
import { pack } from '../../models/app';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get my apps
|
* Get my apps
|
||||||
|
@ -37,5 +37,5 @@ module.exports = (params, user) => new Promise(async (res, rej) => {
|
||||||
|
|
||||||
// Reply
|
// Reply
|
||||||
res(await Promise.all(apps.map(async app =>
|
res(await Promise.all(apps.map(async app =>
|
||||||
await serialize(app))));
|
await pack(app))));
|
||||||
});
|
});
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
*/
|
*/
|
||||||
import $ from 'cafy';
|
import $ from 'cafy';
|
||||||
import Post from '../models/post';
|
import Post from '../models/post';
|
||||||
import serialize from '../serializers/post';
|
import { pack } from '../models/post';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Lists all posts
|
* Lists all posts
|
||||||
|
@ -85,5 +85,5 @@ module.exports = (params) => new Promise(async (res, rej) => {
|
||||||
});
|
});
|
||||||
|
|
||||||
// Serialize
|
// Serialize
|
||||||
res(await Promise.all(posts.map(async post => await serialize(post))));
|
res(await Promise.all(posts.map(async post => await pack(post))));
|
||||||
});
|
});
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
*/
|
*/
|
||||||
import $ from 'cafy';
|
import $ from 'cafy';
|
||||||
import Post from '../../models/post';
|
import Post from '../../models/post';
|
||||||
import serialize from '../../serializers/post';
|
import { pack } from '../../models/post';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Show a context of a post
|
* Show a context of a post
|
||||||
|
@ -60,5 +60,5 @@ module.exports = (params, user) => new Promise(async (res, rej) => {
|
||||||
|
|
||||||
// Serialize
|
// Serialize
|
||||||
res(await Promise.all(context.map(async post =>
|
res(await Promise.all(context.map(async post =>
|
||||||
await serialize(post, user))));
|
await pack(post, user))));
|
||||||
});
|
});
|
||||||
|
|
|
@ -12,7 +12,7 @@ import Mute from '../../models/mute';
|
||||||
import DriveFile from '../../models/drive-file';
|
import DriveFile from '../../models/drive-file';
|
||||||
import Watching from '../../models/post-watching';
|
import Watching from '../../models/post-watching';
|
||||||
import ChannelWatching from '../../models/channel-watching';
|
import ChannelWatching from '../../models/channel-watching';
|
||||||
import serialize from '../../serializers/post';
|
import { pack } from '../../models/post';
|
||||||
import notify from '../../common/notify';
|
import notify from '../../common/notify';
|
||||||
import watch from '../../common/watch-post';
|
import watch from '../../common/watch-post';
|
||||||
import event, { pushSw, publishChannelStream } from '../../event';
|
import event, { pushSw, publishChannelStream } from '../../event';
|
||||||
|
@ -224,7 +224,7 @@ module.exports = (params, user: IUser, app) => new Promise(async (res, rej) => {
|
||||||
});
|
});
|
||||||
|
|
||||||
// Serialize
|
// Serialize
|
||||||
const postObj = await serialize(post);
|
const postObj = await pack(post);
|
||||||
|
|
||||||
// Reponse
|
// Reponse
|
||||||
res({
|
res({
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
import $ from 'cafy';
|
import $ from 'cafy';
|
||||||
import Post from '../../models/post';
|
import Post from '../../models/post';
|
||||||
import getFriends from '../../common/get-friends';
|
import getFriends from '../../common/get-friends';
|
||||||
import serialize from '../../serializers/post';
|
import { pack } from '../../models/post';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get mentions of myself
|
* Get mentions of myself
|
||||||
|
@ -73,6 +73,6 @@ module.exports = (params, user) => new Promise(async (res, rej) => {
|
||||||
|
|
||||||
// Serialize
|
// Serialize
|
||||||
res(await Promise.all(mentions.map(async mention =>
|
res(await Promise.all(mentions.map(async mention =>
|
||||||
await serialize(mention, user)
|
await pack(mention, user)
|
||||||
)));
|
)));
|
||||||
});
|
});
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
import $ from 'cafy';
|
import $ from 'cafy';
|
||||||
import Vote from '../../../models/poll-vote';
|
import Vote from '../../../models/poll-vote';
|
||||||
import Post from '../../../models/post';
|
import Post from '../../../models/post';
|
||||||
import serialize from '../../../serializers/post';
|
import { pack } from '../../../models/post';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get recommended polls
|
* Get recommended polls
|
||||||
|
@ -56,5 +56,5 @@ module.exports = (params, user) => new Promise(async (res, rej) => {
|
||||||
|
|
||||||
// Serialize
|
// Serialize
|
||||||
res(await Promise.all(posts.map(async post =>
|
res(await Promise.all(posts.map(async post =>
|
||||||
await serialize(post, user, { detail: true }))));
|
await pack(post, user, { detail: true }))));
|
||||||
});
|
});
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
import $ from 'cafy';
|
import $ from 'cafy';
|
||||||
import Post from '../../models/post';
|
import Post from '../../models/post';
|
||||||
import Reaction from '../../models/post-reaction';
|
import Reaction from '../../models/post-reaction';
|
||||||
import serialize from '../../serializers/post-reaction';
|
import { pack } from '../../models/post-reaction';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Show reactions of a post
|
* Show reactions of a post
|
||||||
|
@ -54,5 +54,5 @@ module.exports = (params, user) => new Promise(async (res, rej) => {
|
||||||
|
|
||||||
// Serialize
|
// Serialize
|
||||||
res(await Promise.all(reactions.map(async reaction =>
|
res(await Promise.all(reactions.map(async reaction =>
|
||||||
await serialize(reaction, user))));
|
await pack(reaction, user))));
|
||||||
});
|
});
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
*/
|
*/
|
||||||
import $ from 'cafy';
|
import $ from 'cafy';
|
||||||
import Post from '../../models/post';
|
import Post from '../../models/post';
|
||||||
import serialize from '../../serializers/post';
|
import { pack } from '../../models/post';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Show a replies of a post
|
* Show a replies of a post
|
||||||
|
@ -50,5 +50,5 @@ module.exports = (params, user) => new Promise(async (res, rej) => {
|
||||||
|
|
||||||
// Serialize
|
// Serialize
|
||||||
res(await Promise.all(replies.map(async post =>
|
res(await Promise.all(replies.map(async post =>
|
||||||
await serialize(post, user))));
|
await pack(post, user))));
|
||||||
});
|
});
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
*/
|
*/
|
||||||
import $ from 'cafy';
|
import $ from 'cafy';
|
||||||
import Post from '../../models/post';
|
import Post from '../../models/post';
|
||||||
import serialize from '../../serializers/post';
|
import { pack } from '../../models/post';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Show a reposts of a post
|
* Show a reposts of a post
|
||||||
|
@ -70,5 +70,5 @@ module.exports = (params, user) => new Promise(async (res, rej) => {
|
||||||
|
|
||||||
// Serialize
|
// Serialize
|
||||||
res(await Promise.all(reposts.map(async post =>
|
res(await Promise.all(reposts.map(async post =>
|
||||||
await serialize(post, user))));
|
await pack(post, user))));
|
||||||
});
|
});
|
||||||
|
|
|
@ -7,7 +7,7 @@ import Post from '../../models/post';
|
||||||
import User from '../../models/user';
|
import User from '../../models/user';
|
||||||
import Mute from '../../models/mute';
|
import Mute from '../../models/mute';
|
||||||
import getFriends from '../../common/get-friends';
|
import getFriends from '../../common/get-friends';
|
||||||
import serialize from '../../serializers/post';
|
import { pack } from '../../models/post';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Search a post
|
* Search a post
|
||||||
|
@ -351,5 +351,5 @@ async function search(
|
||||||
|
|
||||||
// Serialize
|
// Serialize
|
||||||
res(await Promise.all(posts.map(async post =>
|
res(await Promise.all(posts.map(async post =>
|
||||||
await serialize(post, me))));
|
await pack(post, me))));
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
*/
|
*/
|
||||||
import $ from 'cafy';
|
import $ from 'cafy';
|
||||||
import Post from '../../models/post';
|
import Post from '../../models/post';
|
||||||
import serialize from '../../serializers/post';
|
import { pack } from '../../models/post';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Show a post
|
* Show a post
|
||||||
|
@ -27,7 +27,7 @@ module.exports = (params, user) => new Promise(async (res, rej) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Serialize
|
// Serialize
|
||||||
res(await serialize(post, user, {
|
res(await pack(post, user, {
|
||||||
detail: true
|
detail: true
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
|
|
|
@ -7,7 +7,7 @@ import Post from '../../models/post';
|
||||||
import Mute from '../../models/mute';
|
import Mute from '../../models/mute';
|
||||||
import ChannelWatching from '../../models/channel-watching';
|
import ChannelWatching from '../../models/channel-watching';
|
||||||
import getFriends from '../../common/get-friends';
|
import getFriends from '../../common/get-friends';
|
||||||
import serialize from '../../serializers/post';
|
import { pack } from '../../models/post';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get timeline of myself
|
* Get timeline of myself
|
||||||
|
@ -128,5 +128,5 @@ module.exports = async (params, user, app) => {
|
||||||
});
|
});
|
||||||
|
|
||||||
// Serialize
|
// Serialize
|
||||||
return await Promise.all(timeline.map(post => serialize(post, user)));
|
return await Promise.all(timeline.map(post => pack(post, user)));
|
||||||
};
|
};
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
const ms = require('ms');
|
const ms = require('ms');
|
||||||
import $ from 'cafy';
|
import $ from 'cafy';
|
||||||
import Post from '../../models/post';
|
import Post from '../../models/post';
|
||||||
import serialize from '../../serializers/post';
|
import { pack } from '../../models/post';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get trend posts
|
* Get trend posts
|
||||||
|
@ -76,5 +76,5 @@ module.exports = (params, user) => new Promise(async (res, rej) => {
|
||||||
|
|
||||||
// Serialize
|
// Serialize
|
||||||
res(await Promise.all(posts.map(async post =>
|
res(await Promise.all(posts.map(async post =>
|
||||||
await serialize(post, user, { detail: true }))));
|
await pack(post, user, { detail: true }))));
|
||||||
});
|
});
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
*/
|
*/
|
||||||
import $ from 'cafy';
|
import $ from 'cafy';
|
||||||
import User from '../models/user';
|
import User from '../models/user';
|
||||||
import serialize from '../serializers/user';
|
import { pack } from '../models/user';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Lists all users
|
* Lists all users
|
||||||
|
@ -55,5 +55,5 @@ module.exports = (params, me) => new Promise(async (res, rej) => {
|
||||||
|
|
||||||
// Serialize
|
// Serialize
|
||||||
res(await Promise.all(users.map(async user =>
|
res(await Promise.all(users.map(async user =>
|
||||||
await serialize(user, me))));
|
await pack(user, me))));
|
||||||
});
|
});
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
import $ from 'cafy';
|
import $ from 'cafy';
|
||||||
import User from '../../models/user';
|
import User from '../../models/user';
|
||||||
import Following from '../../models/following';
|
import Following from '../../models/following';
|
||||||
import serialize from '../../serializers/user';
|
import { pack } from '../../models/user';
|
||||||
import getFriends from '../../common/get-friends';
|
import getFriends from '../../common/get-friends';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -82,7 +82,7 @@ module.exports = (params, me) => new Promise(async (res, rej) => {
|
||||||
|
|
||||||
// Serialize
|
// Serialize
|
||||||
const users = await Promise.all(following.map(async f =>
|
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
|
// Response
|
||||||
res({
|
res({
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
import $ from 'cafy';
|
import $ from 'cafy';
|
||||||
import User from '../../models/user';
|
import User from '../../models/user';
|
||||||
import Following from '../../models/following';
|
import Following from '../../models/following';
|
||||||
import serialize from '../../serializers/user';
|
import { pack } from '../../models/user';
|
||||||
import getFriends from '../../common/get-friends';
|
import getFriends from '../../common/get-friends';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -82,7 +82,7 @@ module.exports = (params, me) => new Promise(async (res, rej) => {
|
||||||
|
|
||||||
// Serialize
|
// Serialize
|
||||||
const users = await Promise.all(following.map(async f =>
|
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
|
// Response
|
||||||
res({
|
res({
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
import $ from 'cafy';
|
import $ from 'cafy';
|
||||||
import Post from '../../models/post';
|
import Post from '../../models/post';
|
||||||
import User from '../../models/user';
|
import User from '../../models/user';
|
||||||
import serialize from '../../serializers/user';
|
import { pack } from '../../models/user';
|
||||||
|
|
||||||
module.exports = (params, me) => new Promise(async (res, rej) => {
|
module.exports = (params, me) => new Promise(async (res, rej) => {
|
||||||
// Get 'user_id' parameter
|
// Get 'user_id' parameter
|
||||||
|
@ -91,7 +91,7 @@ module.exports = (params, me) => new Promise(async (res, rej) => {
|
||||||
|
|
||||||
// Make replies object (includes weights)
|
// Make replies object (includes weights)
|
||||||
const repliesObj = await Promise.all(topRepliedUsers.map(async (user) => ({
|
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
|
weight: repliedUsers[user] / peak
|
||||||
})));
|
})));
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
import $ from 'cafy';
|
import $ from 'cafy';
|
||||||
import Post from '../../models/post';
|
import Post from '../../models/post';
|
||||||
import User from '../../models/user';
|
import User from '../../models/user';
|
||||||
import serialize from '../../serializers/post';
|
import { pack } from '../../models/post';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get posts of a user
|
* Get posts of a user
|
||||||
|
@ -124,6 +124,6 @@ module.exports = (params, me) => new Promise(async (res, rej) => {
|
||||||
|
|
||||||
// Serialize
|
// Serialize
|
||||||
res(await Promise.all(posts.map(async (post) =>
|
res(await Promise.all(posts.map(async (post) =>
|
||||||
await serialize(post, me)
|
await pack(post, me)
|
||||||
)));
|
)));
|
||||||
});
|
});
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
const ms = require('ms');
|
const ms = require('ms');
|
||||||
import $ from 'cafy';
|
import $ from 'cafy';
|
||||||
import User from '../../models/user';
|
import User from '../../models/user';
|
||||||
import serialize from '../../serializers/user';
|
import { pack } from '../../models/user';
|
||||||
import getFriends from '../../common/get-friends';
|
import getFriends from '../../common/get-friends';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -44,5 +44,5 @@ module.exports = (params, me) => new Promise(async (res, rej) => {
|
||||||
|
|
||||||
// Serialize
|
// Serialize
|
||||||
res(await Promise.all(users.map(async user =>
|
res(await Promise.all(users.map(async user =>
|
||||||
await serialize(user, me, { detail: true }))));
|
await pack(user, me, { detail: true }))));
|
||||||
});
|
});
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
import * as mongo from 'mongodb';
|
import * as mongo from 'mongodb';
|
||||||
import $ from 'cafy';
|
import $ from 'cafy';
|
||||||
import User from '../../models/user';
|
import User from '../../models/user';
|
||||||
import serialize from '../../serializers/user';
|
import { pack } from '../../models/user';
|
||||||
import config from '../../../conf';
|
import config from '../../../conf';
|
||||||
const escapeRegexp = require('escape-regexp');
|
const escapeRegexp = require('escape-regexp');
|
||||||
|
|
||||||
|
@ -94,6 +94,6 @@ async function byElasticsearch(res, rej, me, query, offset, max) {
|
||||||
|
|
||||||
// Serialize
|
// Serialize
|
||||||
res(await Promise.all(users.map(async user =>
|
res(await Promise.all(users.map(async user =>
|
||||||
await serialize(user, me, { detail: true }))));
|
await pack(user, me, { detail: true }))));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
*/
|
*/
|
||||||
import $ from 'cafy';
|
import $ from 'cafy';
|
||||||
import User from '../../models/user';
|
import User from '../../models/user';
|
||||||
import serialize from '../../serializers/user';
|
import { pack } from '../../models/user';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Search a user by username
|
* Search a user by username
|
||||||
|
@ -35,5 +35,5 @@ module.exports = (params, me) => new Promise(async (res, rej) => {
|
||||||
|
|
||||||
// Serialize
|
// Serialize
|
||||||
res(await Promise.all(users.map(async user =>
|
res(await Promise.all(users.map(async user =>
|
||||||
await serialize(user, me, { detail: true }))));
|
await pack(user, me, { detail: true }))));
|
||||||
});
|
});
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
*/
|
*/
|
||||||
import $ from 'cafy';
|
import $ from 'cafy';
|
||||||
import User from '../../models/user';
|
import User from '../../models/user';
|
||||||
import serialize from '../../serializers/user';
|
import { pack } from '../../models/user';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Show a user
|
* Show a user
|
||||||
|
@ -41,7 +41,7 @@ module.exports = (params, me) => new Promise(async (res, rej) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Send response
|
// Send response
|
||||||
res(await serialize(user, me, {
|
res(await pack(user, me, {
|
||||||
detail: true
|
detail: true
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
|
|
|
@ -20,8 +20,14 @@ export { getGridFSBucket };
|
||||||
|
|
||||||
export type IDriveFile = {
|
export type IDriveFile = {
|
||||||
_id: mongodb.ObjectID;
|
_id: mongodb.ObjectID;
|
||||||
created_at: Date;
|
uploadDate: Date;
|
||||||
|
md5: string;
|
||||||
|
filename: string;
|
||||||
|
metadata: {
|
||||||
|
properties: any;
|
||||||
user_id: mongodb.ObjectID;
|
user_id: mongodb.ObjectID;
|
||||||
|
folder_id: mongodb.ObjectID;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
export function validateFileName(name: string): boolean {
|
export function validateFileName(name: string): boolean {
|
||||||
|
|
|
@ -9,7 +9,9 @@ export default DriveFolder;
|
||||||
export type IDriveFolder = {
|
export type IDriveFolder = {
|
||||||
_id: mongo.ObjectID;
|
_id: mongo.ObjectID;
|
||||||
created_at: Date;
|
created_at: Date;
|
||||||
|
name: string;
|
||||||
user_id: mongo.ObjectID;
|
user_id: mongo.ObjectID;
|
||||||
|
parent_id: mongo.ObjectID;
|
||||||
};
|
};
|
||||||
|
|
||||||
export function isValidFolderName(name: string): boolean {
|
export function isValidFolderName(name: string): boolean {
|
||||||
|
|
|
@ -10,6 +10,11 @@ export default MessagingMessage;
|
||||||
|
|
||||||
export interface IMessagingMessage {
|
export interface IMessagingMessage {
|
||||||
_id: mongo.ObjectID;
|
_id: mongo.ObjectID;
|
||||||
|
created_at: Date;
|
||||||
|
text: string;
|
||||||
|
user_id: mongo.ObjectID;
|
||||||
|
recipient_id: mongo.ObjectID;
|
||||||
|
is_read: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function isValidText(text: string): boolean {
|
export function isValidText(text: string): boolean {
|
||||||
|
|
|
@ -3,7 +3,7 @@ import * as bcrypt from 'bcryptjs';
|
||||||
import * as speakeasy from 'speakeasy';
|
import * as speakeasy from 'speakeasy';
|
||||||
import { default as User, IUser } from '../models/user';
|
import { default as User, IUser } from '../models/user';
|
||||||
import Signin from '../models/signin';
|
import Signin from '../models/signin';
|
||||||
import serialize from '../serializers/signin';
|
import { pack } from '../models/signin';
|
||||||
import event from '../event';
|
import event from '../event';
|
||||||
import signin from '../common/signin';
|
import signin from '../common/signin';
|
||||||
import config from '../../conf';
|
import config from '../../conf';
|
||||||
|
@ -85,5 +85,5 @@ export default async (req: express.Request, res: express.Response) => {
|
||||||
});
|
});
|
||||||
|
|
||||||
// Publish signin event
|
// Publish signin event
|
||||||
event(user._id, 'signin', await serialize(record));
|
event(user._id, 'signin', await pack(record));
|
||||||
};
|
};
|
||||||
|
|
|
@ -4,7 +4,7 @@ import * as bcrypt from 'bcryptjs';
|
||||||
import recaptcha = require('recaptcha-promise');
|
import recaptcha = require('recaptcha-promise');
|
||||||
import { default as User, IUser } from '../models/user';
|
import { default as User, IUser } from '../models/user';
|
||||||
import { validateUsername, validatePassword } from '../models/user';
|
import { validateUsername, validatePassword } from '../models/user';
|
||||||
import serialize from '../serializers/user';
|
import { pack } from '../models/user';
|
||||||
import generateUserToken from '../common/generate-native-user-token';
|
import generateUserToken from '../common/generate-native-user-token';
|
||||||
import config from '../../conf';
|
import config from '../../conf';
|
||||||
|
|
||||||
|
@ -142,7 +142,7 @@ export default async (req: express.Request, res: express.Response) => {
|
||||||
});
|
});
|
||||||
|
|
||||||
// Response
|
// Response
|
||||||
res.send(await serialize(account));
|
res.send(await pack(account));
|
||||||
|
|
||||||
// Create search index
|
// Create search index
|
||||||
if (config.elasticsearch.enable) {
|
if (config.elasticsearch.enable) {
|
||||||
|
|
|
@ -6,7 +6,7 @@ import * as uuid from 'uuid';
|
||||||
import autwh from 'autwh';
|
import autwh from 'autwh';
|
||||||
import redis from '../../db/redis';
|
import redis from '../../db/redis';
|
||||||
import User from '../models/user';
|
import User from '../models/user';
|
||||||
import serialize from '../serializers/user';
|
import { pack } from '../models/user';
|
||||||
import event from '../event';
|
import event from '../event';
|
||||||
import config from '../../conf';
|
import config from '../../conf';
|
||||||
import signin from '../common/signin';
|
import signin from '../common/signin';
|
||||||
|
@ -50,7 +50,7 @@ module.exports = (app: express.Application) => {
|
||||||
res.send(`Twitterの連携を解除しました :v:`);
|
res.send(`Twitterの連携を解除しました :v:`);
|
||||||
|
|
||||||
// Publish i updated event
|
// Publish i updated event
|
||||||
event(user._id, 'i_updated', await serialize(user, user, {
|
event(user._id, 'i_updated', await pack(user, user, {
|
||||||
detail: true,
|
detail: true,
|
||||||
includeSecrets: true
|
includeSecrets: true
|
||||||
}));
|
}));
|
||||||
|
|
Loading…
Reference in a new issue