Commit e62704c866ef71e0725e923fb5878a9d0e9e1cb5

Authored by 陆恒
1 parent a7c5dd9a
Exists in master

提交

src/HttpServer/logic/function.go
@@ -1150,6 +1150,16 @@ func GetPrivateChatMessage(uuid, taduid int) []QueryChatMessageData { @@ -1150,6 +1150,16 @@ func GetPrivateChatMessage(uuid, taduid int) []QueryChatMessageData {
1150 } 1150 }
1151 1151
1152 func WorldChat(message string, uuid int) (int, string) { 1152 func WorldChat(message string, uuid int) (int, string) {
  1153 +
  1154 + //需要检查是否能发言
  1155 + isexist, err := redishandler.GetRedisClient().HExists(redis.USER_CHATFORBIGLIST_WORLD_KEY, strconv.Itoa(uuid))
  1156 + if err == nil {
  1157 + if isexist {
  1158 + //被禁言了 无法发言
  1159 + return 99, "you are forbided"
  1160 + }
  1161 + }
  1162 +
1153 length, err := redishandler.GetRedisClient().LLen(redis.WORLD_CHAT_INFO_KEY) 1163 length, err := redishandler.GetRedisClient().LLen(redis.WORLD_CHAT_INFO_KEY)
1154 if err == nil { 1164 if err == nil {
1155 if length >= CHATLIMITNUM { 1165 if length >= CHATLIMITNUM {
@@ -1192,6 +1202,15 @@ func WorldChat(message string, uuid int) (int, string) { @@ -1192,6 +1202,15 @@ func WorldChat(message string, uuid int) (int, string) {
1192 } 1202 }
1193 1203
1194 func TeamChat(message string, uuid int) (int, string) { 1204 func TeamChat(message string, uuid int) (int, string) {
  1205 + //需要检查是否能发言
  1206 + isexist, err := redishandler.GetRedisClient().HExists(redis.USER_CHATFORBIGLIST_TEAM_KEY, strconv.Itoa(uuid))
  1207 + if err == nil {
  1208 + if isexist {
  1209 + //被禁言了 无法发言
  1210 + return 99, "you are forbided"
  1211 + }
  1212 + }
  1213 +
1195 tid, err := QueryUserTeamId(uuid) 1214 tid, err := QueryUserTeamId(uuid)
1196 if err != nil { 1215 if err != nil {
1197 logger.Error("TeamChat err=%v", err) 1216 logger.Error("TeamChat err=%v", err)
@@ -1240,6 +1259,14 @@ func TeamChat(message string, uuid int) (int, string) { @@ -1240,6 +1259,14 @@ func TeamChat(message string, uuid int) (int, string) {
1240 } 1259 }
1241 1260
1242 func PrivateChat(message string, uuid int, taruid int) (int, string) { 1261 func PrivateChat(message string, uuid int, taruid int) (int, string) {
  1262 + isexist, err := redishandler.GetRedisClient().HExists(redis.USER_CHATFORBIGLIST_PRIVATE_KEY, strconv.Itoa(uuid))
  1263 + if err == nil {
  1264 + if isexist {
  1265 + //被禁言了 无法发言
  1266 + return 99, "you are forbided"
  1267 + }
  1268 + }
  1269 +
1243 //存入待收人的列表 1270 //存入待收人的列表
1244 rkey := redis.USER_CHAT_PRIVATE_INFO_KEY + ":" + strconv.Itoa(taruid) + ":" + strconv.Itoa(uuid) 1271 rkey := redis.USER_CHAT_PRIVATE_INFO_KEY + ":" + strconv.Itoa(taruid) + ":" + strconv.Itoa(uuid)
1245 length, err := redishandler.GetRedisClient().LLen(rkey) 1272 length, err := redishandler.GetRedisClient().LLen(rkey)
src/HttpServer/logic/httpserver.go
@@ -4,6 +4,7 @@ import ( @@ -4,6 +4,7 @@ import (
4 "HttpServer/conf" 4 "HttpServer/conf"
5 "HttpServer/redishandler" 5 "HttpServer/redishandler"
6 "common/logger" 6 "common/logger"
  7 + "common/redis"
7 "fmt" 8 "fmt"
8 "io" 9 "io"
9 "io/ioutil" 10 "io/ioutil"
@@ -71,6 +72,7 @@ func startServerHttpServe() { @@ -71,6 +72,7 @@ func startServerHttpServe() {
71 http.HandleFunc("/catcafe/ClearData", ClearData) //情况账号的测试接口 72 http.HandleFunc("/catcafe/ClearData", ClearData) //情况账号的测试接口
72 http.HandleFunc("/catcafe/AddWhiteList", AddWhiteList) //情况账号的测试接口 73 http.HandleFunc("/catcafe/AddWhiteList", AddWhiteList) //情况账号的测试接口
73 http.HandleFunc("/catcafe/AddGoldAndLove", AddGoldAndLove) //情况账号的测试接口 74 http.HandleFunc("/catcafe/AddGoldAndLove", AddGoldAndLove) //情况账号的测试接口
  75 + http.HandleFunc("/catcafe/ForbidChats", ForbidChats) //禁言接口
74 http.HandleFunc("/catcafe/QueryAllAccount", QueryAllAccount) //查询所有账号的等级信息等数据 76 http.HandleFunc("/catcafe/QueryAllAccount", QueryAllAccount) //查询所有账号的等级信息等数据
75 //------------------------------------------------------------- 77 //-------------------------------------------------------------
76 http.HandleFunc("/catcafe/login", UserLogin) //游客登录 78 http.HandleFunc("/catcafe/login", UserLogin) //游客登录
@@ -258,6 +260,42 @@ func QueryAllAccount(w http.ResponseWriter, r *http.Request) { @@ -258,6 +260,42 @@ func QueryAllAccount(w http.ResponseWriter, r *http.Request) {
258 fmt.Fprint(w, "success") 260 fmt.Fprint(w, "success")
259 } 261 }
260 262
  263 +func ForbidChats(w http.ResponseWriter, r *http.Request) {
  264 + query := r.URL.Query()
  265 + suuid := query.Get("uuid")
  266 + stype := query.Get("type") //0世界频道 1工会频道 2私聊
  267 + soption := query.Get("option") //1解封 其他禁言
  268 +
  269 + if suuid == "" {
  270 + fmt.Fprint(w, "uuid is nil,please check")
  271 + return
  272 + }
  273 +
  274 + rkey := ""
  275 + if stype == "0" {
  276 + rkey = redis.USER_CHATFORBIGLIST_WORLD_KEY
  277 + } else if stype == "1" {
  278 + rkey = redis.USER_CHATFORBIGLIST_TEAM_KEY
  279 + } else {
  280 + rkey = redis.USER_CHATFORBIGLIST_PRIVATE_KEY
  281 + }
  282 +
  283 + if soption == "1" {
  284 + err := redishandler.GetRedisClient().HDel(rkey, suuid)
  285 + if err != nil {
  286 + logger.Error("ForbidChats err=%v")
  287 + }
  288 + } else {
  289 + err := redishandler.GetRedisClient().HSet(rkey, suuid, "1")
  290 + if err != nil {
  291 + logger.Error("ForbidChats err=%v")
  292 + }
  293 + }
  294 +
  295 + fmt.Fprint(w, "禁言成功!")
  296 +
  297 +}
  298 +
261 func AddGoldAndLove(w http.ResponseWriter, r *http.Request) { 299 func AddGoldAndLove(w http.ResponseWriter, r *http.Request) {
262 300
263 query := r.URL.Query() 301 query := r.URL.Query()
src/common/redis/def.go
@@ -22,11 +22,14 @@ const ( @@ -22,11 +22,14 @@ const (
22 USER_BACKUP_DATA = "CATCAFE_USER_BACKUP_DATA" //玩家数据保存的备份 22 USER_BACKUP_DATA = "CATCAFE_USER_BACKUP_DATA" //玩家数据保存的备份
23 USER_NEW_DATA_KEY = "cat:cafe:data_new:where:data_uid:" //玩家数据保存的新的key 23 USER_NEW_DATA_KEY = "cat:cafe:data_new:where:data_uid:" //玩家数据保存的新的key
24 24
25 - USER_CHAT_ISNEW = "CATCAFE_USER_CHAT_ISNEW" //hset field为uuid 存在表示有新消息了不用再去计算 否则需要挨个去判断  
26 - WORLD_CHAT_INFO_KEY = "CATCAFE_WORLD_CHAT_INFO_KEY" //存储的是世界聊天 list结构 最新的消息在最头部  
27 - USER_CHAT_TEAM_LASTGET_KEY = "CATCAFE_USER_CHAT_TEAM_LASTGET_KEY" // 结构是hset field是uuid value是存储的是最后一次获取工会聊天的时间戳,用于和工会聊天最新一条消息做对比,如果时间比最新一条小则有新的消息  
28 - USER_CHAT_TEAM_INFO_KEY = "CATCAFE_USER_CHAT_TEAM_INFO_KEY" // 加teamid 存储的是队伍聊天的信息 list结构 最新的消息在最头部  
29 - USER_CHAT_PRIVATE_LASTGET_KEY = "CATCAFE_USER_CHAT_PRIVATE_LASTGET_KEY" // hset key加自己的uuid field为目标的uuid value为时间戳  
30 - USER_CHAT_PRIVATE_INFO_KEY = "CATCAFE_USER_CHAT_PRIVATE_INFO_KEY" //list key需要加上自己的:uuid再加上目标:uuid 存储的是和自己相关的所有聊天信息  
31 - USER_CHAT_EMOJUNLOCK_KEY = "CATCAFE_USER_CHAT_EMOJUNLOCK_KEY" //hset 记录的是玩家表情页签解锁情况 []int 0表示未解锁 1表示解锁 25 + USER_CHAT_ISNEW = "CATCAFE_USER_CHAT_ISNEW" //hset field为uuid 存在表示有新消息了不用再去计算 否则需要挨个去判断
  26 + WORLD_CHAT_INFO_KEY = "CATCAFE_WORLD_CHAT_INFO_KEY" //存储的是世界聊天 list结构 最新的消息在最头部
  27 + USER_CHAT_TEAM_LASTGET_KEY = "CATCAFE_USER_CHAT_TEAM_LASTGET_KEY" // 结构是hset field是uuid value是存储的是最后一次获取工会聊天的时间戳,用于和工会聊天最新一条消息做对比,如果时间比最新一条小则有新的消息
  28 + USER_CHAT_TEAM_INFO_KEY = "CATCAFE_USER_CHAT_TEAM_INFO_KEY" // 加teamid 存储的是队伍聊天的信息 list结构 最新的消息在最头部
  29 + USER_CHAT_PRIVATE_LASTGET_KEY = "CATCAFE_USER_CHAT_PRIVATE_LASTGET_KEY" // hset key加自己的uuid field为目标的uuid value为时间戳
  30 + USER_CHAT_PRIVATE_INFO_KEY = "CATCAFE_USER_CHAT_PRIVATE_INFO_KEY" //list key需要加上自己的:uuid再加上目标:uuid 存储的是和自己相关的所有聊天信息
  31 + USER_CHAT_EMOJUNLOCK_KEY = "CATCAFE_USER_CHAT_EMOJUNLOCK_KEY" //hset 记录的是玩家表情页签解锁情况 []int 0表示未解锁 1表示解锁
  32 + USER_CHATFORBIGLIST_WORLD_KEY = "CAECAFE_USER_CHATFORBIGLIST_WORLD_KEY" //hset 记录玩家世界是否被禁言
  33 + USER_CHATFORBIGLIST_TEAM_KEY = "CAECAFE_USER_CHATFORBIGLIST_TEAM_KEY" //hset 记录玩家工会是否被禁言
  34 + USER_CHATFORBIGLIST_PRIVATE_KEY = "CAECAFE_USER_CHATFORBIGLIST_PRIVATE_KEY" //hset 记录玩家私聊是否被禁言
32 ) 35 )