Пример #1
0
        public async Task <IActionResult> ProcessAsync()
        {
            await _eventsTable.CreateIfNotExistsAsync();

            try
            {
                Validator.ValidateRequest(_joinMeetingRequest);

                var events = _eventsTable
                             .CreateQuery <EventDto>()
                             .AsQueryable()
                             .Where(e => e.RowKey == _joinMeetingRequest.EventId)
                             .ToArray();

                if (events.Length == 0 || !events[0].EventGuests.Contains(_loginUserEmail))
                {
                    return(new NotFoundResult());
                }

                var @event = events[0];

                await TwilioService.CreateMeetingRoomAsync(@event);

                var meetingRoomToken = TwilioService.GetMeetingRoomJoinToken(@event, _loginUserEmail);

                _logger.LogInformation("User {0} joined meeting for event {1}", _loginUserEmail, @event.RowKey);

                return(new OkObjectResult(new { @event, meetingRoomToken }));
            }
            catch (ValidationException e)
            {
                return(new BadRequestObjectResult(new { errors = e.Message }));
            }
        }
Пример #2
0
        public async Task <IActionResult> ProcessAsync()
        {
            var response = new DialInVoiceResponse();

            _logger.LogInformation(
                "Incoming call from {0} on account {1} for meeting {2}",
                _joinMeetingRequest.Caller,
                _joinMeetingRequest.AccountSid,
                _joinMeetingRequest.Digits);

            if (TwilioService.ValidAccountSid(_joinMeetingRequest.AccountSid))
            {
                var events = _eventsTable
                             .CreateQuery <EventDto>()
                             .AsQueryable()
                             .Where(e => e.RoomId == _joinMeetingRequest.Digits)
                             .ToArray();

                if (events.Length == 0)
                {
                    response
                    .Say(
                        message: "The code you entered is incorrect, " +
                        "please make sure to enter the 4 digit code " +
                        "provided in the event followed by " +
                        "hash key.",
                        language: TwilioService.Language,
                        voice: TwilioService.Voice,
                        loop: 1)
                    .Gather(
                        input: TwilioService.PhoneInput,
                        finishOnKey: "#",
                        timeout: 15,
                        actionOnEmptyResult: true,
                        action: new Uri("meeting", UriKind.Relative),
                        method: Twilio.Http.HttpMethod.Post);
                }
                else
                {
                    await TwilioService.CreateMeetingRoomAsync(events[0]);

                    var roomName = TwilioService.GetRoomName(events[0]);

                    response
                    .Say(
                        message: "Thank you, we are connecting you to the call.",
                        language: TwilioService.Language,
                        voice: TwilioService.Voice,
                        loop: 1)
                    .Append(new ConnectMeeting().Room(
                                roomName,
                                _joinMeetingRequest.Caller));
                }
            }
            else
            {
                response
                .Say(
                    message: "Invalid account.",
                    language: TwilioService.Language,
                    voice: TwilioService.Voice,
                    loop: 1);
            }

            return(response.ToWebResponse());
        }