perf: 优化结构与导出方式

pull/64/head
moonrailgun 2 years ago
parent 5c0736732f
commit 58dba494a0

@ -1 +1 @@
export { Types } from 'mongoose';
export { Types, isValidObjectId } from 'mongoose';

@ -25,7 +25,11 @@ export {
} from './services/lib/settings';
// struct
export type { MessageMetaStruct } from './structs/chat';
export type {
MessageStruct,
MessageReactionStruct,
MessageMetaStruct,
} from './structs/chat';
export type { BuiltinEventMap } from './structs/events';
export type {
GroupStruct,

@ -1,3 +1,18 @@
export interface MessageReactionStruct {
name: string;
author?: string;
}
export interface MessageStruct {
_id: string;
content: string;
author: string;
groupId?: string;
converseId: string;
hasRecall: boolean;
reactions: MessageReactionStruct[];
}
export interface MessageMetaStruct {
mentions?: string[];
reply?: {

@ -17,16 +17,18 @@ import {
Errors,
DataNotFoundError,
EntityError,
db,
} from 'tailchat-server-sdk';
import {
generateRandomNumStr,
generateRandomStr,
getEmailAddress,
} from '../../../lib/utils';
import { Types } from 'mongoose';
import type { TFunction } from 'i18next';
import _ from 'lodash';
const { isValidObjectId, Types } = db;
/**
*
*/
@ -543,6 +545,9 @@ class UserService extends TcService {
async getUserInfoList(ctx: PureContext<{ userIds: string[] }>) {
const userIds = ctx.params.userIds;
if (userIds.some((userId) => !isValidObjectId(userId))) {
throw new EntityError('Include invalid userId');
}
const list = await Promise.all(
userIds.map((userId) =>
ctx.call('user.getUserInfo', {

Loading…
Cancel
Save