Ejemplo n.º 1
0
 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);
     }
 }
Ejemplo n.º 2
0
        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);
            }
        }
Ejemplo n.º 3
0
 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);
 }
Ejemplo n.º 4
0
        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);
        }
Ejemplo n.º 5
0
        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);
        }
Ejemplo n.º 6
0
        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);
        }
Ejemplo n.º 7
0
        private async Task PushRequestDeclinedAsync(NotificationModel model, DiscordNotificationSettings settings)
        {
            var message = $"Hello! Your request for {model.Title} has been declined, Sorry!";

            await Push(settings, message);
        }
Ejemplo n.º 8
0
        private async Task PushNewRequestAsync(NotificationModel model, DiscordNotificationSettings settings)
        {
            var message = $"{model.Title} has been requested by user: {model.User}";

            await Push(settings, message);
        }