避免无限制重复好友请求,好友请求在5分钟之内只允许重复请求一次
This commit is contained in:
@@ -137,6 +137,13 @@ public class MemoryMessagesStore implements IMessagesStore {
|
||||
private ConcurrentHashMap<String, Boolean> userPushHiddenDetail = new ConcurrentHashMap<>();
|
||||
private ConcurrentHashMap<String, Boolean> userConvSlientMap = new ConcurrentHashMap<>();
|
||||
|
||||
private LinkedHashMap<String, Long> repeatFriendRequest = new LinkedHashMap<String, Long>() {
|
||||
@Override
|
||||
protected boolean removeEldestEntry(Map.Entry<String, Long> eldest) {
|
||||
return System.currentTimeMillis() - eldest.getValue() > 5 * 60 * 1000;
|
||||
}
|
||||
};
|
||||
|
||||
private boolean mDisableSearch = false;
|
||||
private boolean mDisableNicknameSearch = false;
|
||||
private boolean mDisableFriendRequest = false;
|
||||
@@ -3120,6 +3127,18 @@ public class MemoryMessagesStore implements IMessagesStore {
|
||||
if (!(mFriendRequestDuration > 0 && System.currentTimeMillis() - existRequest.getUpdateDt() > mFriendRequestDuration)) {
|
||||
if(System.currentTimeMillis() - existRequest.getUpdateDt() > 5 * 60 * 1000) {
|
||||
return ErrorCode.ERROR_CODE_FRIEND_ALREADY_REQUEST;
|
||||
} else {
|
||||
mWriteLock.lock();
|
||||
try {
|
||||
String repeatKey = userId + "-" + existRequest.getToUid();
|
||||
Long lastTime = repeatFriendRequest.get(repeatKey);
|
||||
if(lastTime != null && System.currentTimeMillis() - lastTime < 5 * 60 * 1000) {
|
||||
return ErrorCode.ERROR_CODE_FRIEND_ALREADY_REQUEST;
|
||||
}
|
||||
repeatFriendRequest.put(repeatKey, System.currentTimeMillis());
|
||||
} finally {
|
||||
mWriteLock.unlock();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user