|
@ -4,23 +4,22 @@ var http = require('http');
|
|
|
var qs = require('querystring');
|
|
|
var async = require('async');
|
|
|
|
|
|
var commons = require('./include/endpoints');
|
|
|
var config = require(commons.CONFIG_FILE);
|
|
|
var config = require('../include/commons').CONFIG_FILE;
|
|
|
|
|
|
var log = require('../util/log');
|
|
|
var mysql_wlyy = require("../repository/wlyyRepo");
|
|
|
var mysql_im = require("../repository/imRepo");
|
|
|
var wlyyRepo = require("../repository/wlyy.repo");
|
|
|
var imRepo = require("../repository/im.repo");
|
|
|
|
|
|
function updateGroupChatInfo(user_id, group_id, from_uid, at_me, type, content, msg_count_plus_one, handler) {
|
|
|
var uuid = user_id + '_' + group_id;
|
|
|
if (msg_count_plus_one) {
|
|
|
mysql_im.execQuery({
|
|
|
imRepo.execQuery({
|
|
|
"sql": "INSERT INTO statistic (uid,uuid,from_uid,from_gid,at_me,msg_type,last_content_type,last_content,new_msg_count) VALUES (?,?,?,?,?,?,?,?,?) ON DUPLICATE KEY UPDATE from_uid=?,at_me=?,last_content_type=?,last_content=?,new_msg_count=new_msg_count+1",
|
|
|
"args": [user_id, uuid, from_uid, group_id, at_me, 2, type, content, 1, from_uid, at_me, type, content],
|
|
|
"handler": handler
|
|
|
});
|
|
|
} else {
|
|
|
mysql_im.execQuery({
|
|
|
imRepo.execQuery({
|
|
|
"sql": "INSERT INTO statistic (uid,uuid,from_uid,from_gid,at_me,msg_type,last_content_type,last_content,new_msg_count) VALUES (?,?,?,?,?,?,?,?,?) ON DUPLICATE KEY UPDATE from_uid=?,at_me=?,last_content_type=?,last_content=?",
|
|
|
"args": [user_id, uuid, from_uid, group_id, at_me, 2, type, content, 0, from_uid, at_me, type, content],
|
|
|
"handler": handler
|
|
@ -32,14 +31,14 @@ function updateP2PChatInfo(user_id, peer_uid, from_uid, type, content, handler)
|
|
|
var uuid = user_id + '_' + peer_uid;
|
|
|
if (user_id == from_uid) {
|
|
|
// 更新自身的统计信息
|
|
|
mysql_im.execQuery({
|
|
|
imRepo.execQuery({
|
|
|
"sql": "INSERT INTO statistic (uid,uuid,from_uid,peer_uid,msg_type,last_content_type,last_content,new_msg_count) VALUES (?,?,?,?,?,?,?,?) ON DUPLICATE KEY UPDATE peer_uid=?,last_content_type=?,last_content=?",
|
|
|
"args": [user_id, uuid, from_uid, peer_uid, 1, type, content, 0, peer_uid, type, content],
|
|
|
"handler": handler
|
|
|
});
|
|
|
} else {
|
|
|
// 更新对端的统计信息
|
|
|
mysql_im.execQuery({
|
|
|
imRepo.execQuery({
|
|
|
"sql": "INSERT INTO statistic (uid,uuid,from_uid,peer_uid,msg_type,last_content_type,last_content,new_msg_count) VALUES (?,?,?,?,?,?,?,?) ON DUPLICATE KEY UPDATE peer_uid=?,last_content_type=?,last_content=?,new_msg_count=new_msg_count+1",
|
|
|
"args": [user_id, uuid, from_uid, peer_uid, 1, type, content, 1, peer_uid, type, content],
|
|
|
"handler": handler
|
|
@ -49,7 +48,7 @@ function updateP2PChatInfo(user_id, peer_uid, from_uid, type, content, handler)
|
|
|
|
|
|
function clearGroupChatInfo(user_id, group_id, handler) {
|
|
|
var uuid = user_id + '_' + group_id;
|
|
|
mysql_im.execQuery({
|
|
|
imRepo.execQuery({
|
|
|
"sql": "UPDATE statistic SET new_msg_count='0' WHERE uuid=?",
|
|
|
"args": [uuid],
|
|
|
"handler": handler
|
|
@ -58,7 +57,7 @@ function clearGroupChatInfo(user_id, group_id, handler) {
|
|
|
|
|
|
function clearP2PChatInfo(user_id, peer_uid, handler) {
|
|
|
var uuid = user_id + '_' + peer_uid;
|
|
|
mysql_im.execQuery({
|
|
|
imRepo.execQuery({
|
|
|
"sql": "UPDATE statistic SET new_msg_count='0' WHERE uuid=?",
|
|
|
"args": [uuid],
|
|
|
"handler": handler
|
|
@ -67,7 +66,7 @@ function clearP2PChatInfo(user_id, peer_uid, handler) {
|
|
|
|
|
|
function getGroupChatInfo(user_id, group_id, handler) {
|
|
|
var uuid = user_id + '_' + group_id;
|
|
|
mysql_im.execQuery({
|
|
|
imRepo.execQuery({
|
|
|
"sql": "SELECT uid,from_uid,from_gid,at_me,last_content_type,last_content,new_msg_count,timestamp from statistic WHERE uuid = ?",
|
|
|
"args": [uuid],
|
|
|
"handler": handler
|
|
@ -76,7 +75,7 @@ function getGroupChatInfo(user_id, group_id, handler) {
|
|
|
|
|
|
function getP2PChatInfo(user_id, peer_uid, handler) {
|
|
|
var uuid = user_id + '_' + peer_uid;
|
|
|
mysql_im.execQuery({
|
|
|
imRepo.execQuery({
|
|
|
"sql": "SELECT uid,from_uid,last_content_type,last_content,new_msg_count,timestamp from statistic WHERE uuid = ?",
|
|
|
"args": [uuid],
|
|
|
"handler": handler
|
|
@ -84,7 +83,7 @@ function getP2PChatInfo(user_id, peer_uid, handler) {
|
|
|
}
|
|
|
|
|
|
function getChatList(user_id, handler) {
|
|
|
mysql_im.execQuery({
|
|
|
imRepo.execQuery({
|
|
|
"sql": "SELECT uid,from_uid,from_gid,peer_uid,at_me,msg_type,last_content_type,last_content,new_msg_count,timestamp from statistic WHERE uid = ?",
|
|
|
"args": [user_id],
|
|
|
"handler": handler
|
|
@ -92,7 +91,7 @@ function getChatList(user_id, handler) {
|
|
|
}
|
|
|
|
|
|
function getGroupChatAllUnRead(user_id, handler) {
|
|
|
mysql_im.execQuery({
|
|
|
imRepo.execQuery({
|
|
|
"sql": "SELECT new_msg_count from statistic WHERE uid=? AND msg_type=2 AND new_msg_count>0",
|
|
|
"args": [user_id],
|
|
|
"handler": handler
|
|
@ -100,7 +99,7 @@ function getGroupChatAllUnRead(user_id, handler) {
|
|
|
}
|
|
|
|
|
|
function getP2PChatAllUnRead(user_id, handler) {
|
|
|
mysql_im.execQuery({
|
|
|
imRepo.execQuery({
|
|
|
"sql": "SELECT new_msg_count from statistic WHERE uid=? AND msg_type=1 AND new_msg_count>0",
|
|
|
"args": [user_id],
|
|
|
"handler": handler
|
|
@ -108,7 +107,7 @@ function getP2PChatAllUnRead(user_id, handler) {
|
|
|
}
|
|
|
|
|
|
function getChatAllUnRead(user_id, handler) {
|
|
|
mysql_im.execQuery({
|
|
|
imRepo.execQuery({
|
|
|
"sql": "SELECT new_msg_count from statistic WHERE uid=? AND new_msg_count>0",
|
|
|
"args": [user_id],
|
|
|
"handler": handler
|
|
@ -116,7 +115,7 @@ function getChatAllUnRead(user_id, handler) {
|
|
|
}
|
|
|
|
|
|
function getAppMsgAmount(user_id, handler) {
|
|
|
mysql_wlyy.execQuery({
|
|
|
wlyyRepo.execQuery({
|
|
|
"sql": "SELECT imei,token from wlyy_token WHERE users=?",
|
|
|
"args": [user_id],
|
|
|
"handler": function(err, result) {
|