|
@ -66,8 +66,10 @@ class WechatClient extends RedisModel {
|
|
log.warn("User's wechat endpoint is online, sending via web socket. User id: ", targetUserId);
|
|
log.warn("User's wechat endpoint is online, sending via web socket. User id: ", targetUserId);
|
|
WechatClient.sendViaWebSocket(patientClient.socket, message);
|
|
WechatClient.sendViaWebSocket(patientClient.socket, message);
|
|
if(doctorClient){
|
|
if(doctorClient){
|
|
|
|
if(patientClient.sessionId==doctorClient.sessionId){
|
|
//用户socket在线,推送给用户后,告知医生此消息已读
|
|
//用户socket在线,推送给用户后,告知医生此消息已读
|
|
WechatClient.sendReadDoctor(doctorClient.socket, message);
|
|
|
|
|
|
WechatClient.sendReadDoctor(doctorClient.socket, message);
|
|
|
|
}
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
log.info("User's wechat endpoint is not online, sending via wechat template message. User id: ", targetUserId);
|
|
log.info("User's wechat endpoint is not online, sending via wechat template message. User id: ", targetUserId);
|
|
@ -94,6 +96,7 @@ class WechatClient extends RedisModel {
|
|
static sendAllRead(doctorId,sessionId){
|
|
static sendAllRead(doctorId,sessionId){
|
|
let doctorClient = clientCache.findByIdAndType(doctorId,SOCKET_TYPES.DOCTOR);
|
|
let doctorClient = clientCache.findByIdAndType(doctorId,SOCKET_TYPES.DOCTOR);
|
|
if(doctorClient){
|
|
if(doctorClient){
|
|
|
|
if(doctorClient.sessionId==sessionId)
|
|
doctorClient.socket.emit('message',{ read:"all"});
|
|
doctorClient.socket.emit('message',{ read:"all"});
|
|
}else{
|
|
}else{
|
|
log.warn(doctorId+" target doctor is not online!");
|
|
log.warn(doctorId+" target doctor is not online!");
|
|
@ -122,22 +125,23 @@ class WechatClient extends RedisModel {
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
let sendDoctorClient = clientCache.findByIdAndType(message.sender_id,SOCKET_TYPES.DOCTOR);
|
|
let sendDoctorClient = clientCache.findByIdAndType(message.sender_id,SOCKET_TYPES.DOCTOR);
|
|
sendDoctorClient.socket.emit('message', {
|
|
|
|
id: message.id,
|
|
|
|
session_id: message.session_id,
|
|
|
|
sender_id: message.sender_id,
|
|
|
|
sender_name: message.sender_name,
|
|
|
|
content_type: message.content_type,
|
|
|
|
content: message.content,
|
|
|
|
timestamp: ObjectUtil.timestampToLong(message.timestamp),
|
|
|
|
type: message.content_type, // legacy support
|
|
|
|
name: message.sender_name,
|
|
|
|
read:"one"
|
|
|
|
});
|
|
|
|
|
|
if(sendDoctorClient.sessionId==doctorClient.sessionId){
|
|
|
|
sendDoctorClient.socket.emit('message', {
|
|
|
|
id: message.id,
|
|
|
|
session_id: message.session_id,
|
|
|
|
sender_id: message.sender_id,
|
|
|
|
sender_name: message.sender_name,
|
|
|
|
content_type: message.content_type,
|
|
|
|
content: message.content,
|
|
|
|
timestamp: ObjectUtil.timestampToLong(message.timestamp),
|
|
|
|
type: message.content_type, // legacy support
|
|
|
|
name: message.sender_name,
|
|
|
|
read:"one"
|
|
|
|
});
|
|
|
|
}else{
|
|
|
|
log.warn("doctor is not in the same session");
|
|
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
* 发送微信模板消息给居民
|
|
* 发送微信模板消息给居民
|
|
*
|
|
*
|