|
@@ -20,6 +20,8 @@ import { RoomService } from '../service/room.service';
|
|
|
import get = require('lodash/get');
|
|
|
import { MqSender } from '../service/mq/mqSender.service';
|
|
|
import { WsSocketController } from '../socket/ws.controller';
|
|
|
+import { Types } from 'mongoose';
|
|
|
+const ObjectId = Types.ObjectId;
|
|
|
@ApiTags(['聊天记录'])
|
|
|
@Controller('/chatRecord')
|
|
|
export class ChatRecordController extends BaseController {
|
|
@@ -70,9 +72,9 @@ export class ChatRecordController extends BaseController {
|
|
|
await this.roomService.updateOne(data.room, rd);
|
|
|
const room = await this.roomService.fetch(data.room);
|
|
|
let receiver;
|
|
|
- if (get(room, 'customer') === get(data, 'speaker')) receiver = get(room, 'shop._id');
|
|
|
+ if (new ObjectId(get(room, 'customer._id')).equals(get(data, 'speaker'))) receiver = get(room, 'shop._id');
|
|
|
else receiver = get(room, 'customer._id');
|
|
|
- await this.ws.toSend({ ...result, type: 'chat' }, receiver);
|
|
|
+ await this.ws.toSend({ ...JSON.parse(JSON.stringify(result)), type: 'chat' }, receiver);
|
|
|
return result;
|
|
|
}
|
|
|
@Get('/')
|