Commit b51ca4553150610f14034cbecffe98d7093da2d5

Authored by YunaiV
1 parent b0ca5b75

✨ feat(im):实现 1209 FRIEND_INFO_UPDATED 推送链路 + 修 deleteFriend 单边 TIP bug + FRIEND…

…_APPLICATION 重命名 FRIEND_REQUEST_RECEIVED
yudao-module-im/src/main/java/cn/iocoder/yudao/module/im/enums/ImCommonConstants.java
@@ -60,9 +60,5 @@ public interface ImCommonConstants { @@ -60,9 +60,5 @@ public interface ImCommonConstants {
60 * 好友添加系统提示 60 * 好友添加系统提示
61 */ 61 */
62 String FRIEND_ADD_TIP_MESSAGE = "你们已成为好友,现在可以开始聊天了"; 62 String FRIEND_ADD_TIP_MESSAGE = "你们已成为好友,现在可以开始聊天了";
63 - /**  
64 - * 好友删除系统提示  
65 - */  
66 - String FRIEND_DELETE_TIP_MESSAGE = "你们的好友关系已被解除";  
67 63
68 } 64 }
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,7 +50,7 @@ public enum ImMessageTypeEnum implements ArrayValuable<Integer> {
50 * 对应自己的类:FriendRequestNotification 50 * 对应自己的类:FriendRequestNotification
51 * 场景:A 申请加 B,推给 B 多端,前端落到「新的朋友」列表 51 * 场景:A 申请加 B,推给 B 多端,前端落到「新的朋友」列表
52 */ 52 */
53 - FRIEND_APPLICATION(1203, "收到新的好友申请", false, false), 53 + FRIEND_REQUEST_RECEIVED(1203, "收到新的好友申请", false, false),
54 /** 54 /**
55 * 对应 OpenIM:FriendAddedNotification 1204 55 * 对应 OpenIM:FriendAddedNotification 1204
56 * 对应自己的类:FriendAddNotification 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,12 +98,12 @@ public class ImFriendRequestServiceImpl implements ImFriendRequestService {
98 friendRequestMapper.insert(request); 98 friendRequestMapper.insert(request);
99 } 99 }
100 100
101 - // 3. 推送 FRIEND_APPLICATION 给 toUser 多端 101 + // 3. 推送 FRIEND_REQUEST_RECEIVED 给 toUser 多端
102 FriendRequestNotification payload = (FriendRequestNotification) new FriendRequestNotification() 102 FriendRequestNotification payload = (FriendRequestNotification) new FriendRequestNotification()
103 .setRequestId(request.getId()).setApplyContent(request.getApplyContent()).setAddSource(request.getAddSource()) 103 .setRequestId(request.getId()).setApplyContent(request.getApplyContent()).setAddSource(request.getAddSource())
104 .setOperatorUserId(fromUserId).setFriendUserId(fromUserId); 104 .setOperatorUserId(fromUserId).setFriendUserId(fromUserId);
105 websocketService.sendPrivateMessageAsync(toUserId, ImPrivateMessageDTO.ofFriendNotification( 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 // 4. 全局自动通过开关:注册 afterCommit 回调,事务提交后再走同意流程 108 // 4. 全局自动通过开关:注册 afterCommit 回调,事务提交后再走同意流程
109 // 回调内 try/catch 兜底 —— afterCommit 异常会被 Spring 静默吞掉,否则同意失败时申请方永远等不到 APPROVED 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,7 +34,6 @@ import static cn.iocoder.yudao.module.im.dal.redis.RedisKeyConstants.FRIEND_STAT
34 import static cn.iocoder.yudao.module.im.enums.ErrorCodeConstants.FRIEND_NOT_BLOCKED; 34 import static cn.iocoder.yudao.module.im.enums.ErrorCodeConstants.FRIEND_NOT_BLOCKED;
35 import static cn.iocoder.yudao.module.im.enums.ErrorCodeConstants.FRIEND_NOT_FRIEND; 35 import static cn.iocoder.yudao.module.im.enums.ErrorCodeConstants.FRIEND_NOT_FRIEND;
36 import static cn.iocoder.yudao.module.im.enums.ImCommonConstants.FRIEND_ADD_TIP_MESSAGE; 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 * IM 好友关系 Service 实现类 39 * IM 好友关系 Service 实现类
@@ -169,12 +168,10 @@ public class ImFriendServiceImpl implements ImFriendService { @@ -169,12 +168,10 @@ public class ImFriendServiceImpl implements ImFriendService {
169 @Transactional(rollbackFor = Exception.class) 168 @Transactional(rollbackFor = Exception.class)
170 public void deleteFriend(Long userId, Long friendUserId) { 169 public void deleteFriend(Long userId, Long friendUserId) {
171 // 1. 单边软删:仅 userId 视角的关系置 DISABLE;friendUserId 视角不动 170 // 1. 单边软删:仅 userId 视角的关系置 DISABLE;friendUserId 视角不动
  171 + // 不推 TIP 系统消息:单边删除语义下对方不应感知;userId 端反馈由前端 toast 承担,多端同步靠下面的 FRIEND_DELETE
172 getSelf().deleteFriend0(userId, friendUserId); 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 FriendDeleteNotification payload = (FriendDeleteNotification) new FriendDeleteNotification() 175 FriendDeleteNotification payload = (FriendDeleteNotification) new FriendDeleteNotification()
179 .setOperatorUserId(userId).setFriendUserId(friendUserId); 176 .setOperatorUserId(userId).setFriendUserId(friendUserId);
180 websocketService.sendPrivateMessageAsync(userId, ImPrivateMessageDTO.ofFriendNotification( 177 websocketService.sendPrivateMessageAsync(userId, ImPrivateMessageDTO.ofFriendNotification(