Commit 9ce816e247805acee441f245f6fb4b9e37b77b66
1 parent
70271c1c
✨ feat(im): 优化群邀请的 incoming、inviting 的交互
Showing
2 changed files
with
23 additions
and
9 deletions
yudao-module-im/src/main/java/cn/iocoder/yudao/module/im/service/rtc/ImRtcCallServiceImpl.java
| @@ -232,7 +232,7 @@ public class ImRtcCallServiceImpl implements ImRtcCallService { | @@ -232,7 +232,7 @@ public class ImRtcCallServiceImpl implements ImRtcCallService { | ||
| 232 | AdminUserRespDTO inviterUser = adminUserApi.getUser(inviterId); | 232 | AdminUserRespDTO inviterUser = adminUserApi.getUser(inviterId); |
| 233 | Map<Long, AdminUserRespDTO> inviteeMap = adminUserApi.getUserMap(invitees); | 233 | Map<Long, AdminUserRespDTO> inviteeMap = adminUserApi.getUserMap(invitees); |
| 234 | for (Long inviteeId : invitees) { | 234 | for (Long inviteeId : invitees) { |
| 235 | - pushCallInviteNotification(call, inviterUser, inviteeId, inviteeMap.get(inviteeId)); | 235 | + pushCallInviteNotification(call, inviterUser, inviteeId, inviteeMap.get(inviteeId), invitees); |
| 236 | } | 236 | } |
| 237 | // 3.2 群通话再向全群广播 RTC_CALL_START 入聊天流 | 237 | // 3.2 群通话再向全群广播 RTC_CALL_START 入聊天流 |
| 238 | if (ImConversationTypeEnum.isGroup(reqVO.getConversationType())) { | 238 | if (ImConversationTypeEnum.isGroup(reqVO.getConversationType())) { |
| @@ -303,7 +303,7 @@ public class ImRtcCallServiceImpl implements ImRtcCallService { | @@ -303,7 +303,7 @@ public class ImRtcCallServiceImpl implements ImRtcCallService { | ||
| 303 | AdminUserRespDTO inviter = adminUserApi.getUser(inviterId); | 303 | AdminUserRespDTO inviter = adminUserApi.getUser(inviterId); |
| 304 | Map<Long, AdminUserRespDTO> inviteeMap = adminUserApi.getUserMap(incomingUserIds); | 304 | Map<Long, AdminUserRespDTO> inviteeMap = adminUserApi.getUserMap(incomingUserIds); |
| 305 | for (Long inviteeId : incomingUserIds) { | 305 | for (Long inviteeId : incomingUserIds) { |
| 306 | - pushCallInviteNotification(call, inviter, inviteeId, inviteeMap.get(inviteeId)); | 306 | + pushCallInviteNotification(call, inviter, inviteeId, inviteeMap.get(inviteeId), incomingUserIds); |
| 307 | } | 307 | } |
| 308 | } | 308 | } |
| 309 | 309 | ||
| @@ -820,16 +820,18 @@ public class ImRtcCallServiceImpl implements ImRtcCallService { | @@ -820,16 +820,18 @@ public class ImRtcCallServiceImpl implements ImRtcCallService { | ||
| 820 | /** | 820 | /** |
| 821 | * RTC_CALL(INVITE):走 webSocketService 直推到被邀请人;persistent=false 不入消息流 | 821 | * RTC_CALL(INVITE):走 webSocketService 直推到被邀请人;persistent=false 不入消息流 |
| 822 | * | 822 | * |
| 823 | - * @param call 通话主表 | ||
| 824 | - * @param inviter 发起人;可空,缺失时 payload 的 inviterNickname / Avatar 留空 | ||
| 825 | - * @param inviteeId 被邀请人用户编号 | ||
| 826 | - * @param invitee 被邀请人;可空,缺失时 token 内 displayName 降级为 userId | 823 | + * @param call 通话主表 |
| 824 | + * @param inviter 发起人;可空,缺失时 payload 的 inviterNickname / Avatar 留空 | ||
| 825 | + * @param inviteeId 被邀请人用户编号 | ||
| 826 | + * @param invitee 被邀请人;可空,缺失时 token 内 displayName 降级为 userId | ||
| 827 | + * @param inviteeIds 本次被邀请人列表;前端来电界面展示「邀请的其他人」用,包含 inviteeId 自身 | ||
| 827 | */ | 828 | */ |
| 828 | private void pushCallInviteNotification(ImRtcCallDO call, AdminUserRespDTO inviter, | 829 | private void pushCallInviteNotification(ImRtcCallDO call, AdminUserRespDTO inviter, |
| 829 | - Long inviteeId, AdminUserRespDTO invitee) { | 830 | + Long inviteeId, AdminUserRespDTO invitee, |
| 831 | + Collection<Long> inviteeIds) { | ||
| 830 | String token = signToken(inviteeId, resolveDisplayName(invitee, inviteeId), call.getRoom()); | 832 | String token = signToken(inviteeId, resolveDisplayName(invitee, inviteeId), call.getRoom()); |
| 831 | ImRtcCallNotification payload = ImRtcCallNotification.ofInvite( | 833 | ImRtcCallNotification payload = ImRtcCallNotification.ofInvite( |
| 832 | - call, inviter, imProperties.getRtc().getLivekitUrl(), token); | 834 | + call, inviter, imProperties.getRtc().getLivekitUrl(), token, inviteeIds); |
| 833 | webSocketService.sendPrivateMessageAsync(inviteeId, ImPrivateMessageDTO.ofRtcNotification( | 835 | webSocketService.sendPrivateMessageAsync(inviteeId, ImPrivateMessageDTO.ofRtcNotification( |
| 834 | ImMessageTypeEnum.RTC_CALL.getType(), call.getInviterUserId(), inviteeId, payload)); | 836 | ImMessageTypeEnum.RTC_CALL.getType(), call.getInviterUserId(), inviteeId, payload)); |
| 835 | } | 837 | } |
yudao-module-im/src/main/java/cn/iocoder/yudao/module/im/service/websocket/dto/notification/rtc/ImRtcCallNotification.java
| @@ -5,6 +5,9 @@ import cn.iocoder.yudao.module.im.enums.rtc.ImRtcParticipantStatusEnum; | @@ -5,6 +5,9 @@ import cn.iocoder.yudao.module.im.enums.rtc.ImRtcParticipantStatusEnum; | ||
| 5 | import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; | 5 | import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; |
| 6 | import lombok.Data; | 6 | import lombok.Data; |
| 7 | 7 | ||
| 8 | +import java.util.Collection; | ||
| 9 | +import java.util.List; | ||
| 10 | + | ||
| 8 | /** | 11 | /** |
| 9 | * RTC_CALL 通话信令通知(通话信令统一入口) | 12 | * RTC_CALL 通话信令通知(通话信令统一入口) |
| 10 | * <p> | 13 | * <p> |
| @@ -63,6 +66,12 @@ public class ImRtcCallNotification { | @@ -63,6 +66,12 @@ public class ImRtcCallNotification { | ||
| 63 | * 发起人头像;INVITE 专属,前端来电界面展示 | 66 | * 发起人头像;INVITE 专属,前端来电界面展示 |
| 64 | */ | 67 | */ |
| 65 | private String inviterAvatar; | 68 | private String inviterAvatar; |
| 69 | + /** | ||
| 70 | + * 本次被邀请人列表;INVITE 专属,前端来电界面展示「邀请的其他人」 | ||
| 71 | + * | ||
| 72 | + * 注意:包含收件人自身,前端按需过滤 | ||
| 73 | + */ | ||
| 74 | + private List<Long> inviteeIds; | ||
| 66 | 75 | ||
| 67 | // ========== REJECT 专属字段 ========== | 76 | // ========== REJECT 专属字段 ========== |
| 68 | 77 | ||
| @@ -86,10 +95,12 @@ public class ImRtcCallNotification { | @@ -86,10 +95,12 @@ public class ImRtcCallNotification { | ||
| 86 | * @param inviter 发起人;可空,缺失时 inviterNickname / inviterAvatar 留空 | 95 | * @param inviter 发起人;可空,缺失时 inviterNickname / inviterAvatar 留空 |
| 87 | * @param livekitUrl LiveKit Server WebSocket 地址 | 96 | * @param livekitUrl LiveKit Server WebSocket 地址 |
| 88 | * @param token 被叫的接听 Token;按收件人单独签发 | 97 | * @param token 被叫的接听 Token;按收件人单独签发 |
| 98 | + * @param inviteeIds 本次被邀请人列表;前端来电界面展示「邀请的其他人」用 | ||
| 89 | * @return INVITE 信令 | 99 | * @return INVITE 信令 |
| 90 | */ | 100 | */ |
| 91 | public static ImRtcCallNotification ofInvite(ImRtcCallDO call, AdminUserRespDTO inviter, | 101 | public static ImRtcCallNotification ofInvite(ImRtcCallDO call, AdminUserRespDTO inviter, |
| 92 | - String livekitUrl, String token) { | 102 | + String livekitUrl, String token, |
| 103 | + Collection<Long> inviteeIds) { | ||
| 93 | ImRtcCallNotification notification = baseOf(call, ImRtcParticipantStatusEnum.INVITING.getStatus()); | 104 | ImRtcCallNotification notification = baseOf(call, ImRtcParticipantStatusEnum.INVITING.getStatus()); |
| 94 | notification.livekitUrl = livekitUrl; | 105 | notification.livekitUrl = livekitUrl; |
| 95 | notification.token = token; | 106 | notification.token = token; |
| @@ -98,6 +109,7 @@ public class ImRtcCallNotification { | @@ -98,6 +109,7 @@ public class ImRtcCallNotification { | ||
| 98 | notification.inviterNickname = inviter.getNickname(); | 109 | notification.inviterNickname = inviter.getNickname(); |
| 99 | notification.inviterAvatar = inviter.getAvatar(); | 110 | notification.inviterAvatar = inviter.getAvatar(); |
| 100 | } | 111 | } |
| 112 | + notification.inviteeIds = inviteeIds != null ? new java.util.ArrayList<>(inviteeIds) : null; | ||
| 101 | return notification; | 113 | return notification; |
| 102 | } | 114 | } |
| 103 | 115 |