예제 #1
0
        public async Task <IActionResult> Confirm(string id, [FromQuery] string?channel = null, [FromQuery] string?deviceIdentifier = null)
        {
            var token = TrackingToken.Parse(id, channel, deviceIdentifier);

            await userNotificationService.TrackConfirmedAsync(token);

            var notification = await userNotificationStore.FindAsync(token.Id, HttpContext.RequestAborted);

            if (notification == null)
            {
                return(View());
            }

            var app = await appStore.GetCachedAsync(notification.AppId, HttpContext.RequestAborted);

            if (app?.ConfirmUrl != null && Uri.IsWellFormedUriString(app.ConfirmUrl, UriKind.Absolute))
            {
                var url = app.ConfirmUrl !;

                if (url.Contains('?', StringComparison.OrdinalIgnoreCase))
                {
                    url += $"&id={id:notEmpty}";
                }
                else
                {
                    url += $"?id={id:notEmpty}";
                }

                return(Redirect(url));
            }

            return(View());
        }
예제 #2
0
        public async Task Confirm([FromBody] TrackNotificationDto request)
        {
            if (request.Confirmed.HasValue)
            {
                await userNotificationService.TrackConfirmedAsync(request.Confirmed.Value, request.Channel);
            }

            if (request.Seen?.Length > 0)
            {
                await userNotificationService.TrackSeenAsync(request.Seen, request.Channel);
            }
        }
예제 #3
0
        public async Task <IActionResult> Confirm(Guid id, [FromQuery] string?channel = null)
        {
            var(_, app) = await userNotificationService.TrackConfirmedAsync(id, channel);

            if (app?.ConfirmUrl != null && Uri.IsWellFormedUriString(app.ConfirmUrl, UriKind.Absolute))
            {
                var url = app.WebhookUrl !;

                if (url.Contains("?", StringComparison.OrdinalIgnoreCase))
                {
                    url += $"&id={id}";
                }
                else
                {
                    url += $"?id={id}";
                }

                return(Redirect(url));
            }

            return(View());
        }
예제 #4
0
        public async Task <IActionResult> ConfirmMe([FromBody] TrackNotificationDto request)
        {
            if (request.Confirmed != null)
            {
                var token = TrackingToken.Parse(request.Confirmed, request.Channel, request.DeviceIdentifier);

                await userNotificationService.TrackConfirmedAsync(token);
            }

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

                await userNotificationService.TrackSeenAsync(tokens);
            }

            return(NoContent());
        }