forked from FoundKeyGang/FoundKey
wip
This commit is contained in:
parent
2cb0511dba
commit
bcd65d290d
23 changed files with 48 additions and 43 deletions
src/api
endpoints
aggregation
app
channels
drive
following
i
posts/reactions
users
models
private
service
stream
|
@ -35,10 +35,13 @@ module.exports = (params) => new Promise(async (res, rej) => {
|
|||
{ deleted_at: { $gt: startTime } }
|
||||
]
|
||||
}, {
|
||||
_id: false,
|
||||
post_id: false
|
||||
}, {
|
||||
sort: { created_at: -1 }
|
||||
sort: {
|
||||
_id: -1
|
||||
},
|
||||
fields: {
|
||||
_id: false,
|
||||
post_id: false
|
||||
}
|
||||
});
|
||||
|
||||
const graph = [];
|
||||
|
|
|
@ -17,11 +17,14 @@ module.exports = params => new Promise(async (res, rej) => {
|
|||
|
||||
const users = await User
|
||||
.find({}, {
|
||||
_id: false,
|
||||
created_at: true,
|
||||
deleted_at: true
|
||||
}, {
|
||||
sort: { created_at: -1 }
|
||||
sort: {
|
||||
_id: -1
|
||||
},
|
||||
fields: {
|
||||
_id: false,
|
||||
created_at: true,
|
||||
deleted_at: true
|
||||
}
|
||||
});
|
||||
|
||||
const graph = [];
|
||||
|
|
|
@ -3,8 +3,7 @@
|
|||
*/
|
||||
import rndstr from 'rndstr';
|
||||
import $ from 'cafy';
|
||||
import App from '../../models/app';
|
||||
import { isValidNameId }, { pack } from '../../models/app';
|
||||
import App, { isValidNameId, pack } from '../../models/app';
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* Module dependencies
|
||||
*/
|
||||
import $ from 'cafy';
|
||||
import { default as Channel, IChannel }, { pack } from '../../models/channel';
|
||||
import Channel, { IChannel, pack } from '../../models/channel';
|
||||
|
||||
/**
|
||||
* Show a channel
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* Module dependencies
|
||||
*/
|
||||
import $ from 'cafy';
|
||||
import { validateFileName }, { pack } from '../../../models/drive-file';
|
||||
import { validateFileName, pack } from '../../../models/drive-file';
|
||||
import create from '../../../common/add-file-to-drive';
|
||||
|
||||
/**
|
||||
|
|
|
@ -3,8 +3,7 @@
|
|||
*/
|
||||
import $ from 'cafy';
|
||||
import DriveFolder from '../../../models/drive-folder';
|
||||
import DriveFile from '../../../models/drive-file';
|
||||
import { validateFileName }, { pack } from '../../../models/drive-file';
|
||||
import DriveFile, { validateFileName, pack } from '../../../models/drive-file';
|
||||
import { publishDriveStream } from '../../../event';
|
||||
|
||||
/**
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
*/
|
||||
import * as URL from 'url';
|
||||
import $ from 'cafy';
|
||||
import { validateFileName }, { pack } from '../../../models/drive-file';
|
||||
import { validateFileName, pack } from '../../../models/drive-file';
|
||||
import create from '../../../common/add-file-to-drive';
|
||||
import * as debug from 'debug';
|
||||
import * as tmp from 'tmp';
|
||||
|
|
|
@ -2,8 +2,7 @@
|
|||
* Module dependencies
|
||||
*/
|
||||
import $ from 'cafy';
|
||||
import DriveFolder from '../../../models/drive-folder';
|
||||
import { isValidFolderName }, { pack } from '../../../models/drive-folder';
|
||||
import DriveFolder, { isValidFolderName, pack } from '../../../models/drive-folder';
|
||||
import { publishDriveStream } from '../../../event';
|
||||
|
||||
/**
|
||||
|
|
|
@ -2,8 +2,7 @@
|
|||
* Module dependencies
|
||||
*/
|
||||
import $ from 'cafy';
|
||||
import DriveFolder from '../../../models/drive-folder';
|
||||
import { isValidFolderName }, { pack } from '../../../models/drive-folder';
|
||||
import DriveFolder, { isValidFolderName, pack } from '../../../models/drive-folder';
|
||||
import { publishDriveStream } from '../../../event';
|
||||
|
||||
/**
|
||||
|
|
|
@ -2,11 +2,10 @@
|
|||
* Module dependencies
|
||||
*/
|
||||
import $ from 'cafy';
|
||||
import User from '../../models/user';
|
||||
import User, { pack as packUser } from '../../models/user';
|
||||
import Following from '../../models/following';
|
||||
import notify from '../../common/notify';
|
||||
import event from '../../event';
|
||||
import serializeUser from '../../serializers/user';
|
||||
|
||||
/**
|
||||
* Follow a user
|
||||
|
@ -77,8 +76,8 @@ module.exports = (params, user) => new Promise(async (res, rej) => {
|
|||
});
|
||||
|
||||
// Publish follow event
|
||||
event(follower._id, 'follow', await serializeUser(followee, follower));
|
||||
event(followee._id, 'followed', await serializeUser(follower, followee));
|
||||
event(follower._id, 'follow', await packUser(followee, follower));
|
||||
event(followee._id, 'followed', await packUser(follower, followee));
|
||||
|
||||
// Notify
|
||||
notify(followee._id, follower._id, 'follow');
|
||||
|
|
|
@ -2,10 +2,9 @@
|
|||
* Module dependencies
|
||||
*/
|
||||
import $ from 'cafy';
|
||||
import User from '../../models/user';
|
||||
import User, { pack as packUser } from '../../models/user';
|
||||
import Following from '../../models/following';
|
||||
import event from '../../event';
|
||||
import serializeUser from '../../serializers/user';
|
||||
|
||||
/**
|
||||
* Unfollow a user
|
||||
|
@ -78,5 +77,5 @@ module.exports = (params, user) => new Promise(async (res, rej) => {
|
|||
});
|
||||
|
||||
// Publish follow event
|
||||
event(follower._id, 'unfollow', await serializeUser(followee, follower));
|
||||
event(follower._id, 'unfollow', await packUser(followee, follower));
|
||||
});
|
||||
|
|
|
@ -2,8 +2,7 @@
|
|||
* Module dependencies
|
||||
*/
|
||||
import $ from 'cafy';
|
||||
import User from '../../models/user';
|
||||
import { isValidName, isValidDescription, isValidLocation, isValidBirthday }, { pack } from '../../models/user';
|
||||
import User, { isValidName, isValidDescription, isValidLocation, isValidBirthday, pack } from '../../models/user';
|
||||
import event from '../../event';
|
||||
import config from '../../../conf';
|
||||
|
||||
|
|
|
@ -3,13 +3,12 @@
|
|||
*/
|
||||
import $ from 'cafy';
|
||||
import Reaction from '../../../models/post-reaction';
|
||||
import Post from '../../../models/post';
|
||||
import Post, { pack as packPost } from '../../../models/post';
|
||||
import { pack as packUser } from '../../../models/user';
|
||||
import Watching from '../../../models/post-watching';
|
||||
import notify from '../../../common/notify';
|
||||
import watch from '../../../common/watch-post';
|
||||
import { publishPostStream, pushSw } from '../../../event';
|
||||
import serializePost from '../../../serializers/post';
|
||||
import serializeUser from '../../../serializers/user';
|
||||
|
||||
/**
|
||||
* React to a post
|
||||
|
@ -90,8 +89,8 @@ module.exports = (params, user) => new Promise(async (res, rej) => {
|
|||
});
|
||||
|
||||
pushSw(post.user_id, 'reaction', {
|
||||
user: await serializeUser(user, post.user_id),
|
||||
post: await serializePost(post, post.user_id),
|
||||
user: await packUser(user, post.user_id),
|
||||
post: await packPost(post, post.user_id),
|
||||
reaction: reaction
|
||||
});
|
||||
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
* Module dependencies
|
||||
*/
|
||||
import $ from 'cafy';
|
||||
import Post from '../../models/post';
|
||||
import User, { pack } from '../../models/user';
|
||||
import Post, { pack } from '../../models/post';
|
||||
import User from '../../models/user';
|
||||
|
||||
/**
|
||||
* Get posts of a user
|
||||
|
|
|
@ -51,7 +51,7 @@ async function byNative(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 }))));
|
||||
}
|
||||
|
||||
// Search by Elasticsearch
|
||||
|
|
|
@ -14,6 +14,7 @@ export type IApp = {
|
|||
_id: mongo.ObjectID;
|
||||
created_at: Date;
|
||||
user_id: mongo.ObjectID;
|
||||
secret: string;
|
||||
};
|
||||
|
||||
export function isValidNameId(nameId: string): boolean {
|
||||
|
|
|
@ -23,6 +23,7 @@ export type IDriveFile = {
|
|||
uploadDate: Date;
|
||||
md5: string;
|
||||
filename: string;
|
||||
contentType: string;
|
||||
metadata: {
|
||||
properties: any;
|
||||
user_id: mongodb.ObjectID;
|
||||
|
|
|
@ -9,6 +9,9 @@ export default PostReaction;
|
|||
|
||||
export interface IPostReaction {
|
||||
_id: mongo.ObjectID;
|
||||
created_at: Date;
|
||||
deleted_at: Date;
|
||||
reaction: string;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -25,10 +25,12 @@ export type IPost = {
|
|||
media_ids: mongo.ObjectID[];
|
||||
reply_id: mongo.ObjectID;
|
||||
repost_id: mongo.ObjectID;
|
||||
poll: {}; // todo
|
||||
poll: any; // todo
|
||||
text: string;
|
||||
user_id: mongo.ObjectID;
|
||||
app_id: mongo.ObjectID;
|
||||
category: string;
|
||||
is_category_verified: boolean;
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
@ -42,6 +42,7 @@ export function isValidBirthday(birthday: string): boolean {
|
|||
export type IUser = {
|
||||
_id: mongo.ObjectID;
|
||||
created_at: Date;
|
||||
deleted_at: Date;
|
||||
email: string;
|
||||
followers_count: number;
|
||||
following_count: number;
|
||||
|
|
|
@ -2,8 +2,7 @@ import * as uuid from 'uuid';
|
|||
import * as express from 'express';
|
||||
import * as bcrypt from 'bcryptjs';
|
||||
import recaptcha = require('recaptcha-promise');
|
||||
import { default as User, IUser } from '../models/user';
|
||||
import { validateUsername, validatePassword }, { pack } from '../models/user';
|
||||
import User, { IUser, validateUsername, validatePassword, pack } from '../models/user';
|
||||
import generateUserToken from '../common/generate-native-user-token';
|
||||
import config from '../../conf';
|
||||
|
||||
|
|
|
@ -163,7 +163,7 @@ module.exports = (app: express.Application) => {
|
|||
res.send(`Twitter: @${result.screenName} を、Misskey: @${user.username} に接続しました!`);
|
||||
|
||||
// Publish i updated event
|
||||
event(user._id, 'i_updated', await serialize(user, user, {
|
||||
event(user._id, 'i_updated', await pack(user, user, {
|
||||
detail: true,
|
||||
includeSecrets: true
|
||||
}));
|
||||
|
|
|
@ -4,7 +4,7 @@ import * as debug from 'debug';
|
|||
|
||||
import User from '../models/user';
|
||||
import Mute from '../models/mute';
|
||||
import serializePost from '../serializers/post';
|
||||
import { pack as packPost } from '../models/post';
|
||||
import readNotification from '../common/read-notification';
|
||||
|
||||
const log = debug('misskey');
|
||||
|
@ -49,7 +49,7 @@ export default async function(request: websocket.request, connection: websocket.
|
|||
case 'post-stream':
|
||||
const postId = channel.split(':')[2];
|
||||
log(`RECEIVED: ${postId} ${data} by @${user.username}`);
|
||||
const post = await serializePost(postId, user, {
|
||||
const post = await packPost(postId, user, {
|
||||
detail: true
|
||||
});
|
||||
connection.send(JSON.stringify({
|
||||
|
|
Loading…
Reference in a new issue