|
@ -573,7 +573,38 @@ class Sessions extends RedisModel {
|
|
|
*/
|
|
|
getAllSessionsUnreadMessageCount(userId) {
|
|
|
let self = this;
|
|
|
ModelUtil.emitError(self.eventEmitter, {message: "not implemented."}, null);
|
|
|
let count = 0;
|
|
|
SessionRepo.findAll(userId,function(err,res){
|
|
|
if(err){
|
|
|
logger.err("getAllSessionsUnreadMessageCount is fail :"+err);
|
|
|
return;
|
|
|
}
|
|
|
if(res.length==0){
|
|
|
ModelUtil.emitOK(self.eventEmitter, {count: count});
|
|
|
return;
|
|
|
}
|
|
|
for(var j in res){
|
|
|
if(res[j].type==SESSION_TYPES.SYSTEM){
|
|
|
if(j==res.length-1){
|
|
|
ModelUtil.emitOK(self.eventEmitter, {count: count});
|
|
|
}
|
|
|
continue;
|
|
|
}
|
|
|
callback(res,j,res[j]);
|
|
|
}
|
|
|
})
|
|
|
|
|
|
function callback(res,j,session){
|
|
|
self.getSessionUnreadMessageCount(res[j].id,userId,function(err,con){
|
|
|
if(err){
|
|
|
logger.err("getAllSessionsUnreadMessageCount is fail :"+err);
|
|
|
}
|
|
|
count = count+con;
|
|
|
if(j==res.length-1){
|
|
|
ModelUtil.emitOK(self.eventEmitter, {count: count});
|
|
|
}
|
|
|
})
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
@ -883,6 +914,7 @@ class Sessions extends RedisModel {
|
|
|
* @param userId
|
|
|
*/
|
|
|
static updateParticipantLastFetchTime(sessionId, userId, score) {
|
|
|
score = score+1;
|
|
|
let participantsKey = RedisModel.makeRedisKey(REDIS_KEYS.SessionParticipants, sessionId);
|
|
|
redis.zaddAsync(participantsKey, score, userId)
|
|
|
.then(function (res) {
|