public async Task HandleSeenAsync(TrackingToken token) { using (Telemetry.Activities.StartActivity("MobilePushChannel/HandleSeenAsync")) { var mobileToken = token.DeviceIdentifier; if (string.IsNullOrWhiteSpace(mobileToken)) { return; } var notification = await userNotificationStore.FindAsync(token.Id); if (notification == null) { return; } var user = await userStore.GetCachedAsync(notification.AppId, notification.UserId); if (user == null) { return; } var userToken = user.MobilePushTokens.FirstOrDefault(x => x.Token == mobileToken && x.DeviceType == MobileDeviceType.iOS); if (userToken != null) { await TryWakeupAsync(notification, userToken, default); } } }
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()); }
public async Task HandleResponseAsync(string reference, SmsResult result) { if (Guid.TryParse(reference, out var id)) { var notification = await userNotificationStore.FindAsync(id); if (notification != null && notification.Sending.TryGetValue(Name, out var sending) && sending.Status == ProcessStatus.Attempt) { if (result == SmsResult.Delivered) { await UpdateAsync(notification, ProcessStatus.Handled); } else if (result == SmsResult.Failed) { await UpdateAsync(notification, ProcessStatus.Handled); } } } }
public async Task HandleCallbackAsync(string to, string token, SmsResult result, CancellationToken ct) { using (Telemetry.Activities.StartActivity("SmsChannel/HandleCallbackAsync")) { if (Guid.TryParse(token, out var id)) { var notification = await userNotificationStore.FindAsync(id, ct); if (notification != null) { await UpdateAsync(to, result, notification); } if (result == SmsResult.Delivered) { userNotificationQueue.Complete(SmsJob.ComputeScheduleKey(id)); } } } }