Commit 9d11741aa5b202deecb00232c35191c7e778e7dc
1 parent
9720f208
✨ feat(im): 优化好友重新添加逻辑,增强用户体验
实现好友关系的单边重新启用,推送隐私友好的通知,确保对方不感知好友状态的变化。此变更提升了用户在好友管理中的体验,保持了社交互动的自然性。
Showing
1 changed file
with
4 additions
and
2 deletions
yudao-module-im/src/main/java/cn/iocoder/yudao/module/im/service/friend/ImFriendServiceImpl.java
| ... | ... | @@ -155,10 +155,12 @@ public class ImFriendServiceImpl implements ImFriendService { |
| 155 | 155 | @Transactional(rollbackFor = Exception.class) |
| 156 | 156 | public void silentReAddFriend(Long userId, Long friendUserId, String displayName, Integer addSource) { |
| 157 | 157 | // 1. 单边重新启用我侧好友关系 |
| 158 | - // 不推 TIP 系统消息:sendPrivateMessage 是 (sender, receiver) 单条入库 + 双向可见,无法仅 userId 单边可见;对方不应感知 silent 重启,TIP 整体省略 | |
| 159 | 158 | addFriend0(userId, friendUserId, displayName, addSource); |
| 160 | 159 | |
| 161 | - // 2. 仅推 FRIEND_ADD 给 userId 多端(不通知对方,保持「对方一直把我当好友」的错觉) | |
| 160 | + // 2. 推 TIP「你们已成为好友」走单边语义(persistent=false):不入库 + 仅推 userId 多端,对方完全不感知 | |
| 161 | + privateMessageService.sendTipPrivateMessage(userId, friendUserId, FRIEND_ADD_TIP_MESSAGE, false); | |
| 162 | + | |
| 163 | + // 3. 仅推 FRIEND_ADD 给 userId 多端(不通知对方,保持「对方一直把我当好友」的错觉) | |
| 162 | 164 | // operatorUserId 填 friendUserId(对方):让 userId 多端 UI 呈现「对方加了我」的视觉效果,与 silent 语义对齐 |
| 163 | 165 | FriendAddNotification payload = (FriendAddNotification) new FriendAddNotification() |
| 164 | 166 | .setOperatorUserId(friendUserId).setFriendUserId(friendUserId); | ... | ... |