|
@ -49,6 +49,10 @@ class Sessions extends RedisModel {
|
|
|
//创建session到mysql
|
|
|
self.createSessionToMysql(sessionId, name, type, participantArray, messageId, function (err, res) {
|
|
|
if (err) {
|
|
|
if (handler) {
|
|
|
handler(err, null);
|
|
|
return;
|
|
|
}
|
|
|
ModelUtil.emitError(self.eventEmitter, {message: err, status: -1}, null);
|
|
|
} else {
|
|
|
//创建session到redis
|
|
@ -198,12 +202,11 @@ class Sessions extends RedisModel {
|
|
|
//查找该sessionId是否存在存在则直接返回实例
|
|
|
SessionRepo.findOne(sessionId, function (err, res) {
|
|
|
if (res.length > 0) {//已经存在
|
|
|
for (let i in participantArray) {
|
|
|
//更新成员
|
|
|
Participants.saveParticipantsToMysql(sessionId, participantArray, function (err, update) {
|
|
|
handler(null, res[0]);
|
|
|
})
|
|
|
}
|
|
|
Participants.saveParticipantsToMysql(sessionId, participantArray, function (err, update) {
|
|
|
handler(null, res[0]);
|
|
|
return;
|
|
|
})
|
|
|
} else {
|
|
|
let createDate = new Date();
|
|
|
let session = {
|
|
@ -220,7 +223,6 @@ class Sessions extends RedisModel {
|
|
|
handler(err, null);
|
|
|
return;
|
|
|
}
|
|
|
;
|
|
|
callCreateParticipants(session);
|
|
|
})
|
|
|
|
|
@ -234,42 +236,12 @@ class Sessions extends RedisModel {
|
|
|
if (err) {
|
|
|
handler(err, null);
|
|
|
return;
|
|
|
}else{
|
|
|
handler(null, session);
|
|
|
return;
|
|
|
}
|
|
|
// callBeginTrans(session);
|
|
|
})
|
|
|
}
|
|
|
|
|
|
//流程5-发起session会话
|
|
|
function callBeginTrans(session) {
|
|
|
let mesDate = new Date();
|
|
|
let message = {
|
|
|
sender_id: "system",
|
|
|
sender_name: "system",
|
|
|
content_type: 6,
|
|
|
content: "会话创建成功",
|
|
|
timestamp: mesDate,
|
|
|
id: messageId
|
|
|
};
|
|
|
|
|
|
session.last_sender_id = message.sender_id;
|
|
|
session.last_sender_name = message.sender_name;
|
|
|
session.last_message_time = mesDate.getTime();
|
|
|
session.last_content = message.content;
|
|
|
session.last_content_type = message.content_type;
|
|
|
|
|
|
SessionRepo.updateSessionLastStatus(message.sender_id,
|
|
|
message.sender_name,
|
|
|
message.timestamp,
|
|
|
message.content,
|
|
|
message.content_type,
|
|
|
sessionId, function (err, res) {
|
|
|
if (err) {
|
|
|
handler(err, null);
|
|
|
return;
|
|
|
}
|
|
|
handler(null, session);
|
|
|
});
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|