Пример #1
0
        public async Task <IActionResult> GetMyPolling([FromBody] PollRequest request)
        {
            var requestToken = request.Token ?? default;

            if (requestToken != default)
            {
                requestToken = requestToken.Minus(Duration.FromSeconds(10));
            }

#pragma warning disable MA0040 // Flow the cancellation token
            if (request.Delivered?.Length > 0)
            {
                var tokens = request.Delivered.Select(x => TrackingToken.Parse(x));

                await userNotificationStore.TrackSeenAsync(tokens);
            }

            if (request.Seen?.Length > 0)
            {
                var tokens = request.Seen.Select(x => TrackingToken.Parse(x));

                await userNotificationStore.TrackSeenAsync(tokens);
            }

            foreach (var id in request.Confirmed.OrEmpty())
            {
                var token = TrackingToken.Parse(id);

                await userNotificationStore.TrackConfirmedAsync(token);
            }
#pragma warning restore MA0040 // Flow the cancellation token

            foreach (var id in request.Deleted.OrEmpty())
            {
                await userNotificationStore.DeleteAsync(id, HttpContext.RequestAborted);
            }

            var notifications = await userNotificationStore.QueryAsync(App.Id, UserId, DefaultQuery with {
                After = requestToken
            }, HttpContext.RequestAborted);