Browse Source

发起和结束咨询的消息由系统发出,发送者ID记录操作人!

8 years ago
parent
commit
6727b9b18a

+ 1 - 1
src/server/models/client/app.client.js

@ -123,7 +123,7 @@ class AppClient extends RedisModel {
                if (userStatus.platform == PLATFORMS.iOS) {
                    pusher.pushToSingleViaAPN(tipMessage, customData, message.contentType, userStatus.device_token, function (err, res) {
                        if (err) {
                            ModelUtil.logError("Send notification via APN failed", err);
                            ModelUtil.logError("Send notification via APN failed:"+userStatus.device_token, err);
                        } else {
                            log.info("Send notification via APN succeed: ", JSON.stringify(res));
                        }

+ 27 - 0
src/server/models/client/wechat.client.js

@ -172,6 +172,33 @@ class WechatClient extends RedisModel {
            log.warn("doctor is not in the same session");
        }
    }
    static sendSocketMessageToDoctor(doctorId, message) {
        let doctorClient = clientCache.findByIdAndType(doctorId,SOCKET_TYPES.DOCTOR);
        if(!doctorClient){
            log.warn("target doctor is not online!");
            return;
        }
        let sendDoctorClient = clientCache.findByIdAndType(message.sender_id,SOCKET_TYPES.DOCTOR);
        if(!sendDoctorClient){
            sendDoctorClient = clientCache.findByIdAndType(doctorId,SOCKET_TYPES.PATIENT);
        }
        if(sendDoctorClient&&sendDoctorClient.sessionId==doctorClient.sessionId){
            doctorClient.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,
            });
        }else{
            log.warn("doctor is not in the same session");
        }
    }
    /**
     * 发送微信模板消息给居民
     *

+ 1 - 1
src/server/models/push/pusher.js

@ -67,7 +67,7 @@ class Pusher extends RedisModel {
                }
            });
        } catch (e) {
            log.error('Push via APN failed:' + e);
            log.error('Push via APN failed:'+deviceToken+":" + e);
        }
    }

+ 4 - 2
src/server/models/sessions/sessions.js

@ -843,7 +843,7 @@ class Sessions extends RedisModel {
            for (let j in res) {
                if (res[j].type == SESSION_TYPES.SYSTEM) {
                    if (j == res.length - 1) {
                        ModelUtil.emitOK(self.eventEmitter, {count: count});
                        ModelUtil.emitOK(self.eventEmitter, {count: count, patient: patientCount, doctor: doctorCount});
                    }
                    continue;
                }
@ -858,7 +858,7 @@ class Sessions extends RedisModel {
                }
                count = count + con;
                if (session.type == SESSION_BUSINESS_TYPE.PATIENT) {
                if (session.business_type == SESSION_BUSINESS_TYPE.PATIENT) {
                    patientCount = patientCount + con;
                } else {
                    doctorCount = doctorCount + con;
@ -1232,6 +1232,8 @@ class Sessions extends RedisModel {
                if(sessionType==SESSION_TYPES.P2P){
                     WechatClient.sendReadDoctorByDoctorId(targetUserId, message);
                }
                //告知医生新消息
                WechatClient.sendSocketMessageToDoctor(targetUserId,message);
                AppClient.sendNotification(targetUserId, message);
            }
        });

+ 3 - 1
src/server/repository/mysql/participant.repo.js

@ -34,7 +34,9 @@ class ParticipantRepo {
            "handler": function(err,res){
                if(res&&res.length>0){
                    for(var j in res){
                        res[j].last_fetch_time = res[j].last_fetch_time.getTime();
                        if(res[j].last_fetch_time){
                            res[j].last_fetch_time = res[j].last_fetch_time.getTime();
                        }
                    }
                }
                handler(err,res);