Commit 763d63969503518ec6777633d58f6efd114cc0f1

Authored by zhouhaihai
1 parent 3dbbc9f3

批量增加好友bug

Showing 1 changed file with 11 additions and 12 deletions   Show diff stats
src/actions/FriendAction.lua
@@ -201,8 +201,8 @@ function _M.applyListRpc(agent, data) @@ -201,8 +201,8 @@ function _M.applyListRpc(agent, data)
201 return true 201 return true
202 end 202 end
203 203
204 -local function checkHandleApply(roleId, objectId)  
205 - local result = nil 204 +local function checkHandleApply(roleId, objectId, needAddNew)
  205 + needAddNew = needAddNew or 0
206 local redret = redisproxy:pipelining(function (red) 206 local redret = redisproxy:pipelining(function (red)
207 red:hlen(FRIEND_KEY:format(roleId)) 207 red:hlen(FRIEND_KEY:format(roleId))
208 red:hlen(FRIEND_KEY:format(objectId)) 208 red:hlen(FRIEND_KEY:format(objectId))
@@ -210,22 +210,21 @@ local function checkHandleApply(roleId, objectId) @@ -210,22 +210,21 @@ local function checkHandleApply(roleId, objectId)
210 red:sismember(FRIEND_BLACK_KEY:format(roleId), objectId) 210 red:sismember(FRIEND_BLACK_KEY:format(roleId), objectId)
211 end) 211 end)
212 --自己好友满了 212 --自己好友满了
213 - if not result and redret[1] >= globalCsv.friendListLimit then  
214 - result = 1 213 + if (redret[1] + needAddNew) >= globalCsv.friendListLimit then
  214 + return 1
215 end 215 end
216 -- 对方好友满了 216 -- 对方好友满了
217 - if not result and redret[2] >= globalCsv.friendListLimit then  
218 - result = 2 217 + if redret[2] >= globalCsv.friendListLimit then
  218 + return 2
219 end 219 end
220 -- 对方把你拉黑 220 -- 对方把你拉黑
221 - if not result and redret[3] == 1 then  
222 - result = 3 221 + if redret[3] == 1 then
  222 + return 3
223 end 223 end
224 -- 你把对方拉黑了 224 -- 你把对方拉黑了
225 - if not result and redret[4] == 1 then  
226 - result = 4 225 + if redret[4] == 1 then
  226 + return 4
227 end 227 end
228 - return result  
229 end 228 end
230 229
231 function _M.handleApplyRpc(agent, data) 230 function _M.handleApplyRpc(agent, data)
@@ -291,7 +290,7 @@ function _M.handleApplyRpc(agent, data) @@ -291,7 +290,7 @@ function _M.handleApplyRpc(agent, data)
291 local needAddInfo = {} 290 local needAddInfo = {}
292 for _, objId in ipairs(allIds) do 291 for _, objId in ipairs(allIds) do
293 objId = tonumber(objId) 292 objId = tonumber(objId)
294 - local cr = checkHandleApply(roleId, objId) 293 + local cr = checkHandleApply(roleId, objId, #needAdd)
295 if not cr then 294 if not cr then
296 table.insert(needAdd, objId) 295 table.insert(needAdd, objId)
297 table.insert(needAddMy, objId) 296 table.insert(needAddMy, objId)