Commit b51ca4553150610f14034cbecffe98d7093da2d5
1 parent
b0ca5b75
✨ feat(im):实现 1209 FRIEND_INFO_UPDATED 推送链路 + 修 deleteFriend 单边 TIP bug + FRIEND…
…_APPLICATION 重命名 FRIEND_REQUEST_RECEIVED
Showing
4 changed files
with
5 additions
and
12 deletions
yudao-module-im/src/main/java/cn/iocoder/yudao/module/im/enums/ImCommonConstants.java
yudao-module-im/src/main/java/cn/iocoder/yudao/module/im/enums/message/ImMessageTypeEnum.java
| ... | ... | @@ -50,7 +50,7 @@ public enum ImMessageTypeEnum implements ArrayValuable<Integer> { |
| 50 | 50 | * 对应自己的类:FriendRequestNotification |
| 51 | 51 | * 场景:A 申请加 B,推给 B 多端,前端落到「新的朋友」列表 |
| 52 | 52 | */ |
| 53 | - FRIEND_APPLICATION(1203, "收到新的好友申请", false, false), | |
| 53 | + FRIEND_REQUEST_RECEIVED(1203, "收到新的好友申请", false, false), | |
| 54 | 54 | /** |
| 55 | 55 | * 对应 OpenIM:FriendAddedNotification 1204 |
| 56 | 56 | * 对应自己的类:FriendAddNotification | ... | ... |
yudao-module-im/src/main/java/cn/iocoder/yudao/module/im/service/friend/ImFriendRequestServiceImpl.java
| ... | ... | @@ -98,12 +98,12 @@ public class ImFriendRequestServiceImpl implements ImFriendRequestService { |
| 98 | 98 | friendRequestMapper.insert(request); |
| 99 | 99 | } |
| 100 | 100 | |
| 101 | - // 3. 推送 FRIEND_APPLICATION 给 toUser 多端 | |
| 101 | + // 3. 推送 FRIEND_REQUEST_RECEIVED 给 toUser 多端 | |
| 102 | 102 | FriendRequestNotification payload = (FriendRequestNotification) new FriendRequestNotification() |
| 103 | 103 | .setRequestId(request.getId()).setApplyContent(request.getApplyContent()).setAddSource(request.getAddSource()) |
| 104 | 104 | .setOperatorUserId(fromUserId).setFriendUserId(fromUserId); |
| 105 | 105 | websocketService.sendPrivateMessageAsync(toUserId, ImPrivateMessageDTO.ofFriendNotification( |
| 106 | - ImMessageTypeEnum.FRIEND_APPLICATION.getType(), fromUserId, toUserId, payload)); | |
| 106 | + ImMessageTypeEnum.FRIEND_REQUEST_RECEIVED.getType(), fromUserId, toUserId, payload)); | |
| 107 | 107 | |
| 108 | 108 | // 4. 全局自动通过开关:注册 afterCommit 回调,事务提交后再走同意流程 |
| 109 | 109 | // 回调内 try/catch 兜底 —— afterCommit 异常会被 Spring 静默吞掉,否则同意失败时申请方永远等不到 APPROVED | ... | ... |
yudao-module-im/src/main/java/cn/iocoder/yudao/module/im/service/friend/ImFriendServiceImpl.java
| ... | ... | @@ -34,7 +34,6 @@ import static cn.iocoder.yudao.module.im.dal.redis.RedisKeyConstants.FRIEND_STAT |
| 34 | 34 | import static cn.iocoder.yudao.module.im.enums.ErrorCodeConstants.FRIEND_NOT_BLOCKED; |
| 35 | 35 | import static cn.iocoder.yudao.module.im.enums.ErrorCodeConstants.FRIEND_NOT_FRIEND; |
| 36 | 36 | import static cn.iocoder.yudao.module.im.enums.ImCommonConstants.FRIEND_ADD_TIP_MESSAGE; |
| 37 | -import static cn.iocoder.yudao.module.im.enums.ImCommonConstants.FRIEND_DELETE_TIP_MESSAGE; | |
| 38 | 37 | |
| 39 | 38 | /** |
| 40 | 39 | * IM 好友关系 Service 实现类 |
| ... | ... | @@ -169,12 +168,10 @@ public class ImFriendServiceImpl implements ImFriendService { |
| 169 | 168 | @Transactional(rollbackFor = Exception.class) |
| 170 | 169 | public void deleteFriend(Long userId, Long friendUserId) { |
| 171 | 170 | // 1. 单边软删:仅 userId 视角的关系置 DISABLE;friendUserId 视角不动 |
| 171 | + // 不推 TIP 系统消息:单边删除语义下对方不应感知;userId 端反馈由前端 toast 承担,多端同步靠下面的 FRIEND_DELETE | |
| 172 | 172 | getSelf().deleteFriend0(userId, friendUserId); |
| 173 | 173 | |
| 174 | - // 2.1 推 TIP 系统消息 | |
| 175 | - privateMessageService.sendTipPrivateMessage(userId, friendUserId, FRIEND_DELETE_TIP_MESSAGE); | |
| 176 | - | |
| 177 | - // 2.2 推 FRIEND_DELETE 给 userId 多端做同步(friendUserId 不感知) | |
| 174 | + // 2. 推 FRIEND_DELETE 给 userId 多端做同步(friendUserId 不感知) | |
| 178 | 175 | FriendDeleteNotification payload = (FriendDeleteNotification) new FriendDeleteNotification() |
| 179 | 176 | .setOperatorUserId(userId).setFriendUserId(friendUserId); |
| 180 | 177 | websocketService.sendPrivateMessageAsync(userId, ImPrivateMessageDTO.ofFriendNotification( | ... | ... |