public async Task PublishTest(NotificationModel model, Settings settings, INotification type) { await type.NotifyAsync(model, settings); }
/// <summary> /// Sends a notification to the user, this is usually for testing the settings. /// </summary> /// <param name="model">The model.</param> /// <param name="settings">The settings.</param> /// <returns></returns> public async Task Publish(NotificationModel model, Settings settings) { var notificationTasks = Observers.Values.Select(notification => NotifyAsync(notification, model, settings)); await Task.WhenAll(notificationTasks).ConfigureAwait(false); }
private async Task PushFaultQueue(NotificationModel model, DiscordNotificationSettings settings) { var message = $"Hello! The user '{model.User}' has requested {model.Title} but it could not be added. This has been added into the requests queue and will keep retrying"; await Push(settings, message); }
public async Task NotifyAsync(NotificationModel model) { var settings = Settings.GetSettings(); await NotifyAsync(model, settings); }
private async Task PushRequestDeclinedAsync(NotificationModel model, DiscordNotificationSettings settings) { var message = $"Hello! Your request for {model.Title} has been declined, Sorry!"; await Push(settings, message); }
private async Task PushIssueAsync(NotificationModel model, DiscordNotificationSettings settings) { var message = $"A new issue: {model.Body} has been reported by user: {model.User} for the title: {model.Title}"; await Push(settings, message); }
public async Task NotifyAsync(NotificationModel model, Settings settings) { if (settings == null) { await NotifyAsync(model); } var notificationSettings = (T)settings; if (!ValidateConfiguration(notificationSettings)) { return; } try { switch (model.NotificationType) { case NotificationType.NewRequest: await NewRequest(model, notificationSettings); break; case NotificationType.Issue: await Issue(model, notificationSettings); break; case NotificationType.RequestAvailable: await AvailableRequest(model, notificationSettings); break; case NotificationType.RequestApproved: await RequestApproved(model, notificationSettings); break; case NotificationType.AdminNote: throw new NotImplementedException(); case NotificationType.Test: await Test(model, notificationSettings); break; case NotificationType.RequestDeclined: await RequestDeclined(model, notificationSettings); break; case NotificationType.ItemAddedToFaultQueue: await AddedToRequestQueue(model, notificationSettings); break; default: throw new ArgumentOutOfRangeException(); } } catch (NotImplementedException) { // Do nothing, it's not implimented meaning it might not be ready or even used } }
private async Task PushNewRequestAsync(NotificationModel model, DiscordNotificationSettings settings) { var message = $"{model.Title} has been requested by user: {model.User}"; await Push(settings, message); }
protected abstract Task Test(NotificationModel model, T settings);
public async Task NotifyAsync(NotificationModel model) { var configuration = GetConfiguration(); await NotifyAsync(model, configuration); }
protected abstract Task AvailableRequest(NotificationModel model, T settings);
protected abstract Task RequestApproved(NotificationModel model, T settings);
protected abstract Task RequestDeclined(NotificationModel model, T settings);
protected abstract Task AddedToRequestQueue(NotificationModel model, T settings);
protected abstract Task Issue(NotificationModel model, T settings);