|
@ -976,6 +976,7 @@ class Sessions extends RedisModel {
|
|
|
let message_timestamp_key = RedisModel.makeRedisKey(REDIS_KEYS.MessagesByTimestamp, sessionId);
|
|
|
if (!start_msg_id && !end_msg_id) {
|
|
|
redis.zrevrangeAsync(message_timestamp_key, 0, 0).then(function (res) {
|
|
|
logger.info("redis return res-----"+res);
|
|
|
if (res.length == 0) {
|
|
|
//修复应redis没有缓冲聊天记录导致会话列表加载不出来
|
|
|
// cache messages
|
|
@ -1422,6 +1423,7 @@ class Sessions extends RedisModel {
|
|
|
let sessionKey = RedisModel.makeRedisKey(REDIS_KEYS.Session, sessionId);
|
|
|
let messageId = mongoose.Types.ObjectId().toString();
|
|
|
let sessionType =0;
|
|
|
let sessionName;
|
|
|
message.id = messageId;
|
|
|
|
|
|
// 检查会话中是否存在此成员
|
|
@ -1436,8 +1438,49 @@ class Sessions extends RedisModel {
|
|
|
sessionType = res[0];
|
|
|
let sessionName = res[1];
|
|
|
if (sessionType == null) {
|
|
|
ModelUtil.emitError(self.eventEmitter, "Session " + sessionId + " is not found.");
|
|
|
return;
|
|
|
self.getSessions(sessionId,function(err,res){
|
|
|
if (err){
|
|
|
logger.error("session data is error");
|
|
|
} else {
|
|
|
sessionName=res[0].name;
|
|
|
sessionType = res[0].type;
|
|
|
}
|
|
|
});
|
|
|
let participantArray = [];
|
|
|
let participantsStr="{";
|
|
|
ParticipantRepo.findAll(sessionId, function (err, participants) {
|
|
|
if (err) {
|
|
|
ModelUtil.emitError(self.eventEmitter, err.message);
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
participants.forEach(function (participant) {
|
|
|
let participantId = participant.id;
|
|
|
let participantRole = participant.role;
|
|
|
let score = ObjectUtil.timestampToLong(participant.last_fetch_time||(new Date()));
|
|
|
participantsStr +="\""+participantId+"\":\""+participantRole+"\",";
|
|
|
});
|
|
|
|
|
|
participantsStr = participantsStr.substring(0,participantsStr.length-1)+'}';
|
|
|
participantsStr = JSON.parse(participantsStr);
|
|
|
for (let j in participantsStr) {
|
|
|
participantArray.push(j + ":" + participantsStr[j]);
|
|
|
}
|
|
|
//创建session到redis
|
|
|
self.createSessionToRedis(sessionId, sessionName, sessionType, participantArray, messageId, function (err, res) {
|
|
|
if (err) {
|
|
|
if (handler) {
|
|
|
handler(err, null);
|
|
|
}
|
|
|
ModelUtil.emitError(self.eventEmitter, {message: err, status: -1}, null);
|
|
|
} else {
|
|
|
if (handler) {
|
|
|
handler(null, res);
|
|
|
}
|
|
|
ModelUtil.emitOK(self.eventEmitter, {status: 200, data: res});
|
|
|
}
|
|
|
});
|
|
|
});
|
|
|
}
|
|
|
if(sessionType == SESSION_TYPES.MUC || sessionType == SESSION_TYPES.PRESCRIPTION){
|
|
|
if(message.content_type == CONTENT_TYPES.PlainText ||
|