public async Task <Unit> Handle(UpdateParticipantSubscriptionsOfPollRequest request,
                                        CancellationToken cancellationToken)
        {
            var(conferenceId, poll) = request;

            var participantsSubscribed = await _mediator.Send(
                new FetchSubscribedParticipantsRequest(conferenceId, SynchronizedPoll.SyncObjId(poll.Id)));

            var participantsShouldBeSubscribed = await FetchParticipantsThatShouldBeSubscribed(conferenceId, poll);

            foreach (var participant in participantsSubscribed.Union(participantsShouldBeSubscribed))
            {
                await _mediator.Send(new UpdateSubscriptionsRequest(participant));
            }

            return(Unit.Value);
        }
示例#2
0
        public async Task CreatePoll_Global_ReceiveSyncPollObj()
        {
            // arrange
            var (connection, _) = await ConnectToOpenedConference();

            // act
            var instruction = new SingleChoiceInstruction(new[] {"A", "B"});
            var createDto = new CreatePollDto(instruction, new PollConfig("A or B?", true, false), PollState.Default,
                null);

            var pollId = await CreatePollReturnId(connection, createDto);

            await connection.SyncObjects.AssertSyncObject<SynchronizedPoll>(SynchronizedPoll.SyncObjId(pollId), poll =>
            {
                Assert.Equal(pollId, poll.Id);
                Assert.Equal(createDto.Config, poll.Config);
                Assert.Equal(createDto.InitialState, poll.State);

                var actualInstruction = Assert.IsType<SingleChoiceInstruction>(poll.Instruction);
                Assert.Equal(instruction.Options, actualInstruction.Options);
            });
        }
示例#3
0
        public async Task <Unit> Handle(UpdatePollStateRequest request, CancellationToken cancellationToken)
        {
            var(conferenceId, pollId, pollState) = request;

            var previousState = await _repository.SetPollState(conferenceId, pollId, pollState);

            var poll = await _repository.GetPoll(conferenceId, pollId);

            if (poll == null)
            {
                await _repository.DeletePollAndState(conferenceId, pollId);

                throw PollError.PollNotFound.ToException();
            }

            await _mediator.Send(new UpdateSynchronizedObjectRequest(conferenceId, SynchronizedPoll.SyncObjId(pollId)));

            if (request.State.ResultsPublished != previousState?.ResultsPublished)
            {
                await _mediator.Send(new UpdateParticipantSubscriptionsOfPollRequest(conferenceId, poll));
            }

            return(Unit.Value);
        }