|  | @ -21,11 +21,12 @@ let redis = RedisClient.redisClient().connection;
 | 
	
		
			
				|  |  | let logger = require('../../util/log.js');
 | 
	
		
			
				|  |  | let mongoose = require('mongoose');
 | 
	
		
			
				|  |  | let async = require("async");
 | 
	
		
			
				|  |  | var log = require("../../util/log.js");
 | 
	
		
			
				|  |  | let log = require("../../util/log.js");
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | const REDIS_KEYS = require('../../include/commons').REDIS_KEYS;
 | 
	
		
			
				|  |  | const SESSION_TYPES = require('../../include/commons').SESSION_TYPES;
 | 
	
		
			
				|  |  | const STICKY_SESSION_BASE_SCORE = require('../../include/commons').STICKY_SESSION_BASE_SCORE;
 | 
	
		
			
				|  |  | const PARTICIPANT_ROLES = require('../../include/commons').PARTICIPANT_ROLES;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | class Sessions extends RedisModel {
 | 
	
		
			
				|  |  |     constructor() {
 | 
	
	
		
			
				|  | @ -132,7 +133,7 @@ class Sessions extends RedisModel {
 | 
	
		
			
				|  |  |                 timestamp: createDate,
 | 
	
		
			
				|  |  |                 id: messageId
 | 
	
		
			
				|  |  |             };
 | 
	
		
			
				|  |  |             if(type == SESSION_TYPES.MUC){
 | 
	
		
			
				|  |  |             if (type == SESSION_TYPES.MUC) {
 | 
	
		
			
				|  |  |                 businessType = 2;
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             let session = {
 | 
	
	
		
			
				|  | @ -202,7 +203,7 @@ class Sessions extends RedisModel {
 | 
	
		
			
				|  |  |             //查找该sessionId是否存在存在则直接返回实例
 | 
	
		
			
				|  |  |             SessionRepo.findOne(sessionId, function (err, res) {
 | 
	
		
			
				|  |  |                 if (res.length > 0) {//已经存在
 | 
	
		
			
				|  |  |                      //更新成员
 | 
	
		
			
				|  |  |                     //更新成员
 | 
	
		
			
				|  |  |                     Participants.saveParticipantsToMysql(sessionId, participantArray, function (err, update) {
 | 
	
		
			
				|  |  |                         handler(null, res[0]);
 | 
	
		
			
				|  |  |                         return;
 | 
	
	
		
			
				|  | @ -236,7 +237,7 @@ class Sessions extends RedisModel {
 | 
	
		
			
				|  |  |                 if (err) {
 | 
	
		
			
				|  |  |                     handler(err, null);
 | 
	
		
			
				|  |  |                     return;
 | 
	
		
			
				|  |  |                 }else{
 | 
	
		
			
				|  |  |                 } else {
 | 
	
		
			
				|  |  |                     handler(null, session);
 | 
	
		
			
				|  |  |                     return;
 | 
	
		
			
				|  |  |                 }
 | 
	
	
		
			
				|  | @ -385,12 +386,12 @@ class Sessions extends RedisModel {
 | 
	
		
			
				|  |  |                                                 sessionName = res[0].name;
 | 
	
		
			
				|  |  |                                             }
 | 
	
		
			
				|  |  |                                             var bir = new Date().getTime();
 | 
	
		
			
				|  |  |                                             if(res.length!=0&&res[0].birthdate){
 | 
	
		
			
				|  |  |                                             if (res.length != 0 && res[0].birthdate) {
 | 
	
		
			
				|  |  |                                                 bir = res[0].birthdate.getTime();
 | 
	
		
			
				|  |  |                                             }
 | 
	
		
			
				|  |  |                                             var sex = 1;
 | 
	
		
			
				|  |  |                                             if(res.length!=0&&res[0].sex){
 | 
	
		
			
				|  |  |                                                 sex =   res[0].sex;
 | 
	
		
			
				|  |  |                                             if (res.length != 0 && res[0].sex) {
 | 
	
		
			
				|  |  |                                                 sex = res[0].sex;
 | 
	
		
			
				|  |  |                                             }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |                                             sessionList.push({
 | 
	
	
		
			
				|  | @ -405,8 +406,8 @@ class Sessions extends RedisModel {
 | 
	
		
			
				|  |  |                                                 unread_count: count,
 | 
	
		
			
				|  |  |                                                 business_type: session.business_type,
 | 
	
		
			
				|  |  |                                                 my_role: role,
 | 
	
		
			
				|  |  |                                                 sender_sex:sex,
 | 
	
		
			
				|  |  |                                                 sender_birthday:bir,
 | 
	
		
			
				|  |  |                                                 sender_sex: sex,
 | 
	
		
			
				|  |  |                                                 sender_birthday: bir,
 | 
	
		
			
				|  |  |                                             });
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |                                             index = (parseInt(index) + 1);
 | 
	
	
		
			
				|  | @ -591,7 +592,7 @@ class Sessions extends RedisModel {
 | 
	
		
			
				|  |  |                         let startMsgScore = res[1];
 | 
	
		
			
				|  |  |                         let endMsgScore = res[0];
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |                         if (startMsgScore == null || endMsgScore == null || (startMsgScore == endMsgScore&&isoffset==1)) {
 | 
	
		
			
				|  |  |                         if (startMsgScore == null || endMsgScore == null || (startMsgScore == endMsgScore && isoffset == 1)) {
 | 
	
		
			
				|  |  |                             handler(null, []);
 | 
	
		
			
				|  |  |                             return;
 | 
	
		
			
				|  |  |                         }
 | 
	
	
		
			
				|  | @ -657,13 +658,13 @@ class Sessions extends RedisModel {
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |                 count = count + con;
 | 
	
		
			
				|  |  |                 if(session.type ==2){
 | 
	
		
			
				|  |  |                     patientCount = patientCount+con;
 | 
	
		
			
				|  |  |                 }else{
 | 
	
		
			
				|  |  |                     doctorCount = doctorCount+con;
 | 
	
		
			
				|  |  |                 if (session.type == 2) {
 | 
	
		
			
				|  |  |                     patientCount = patientCount + con;
 | 
	
		
			
				|  |  |                 } else {
 | 
	
		
			
				|  |  |                     doctorCount = doctorCount + con;
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |                 if (j == res.length - 1) {
 | 
	
		
			
				|  |  |                     ModelUtil.emitOK(self.eventEmitter, {count: count,patient:patientCount,doctor:doctorCount});
 | 
	
		
			
				|  |  |                     ModelUtil.emitOK(self.eventEmitter, {count: count, patient: patientCount, doctor: doctorCount});
 | 
	
		
			
				|  |  |                 }
 | 
	
		
			
				|  |  |             })
 | 
	
		
			
				|  |  |         }
 | 
	
	
		
			
				|  | @ -819,11 +820,9 @@ class Sessions extends RedisModel {
 | 
	
		
			
				|  |  |                         } else {
 | 
	
		
			
				|  |  |                             message.session_id = sessionId;
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |                             log.info("Candidate to push: " + participants);
 | 
	
		
			
				|  |  |                             res.forEach(function (participant) {
 | 
	
		
			
				|  |  |                                 if (participant.id !== message.sender_id) {
 | 
	
		
			
				|  |  |                                     log.warn('Push message to ' + participant.id);
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |                                 if (participant.id !== message.sender_id &&
 | 
	
		
			
				|  |  |                                     participant.participant_role == PARTICIPANT_ROLES.HOST) {
 | 
	
		
			
				|  |  |                                     Sessions.pushNotification(participant.id, message);
 | 
	
		
			
				|  |  |                                 }
 | 
	
		
			
				|  |  |                             });
 |