public async Task <bool> HandleAsync(List <EmailJob> jobs, bool isLastAttempt, CancellationToken ct) { var links = jobs.SelectMany(x => x.Notification.Links()); var parentContext = Activity.Current?.Context ?? default; using (Telemetry.Activities.StartActivity("EmailChannel/Handle", ActivityKind.Internal, parentContext, links: links)) { var unhandledJobs = new List <EmailJob>(); foreach (var job in jobs) { if (await userNotificationStore.IsHandledAsync(job, this, ct)) { await UpdateAsync(job.Notification, job.EmailAddress, ProcessStatus.Skipped); } else { unhandledJobs.Add(job); } } if (unhandledJobs.Any()) { await SendJobsAsync(unhandledJobs, ct); } return(true); } }
public async Task <bool> HandleAsync(WebPushJob job, bool isLastAttempt, CancellationToken ct) { var links = job.Links(); var parentContext = Activity.Current?.Context ?? default; using (Telemetry.Activities.StartActivity("WebPushChannel/HandleAsync", ActivityKind.Internal, parentContext, links: links)) { if (await userNotificationStore.IsHandledAsync(job, this, ct)) { await UpdateAsync(job, ProcessStatus.Skipped); } else { await SendAsync(job, ct); } return(true); } }