视频会议
This commit is contained in:
@@ -355,7 +355,62 @@ func (s *MeetingService) CreateRoom(ctx context.Context, hostID int64, req *dto.
|
||||
}
|
||||
|
||||
func (s *MeetingService) CreateRoomForInternal(ctx context.Context, hostID int64, req *dto.CreateMeetingRoomRequest) (*model.MeetingRoom, *model.MeetingParticipant, string, error) {
|
||||
return s.createRoom(ctx, hostID, req, false, false, "service.meeting_service.CreateRoomForInternal")
|
||||
return s.createRoom(ctx, hostID, req, false, true, "service.meeting_service.CreateRoomForInternal")
|
||||
}
|
||||
|
||||
func (s *MeetingService) JoinRoomForInternal(ctx context.Context, userID int64, code string) (*model.MeetingRoom, *model.MeetingParticipant, string, error) {
|
||||
funcName := "service.meeting_service.JoinRoomForInternal"
|
||||
room, err := s.roomDAO.GetByCode(ctx, code)
|
||||
if err != nil {
|
||||
return nil, nil, "", err
|
||||
}
|
||||
if room == nil {
|
||||
return nil, nil, "", ErrMeetingNotFound
|
||||
}
|
||||
if room.Status == constants.MeetingStatusEnded {
|
||||
return nil, nil, "", ErrMeetingEnded
|
||||
}
|
||||
if existing, pErr := s.participantDAO.GetByRoomAndUser(ctx, room.ID, userID); pErr != nil {
|
||||
return nil, nil, "", pErr
|
||||
} else if existing != nil && existing.IsActive() {
|
||||
routerID, _ := s.mediaOrchestrator.ResolveRouterID(code)
|
||||
return room, existing, routerID, nil
|
||||
}
|
||||
activeCount, err := s.participantDAO.CountActiveByRoom(ctx, room.ID)
|
||||
if err != nil {
|
||||
return nil, nil, "", err
|
||||
}
|
||||
if int(activeCount) >= room.MaxMembers {
|
||||
return nil, nil, "", ErrMeetingFull
|
||||
}
|
||||
participant, err := s.participantDAO.JoinRoom(ctx, room.ID, userID, constants.MeetingRoleParticipant)
|
||||
if err != nil {
|
||||
if errors.Is(err, dao.ErrAlreadyInMeeting) {
|
||||
existing, getErr := s.participantDAO.GetByRoomAndUser(ctx, room.ID, userID)
|
||||
if getErr != nil {
|
||||
return nil, nil, "", getErr
|
||||
}
|
||||
routerID, _ := s.mediaOrchestrator.ResolveRouterID(code)
|
||||
return room, existing, routerID, nil
|
||||
}
|
||||
return nil, nil, "", err
|
||||
}
|
||||
if s.lifecycleSvc != nil {
|
||||
s.lifecycleSvc.CancelEmptyTTL(ctx, code)
|
||||
}
|
||||
routerID, _ := s.mediaOrchestrator.ResolveRouterID(code)
|
||||
if routerID == "" {
|
||||
newID, mediaErr := s.mediaOrchestrator.CreateRouter(ctx, code)
|
||||
if mediaErr != nil {
|
||||
if _, leaveErr := s.participantDAO.LeaveRoom(ctx, room.ID, userID, constants.MeetingLeftReasonSelf); leaveErr != nil {
|
||||
logs.Warn(ctx, funcName, "内部入会补偿 LeaveRoom 失败", zap.Int64("room_id", room.ID), zap.Int64("user_id", userID), zap.Error(leaveErr))
|
||||
}
|
||||
return nil, nil, "", ErrMediaServiceUnavailable
|
||||
}
|
||||
routerID = newID
|
||||
}
|
||||
logs.Info(ctx, funcName, "云律接单人加入会议成功", zap.String("room_code", code), zap.Int64("user_id", userID))
|
||||
return room, participant, routerID, nil
|
||||
}
|
||||
|
||||
func (s *MeetingService) createRoom(ctx context.Context, hostID int64, req *dto.CreateMeetingRoomRequest, enforceSingleActive bool, addHostParticipant bool, funcName string) (*model.MeetingRoom, *model.MeetingParticipant, string, error) {
|
||||
|
||||
Reference in New Issue
Block a user