Example #1
0
        public async Task JoinToChannelAsync(JoinToChannelRequest request)
        {
            if (request.ChannelId == Guid.Empty)
            {
                throw new Exception(LanguageResources.Join_RoomRequired);
            }

            // Locate the room, does NOT have to be open
            try
            {
                var member = await _memberService.GetMemberSummaryBySaasUserIdAsync(request.SaasUserId);

                var isMemberExistInChannel = await _channelService.CheckIfMemberExistInChannelAsync(new InviteMemberRequest(request.SaasUserId, request.ChannelId, member.Id));

                if (!isMemberExistInChannel)
                {
                    await _channelService.JoinToChannelAsync(request);

                    var channel = await _channelService.GetChannelSummaryAsync(new ChannelRequest(request.SaasUserId, request.ChannelId));

                    await _channelNotificationHub.OnJoinChannel(member, channel);
                }
            }
            catch (NotFoundException ex)
            {
                _logger.Event(PropertyNames.EventId).With.Message("Exception: Channel does not exist. ChannelId: {channelId}", request.ChannelId).Exception(ex).AsError();
                throw new Exception(String.Format(LanguageResources.RoomNotFound, request.ChannelId));
            }
        }