Commit a0be8e2907f9994966af24308f7c9cdaefa6dd40
1 parent
716738ac
fix(im):修复同意好友申请误报用户不存在
- 移除 agreeFriendRequest 中对申请双方的重复 validateUserList 校验 - 保留申请存在、未处理、操作人必须为接收方的校验,避免削弱处理权限边界 - 调整单测,断言同意好友申请不再触发双方用户复验
Showing
2 changed files
with
1 additions
and
4 deletions
yudao-module-im/src/main/java/cn/iocoder/yudao/module/im/service/friend/ImFriendRequestServiceImpl.java
| ... | ... | @@ -172,8 +172,6 @@ public class ImFriendRequestServiceImpl implements ImFriendRequestService { |
| 172 | 172 | public void agreeFriendRequest(Long userId, Long requestId) { |
| 173 | 173 | // 1.1 校验申请存在、未处理、操作人是接收方 |
| 174 | 174 | ImFriendRequestDO request = validateRequestForHandle(userId, requestId); |
| 175 | - // 1.2 复验双方用户有效 | |
| 176 | - adminUserApi.validateUserList(ListUtil.of(request.getFromUserId(), request.getToUserId())); | |
| 177 | 175 | |
| 178 | 176 | // 2. 乐观锁更新申请处理结果 |
| 179 | 177 | ImFriendRequestDO updateObj = new ImFriendRequestDO() | ... | ... |
yudao-module-im/src/test/java/cn/iocoder/yudao/module/im/service/friend/ImFriendRequestServiceImplTest.java
| 1 | 1 | package cn.iocoder.yudao.module.im.service.friend; |
| 2 | 2 | |
| 3 | -import cn.hutool.core.collection.ListUtil; | |
| 4 | 3 | import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; |
| 5 | 4 | import cn.iocoder.yudao.framework.common.exception.ServiceException; |
| 6 | 5 | import cn.iocoder.yudao.framework.test.core.ut.BaseMockitoUnitTest; |
| ... | ... | @@ -228,7 +227,7 @@ public class ImFriendRequestServiceImplTest extends BaseMockitoUnitTest { |
| 228 | 227 | friendRequestService.agreeFriendRequest(2L, 100L); |
| 229 | 228 | |
| 230 | 229 | // 断言:双向建立好友 + 推 APPROVED 给发起方 |
| 231 | - verify(adminUserApi).validateUserList(ListUtil.of(1L, 2L)); | |
| 230 | + verify(adminUserApi, never()).validateUserList(any()); | |
| 232 | 231 | verify(friendService).becomeFriends(request); |
| 233 | 232 | verify(websocketService).sendNotificationAsync(eq(1L), anyInt(), anyInt(), any()); |
| 234 | 233 | } | ... | ... |