|
@ -317,6 +317,36 @@ class Sessions extends RedisModel {
|
|
|
SessionRepo.findOne(sessionId, handler);
|
|
|
}
|
|
|
|
|
|
getSession(sessionId,userId,handler){
|
|
|
let self = this;
|
|
|
let sessionKey = RedisModel.makeRedisKey(REDIS_KEYS.Session, sessionId);
|
|
|
redis.hgetallAsync(sessionKey).then(function(session){
|
|
|
if(session.type==SESSION_TYPES.P2P){
|
|
|
ParticipantRepo.findNameById(userId, function (err, res) {
|
|
|
session.name = res[0].name;
|
|
|
if(handler){
|
|
|
handler(null,session);
|
|
|
return;
|
|
|
}
|
|
|
ModelUtil.emitOK(self.eventEmitter, session);
|
|
|
})
|
|
|
}else{
|
|
|
if(handler){
|
|
|
handler(null,session);
|
|
|
return;
|
|
|
}
|
|
|
ModelUtil.emitOK(self.eventEmitter, session);
|
|
|
}
|
|
|
}).catch(function (err) {
|
|
|
logger.error("Get session failed: ", err);
|
|
|
if(handler){
|
|
|
handler(null,session);
|
|
|
return;
|
|
|
}
|
|
|
ModelUtil.emitError(self.eventEmitter, {message: err, status: -1}, null);
|
|
|
})
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 根据用户ID获取用户的session列表
|
|
|
* @param userId
|