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 201 return true
202 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 206 local redret = redisproxy:pipelining(function (red)
207 207 red:hlen(FRIEND_KEY:format(roleId))
208 208 red:hlen(FRIEND_KEY:format(objectId))
... ... @@ -210,22 +210,21 @@ local function checkHandleApply(roleId, objectId)
210 210 red:sismember(FRIEND_BLACK_KEY:format(roleId), objectId)
211 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 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 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 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 227 end
228   - return result
229 228 end
230 229  
231 230 function _M.handleApplyRpc(agent, data)
... ... @@ -291,7 +290,7 @@ function _M.handleApplyRpc(agent, data)
291 290 local needAddInfo = {}
292 291 for _, objId in ipairs(allIds) do
293 292 objId = tonumber(objId)
294   - local cr = checkHandleApply(roleId, objId)
  293 + local cr = checkHandleApply(roleId, objId, #needAdd)
295 294 if not cr then
296 295 table.insert(needAdd, objId)
297 296 table.insert(needAddMy, objId)
... ...