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 <SuccessOrError <Unit> > Handle(SetTemporaryPermissionRequest request, CancellationToken cancellationToken) { var(participant, permissionKey, value) = request; if (!_permissionValidator.TryGetDescriptor(permissionKey, out var descriptor)) { return(PermissionsError.PermissionKeyNotFound(permissionKey)); } if (value != null) { if (!descriptor.ValidateValue(value)) { return(PermissionsError.InvalidPermissionValueType); } await _temporaryPermissionRepository.SetTemporaryPermission(participant, descriptor.Key, value); if (!await _participantsRepository.IsParticipantJoined(participant)) { _logger.LogDebug( "After setting temporary permissions for participant {participantId}, it was noticed that the participant is not currently joined. Remove temporary permission.", participant); await _temporaryPermissionRepository.RemoveAllTemporaryPermissions(participant); return(CommonError.ConcurrencyError); } } else { await _temporaryPermissionRepository.RemoveTemporaryPermission(participant, descriptor.Key); } await _mediator.Send(new UpdateParticipantsPermissionsRequest(participant.Yield())); await _mediator.Send(new UpdateSynchronizedObjectRequest(participant.ConferenceId, SynchronizedTemporaryPermissions.SyncObjId)); return(Unit.Value); }