private async Task Push(DiscordNotificationSettings config, string message) { try { await Api.SendMessageAsync(message, config.WebookId, config.Token, config.Username); } catch (Exception e) { Log.Error(e); } }
public bool Discord([FromBody] DiscordNotificationSettings settings) { try { settings.Enabled = true; DiscordNotification.NotifyAsync( new NotificationOptions { NotificationType = NotificationType.Test, RequestId = -1 }, settings); return(true); } catch (Exception e) { Log.LogError(LoggingEvents.Api, e, "Could not test Discord"); return(false); } }
private bool ValidateConfiguration(DiscordNotificationSettings settings) { if (!settings.Enabled) { return(false); } if (string.IsNullOrEmpty(settings.WebhookUrl)) { return(false); } try { var a = settings.Token; var b = settings.WebookId; } catch (IndexOutOfRangeException) { return(false); } return(true); }
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); }
private async Task PushTest(DiscordNotificationSettings settings) { var message = $"This is a test from Ombi, if you can see this then we have successfully pushed a notification!"; 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); }
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 PushNewRequestAsync(NotificationModel model, DiscordNotificationSettings settings) { var message = $"{model.Title} has been requested by user: {model.User}"; await Push(settings, message); }