|
@ -6,6 +6,7 @@
|
|
let MessageRepo = require('../../repository/mysql/message.repo');
|
|
let MessageRepo = require('../../repository/mysql/message.repo');
|
|
let RedisModel = require('./../redis.model.js');
|
|
let RedisModel = require('./../redis.model.js');
|
|
let SessionRepo = require('../../repository/mysql/session.repo');
|
|
let SessionRepo = require('../../repository/mysql/session.repo');
|
|
|
|
let ParticipantRepo = require('../../repository/mysql/participant.repo');
|
|
let RedisClient = require('../../repository/redis/redis.client.js');
|
|
let RedisClient = require('../../repository/redis/redis.client.js');
|
|
let ModelUtil = require('../../util/model.util');
|
|
let ModelUtil = require('../../util/model.util');
|
|
var ObjectUtil = require("../../util/object.util.js");
|
|
var ObjectUtil = require("../../util/object.util.js");
|
|
@ -308,18 +309,26 @@ class Messages extends RedisModel {
|
|
});
|
|
});
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* 清洗数据
|
|
|
|
* @param message
|
|
|
|
*/
|
|
|
|
cleanMessageToReids(session_id_str) {
|
|
|
|
|
|
cleanMessageLastFetchTime(sessionId,userId) {
|
|
let self = this;
|
|
let self = this;
|
|
console.log(session_id_str)
|
|
|
|
let sessionArray=session_id_str.split(",");
|
|
|
|
sessionArray.forEach(function (sessionId) {
|
|
|
|
console.log(sessionId);
|
|
|
|
self.dataMessage(sessionId);
|
|
|
|
|
|
ParticipantRepo.findLastFetchTime(sessionId,userId,function(err,res){
|
|
|
|
if (err) {
|
|
|
|
logger.error(err);
|
|
|
|
return;
|
|
|
|
} else {
|
|
|
|
let last_fetch_time = new Date(res[0].last_fetch_time).getTime();
|
|
|
|
last_fetch_time = last_fetch_time + 1;
|
|
|
|
let participantsKey = RedisModel.makeRedisKey(REDIS_KEYS.SessionParticipants, sessionId);
|
|
|
|
redis.zaddAsync(participantsKey, last_fetch_time, userId)
|
|
|
|
.then(function (res) {
|
|
|
|
ModelUtil.emitOK(self.eventEmitter, {status:200,message:"存入redis成功!"});
|
|
|
|
})
|
|
|
|
.catch(function (err) {
|
|
|
|
logger.error("Update participant last fetch time failed: ", err);
|
|
|
|
ModelUtil.emitOK(self.eventEmitter, res);
|
|
|
|
return;
|
|
|
|
});
|
|
|
|
}
|
|
});
|
|
});
|
|
}
|
|
}
|
|
}
|
|
}
|