|
@ -10,7 +10,7 @@ let ModelUtil = require('../../util/model.util');
|
|
|
let WechatSDK = require('../../util/wechat.sdk');
|
|
|
let PatientRepo = require('../../repository/mysql/patient.repo');
|
|
|
let TopicRepo = require("../../repository/mysql/topics.repo.js");
|
|
|
|
|
|
let ParticipantRepo = require("../../repository/mysql/participant.repo");
|
|
|
let redisConn = RedisClient.redisClient().connection;
|
|
|
let clientCache = require('../socket.io/client.cache').clientCache();
|
|
|
let configFile = require('../../include/commons').CONFIG_FILE;
|
|
@ -71,6 +71,7 @@ class WechatClient extends RedisModel {
|
|
|
log.error("patient sessionid "+patientClient.sessionId);
|
|
|
if(patientClient.sessionId==doctorClient.sessionId){
|
|
|
//用户socket在线,推送给用户后,告知医生此消息已读
|
|
|
WechatClient.updateParticipantLastFetchTime(doctorClient.sessionId, targetUserId, ObjectUtil.timestampToLong(message.timestamp));
|
|
|
WechatClient.sendReadDoctor(doctorClient.socket, message);
|
|
|
}
|
|
|
}else{
|
|
@ -156,6 +157,7 @@ class WechatClient extends RedisModel {
|
|
|
}
|
|
|
let sendDoctorClient = clientCache.findByIdAndType(message.sender_id,SOCKET_TYPES.DOCTOR);
|
|
|
if(sendDoctorClient&&sendDoctorClient.sessionId==doctorClient.sessionId){
|
|
|
WechatClient.updateParticipantLastFetchTime(doctorClient.sessionId, doctorId, ObjectUtil.timestampToLong(message.timestamp));
|
|
|
sendDoctorClient.socket.emit('message', {
|
|
|
id: message.id,
|
|
|
session_id: message.session_id,
|
|
@ -184,6 +186,7 @@ class WechatClient extends RedisModel {
|
|
|
sendDoctorClient = clientCache.findByIdAndType(doctorId,SOCKET_TYPES.PATIENT);
|
|
|
}
|
|
|
if(sendDoctorClient&&sendDoctorClient.sessionId==doctorClient.sessionId){
|
|
|
WechatClient.updateParticipantLastFetchTime(doctorClient.sessionId, doctorId, ObjectUtil.timestampToLong(message.timestamp));
|
|
|
doctorClient.socket.emit('message', {
|
|
|
id: message.id,
|
|
|
session_id: message.session_id,
|
|
@ -282,6 +285,23 @@ class WechatClient extends RedisModel {
|
|
|
}
|
|
|
});
|
|
|
};
|
|
|
|
|
|
|
|
|
static updateParticipantLastFetchTime(sessionId, userId, score) {
|
|
|
score = score + 1000;
|
|
|
let participantsKey = RedisModel.makeRedisKey(REDIS_KEYS.SessionParticipants, sessionId);
|
|
|
redisConn.zaddAsync(participantsKey, score, userId)
|
|
|
.then(function (res) {
|
|
|
ParticipantRepo.updateLastFetchTime(new Date(score), sessionId, userId, function (err, res) {
|
|
|
if (err) {
|
|
|
log.error("Update participant last fetch time failed: ", err);
|
|
|
}
|
|
|
});
|
|
|
})
|
|
|
.catch(function (err) {
|
|
|
log.error("Update participant last fetch time failed: ", err);
|
|
|
});
|
|
|
}
|
|
|
}
|
|
|
|
|
|
module.exports = WechatClient;
|