예제 #1
0
        public async Task ProcessUpdateNotification(StravaUpdateNotification updateNotification)
        {
            StravaSubscription subscription = await _stravaSubscriptionService.GetSubscriptionAsync();

            if (updateNotification.SubscriptionId != subscription.Id)
            {
                _logger.LogWarning($"Received Strava update for unrecognised subscription ID: {updateNotification.SubscriptionId}.");
                return;
            }

            Integration integration = await _integrationRepository.GetIntegrationAsync(Provider.Strava, updateNotification.OwnerId.ToString());

            if (integration is null)
            {
                _logger.LogWarning($"Received Strava update for owner ID with no integration '{updateNotification.OwnerId}'.");
                return;
            }

            await _eventPublisher.PublishAsync(
                new IntegrationProviderUpdateEvent(
                    id : Guid.NewGuid().ToString(),
                    subject : updateNotification.OwnerId.ToString(),
                    eventTime : _dateTimeProvider.UtcNow,
                    dataVersion : EventConstants.EventDataVersion,
                    data : new IntegrationProviderEventData
            {
                OperationId = _operationContext.OperationId,
                SourceSystem = EventConstants.IntegrationsApi,
                SubjectSystem = Provider.Strava.ToString(),
                Provider = Provider.Strava,
                ProviderData = updateNotification,
                UserId = integration.UserId
            }));
        }
예제 #2
0
        public async Task <ActionResult <StravaSubscription> > GetStravaSubscription()
        {
            StravaSubscription subscription = await _stravaSubscriptionService.GetSubscriptionAsync();

            if (subscription is null)
            {
                return(NotFound());
            }

            return(subscription);
        }