public async Task Handle(ParticipantLeftNotification notification, CancellationToken cancellationToken)
        {
            var(participant, _) = notification;

            await _permissionRepository.DeletePermissions(participant);

            await _temporaryPermissionRepository.RemoveAllTemporaryPermissions(participant);

            await _mediator.Send(new UpdateSynchronizedObjectRequest(notification.Participant.ConferenceId,
                                                                     SynchronizedTemporaryPermissions.SyncObjId));
        }
        public async Task <Unit> Handle(UpdateParticipantsPermissionsRequest request,
                                        CancellationToken cancellationToken)
        {
            var participants = request.Participants;

            var newPermissions = new Dictionary <Participant, PermissionsDict>();

            foreach (var participant in participants)
            {
                newPermissions.Add(participant,
                                   await _permissionLayersAggregator.FetchAggregatedPermissions(participant));

                cancellationToken.ThrowIfCancellationRequested();
            }

            _logger.LogDebug("Update permissions for {count} participants", newPermissions.Count);

            var appliedPermissions = new Dictionary <Participant, PermissionsDict>();

            foreach (var(participant, permissions) in newPermissions)
            {
                await _permissionRepository.SetPermissions(participant, permissions);

                if (await _joinedParticipantsRepository.IsParticipantJoined(participant))
                {
                    appliedPermissions.Add(participant, permissions);
                }
                else
                {
                    _logger.LogDebug("Participant {participantId} is not joined to the conference, remove permissions.",
                                     participant);
                    await _permissionRepository.DeletePermissions(participant);
                }
            }

            if (appliedPermissions.Any())
            {
                await _mediator.Publish(new ParticipantPermissionsUpdatedNotification(appliedPermissions));
            }

            return(Unit.Value);
        }