public async Task <IReadOnlyList <Participant> > Handle(FetchSubscribedParticipantsRequest request, CancellationToken cancellationToken) { var(conferenceId, synchronizedObjectId) = request; var subscriptions = await _subscriptionsRepository.GetOfConference(conferenceId); return(ConferenceSubscriptionHelper.GetParticipantIdsSubscribedTo(subscriptions, synchronizedObjectId) .Select(id => new Participant(conferenceId, id)).ToList()); }
public async Task Handle(ParticipantSubscriptionsUpdatedNotification notification, CancellationToken cancellationToken) { var((conferenceId, _), removedSubscriptions, _) = notification; if (!removedSubscriptions.Any()) { return; } var conferenceSubscriptions = await _subscriptionsRepository.GetOfConference(conferenceId); var activeSyncObjects = conferenceSubscriptions.SelectMany(x => x.Value ?? ImmutableList <string> .Empty) .ToHashSet(); var inactiveSyncObjects = removedSubscriptions.Select(x => x.ToString()).Except(activeSyncObjects); foreach (var inactiveSubscription in inactiveSyncObjects) { await _synchronizedObjectRepository.Remove(conferenceId, inactiveSubscription); } }