diff --git a/src/Ombi.Notifications/Agents/DiscordNotification.cs b/src/Ombi.Notifications/Agents/DiscordNotification.cs index b013fbf07..a85ddff48 100644 --- a/src/Ombi.Notifications/Agents/DiscordNotification.cs +++ b/src/Ombi.Notifications/Agents/DiscordNotification.cs @@ -121,16 +121,27 @@ namespace Ombi.Notifications.Agents fields.Add(new DiscordField { name = "Denied Reason", value = denyReason, inline = true }); } } + + var color = string.Empty; if (model.Data.TryGetValue("RequestStatus", out var status)) { if (status.HasValue()) { fields.Add(new DiscordField { name = "Status", value = status, inline = true }); + + color = status switch + { + "Available" => "51283", + "Denied" => "13959168", + "Processing Request" => "37354", + "Pending Approval" => "16754470" + }; } } var author = new DiscordAuthor { + iconurl = settings.Icon.HasValue() ? settings.Icon : string.Empty }; if (model.Data.TryGetValue("ApplicationUrl", out var appUrl)) @@ -142,10 +153,13 @@ namespace Ombi.Notifications.Agents author.name = appName; } + + var embed = new DiscordEmbeds { fields = fields, - author = author + author = author, + color = color }; if (model.Data.TryGetValue("Title", out var title)) @@ -162,8 +176,10 @@ namespace Ombi.Notifications.Agents embed.thumbnail = new DiscordImage { url = image }; } - discordBody.embeds = new List { embed }; - + if (model.Data.Any()) + { + discordBody.embeds = new List { embed }; + } await Api.SendMessage(discordBody, settings.WebHookId, settings.Token); } catch (Exception e) diff --git a/src/Ombi.Notifications/Models/NotificationMessage.cs b/src/Ombi.Notifications/Models/NotificationMessage.cs index 7ffd48e63..1e0fbf2d6 100644 --- a/src/Ombi.Notifications/Models/NotificationMessage.cs +++ b/src/Ombi.Notifications/Models/NotificationMessage.cs @@ -9,6 +9,6 @@ namespace Ombi.Notifications.Models public string To { get; set; } public Dictionary Other { get; set; } = new Dictionary(); - public IDictionary Data { get; set; } + public IDictionary Data { get; set; } = new Dictionary(); } } \ No newline at end of file diff --git a/src/Ombi.Settings/Settings/Models/Notifications/DiscordNotificationSettings.cs b/src/Ombi.Settings/Settings/Models/Notifications/DiscordNotificationSettings.cs index 2616fa4c3..45dc17ee1 100644 --- a/src/Ombi.Settings/Settings/Models/Notifications/DiscordNotificationSettings.cs +++ b/src/Ombi.Settings/Settings/Models/Notifications/DiscordNotificationSettings.cs @@ -8,6 +8,7 @@ namespace Ombi.Settings.Settings.Models.Notifications public bool Enabled { get; set; } public string WebhookUrl { get; set; } public string Username { get; set; } + public string Icon { get; set; } [JsonIgnore] public string WebHookId => SplitWebUrl(4); diff --git a/src/Ombi/ClientApp/src/app/interfaces/INotificationSettings.ts b/src/Ombi/ClientApp/src/app/interfaces/INotificationSettings.ts index 6a96a55e1..d08778e2a 100644 --- a/src/Ombi/ClientApp/src/app/interfaces/INotificationSettings.ts +++ b/src/Ombi/ClientApp/src/app/interfaces/INotificationSettings.ts @@ -58,6 +58,7 @@ export enum NotificationType { export interface IDiscordNotifcationSettings extends INotificationSettings { webhookUrl: string; username: string; + icon: string; notificationTemplates: INotificationTemplates[]; } diff --git a/src/Ombi/ClientApp/src/app/settings/notifications/discord.component.html b/src/Ombi/ClientApp/src/app/settings/notifications/discord.component.html index 97900daf0..140198c94 100644 --- a/src/Ombi/ClientApp/src/app/settings/notifications/discord.component.html +++ b/src/Ombi/ClientApp/src/app/settings/notifications/discord.component.html @@ -25,8 +25,17 @@ +
+ + Icon + + +
+ +
+
-
+
diff --git a/src/Ombi/ClientApp/src/app/settings/notifications/discord.component.ts b/src/Ombi/ClientApp/src/app/settings/notifications/discord.component.ts index 7c0222d96..73f271894 100644 --- a/src/Ombi/ClientApp/src/app/settings/notifications/discord.component.ts +++ b/src/Ombi/ClientApp/src/app/settings/notifications/discord.component.ts @@ -29,6 +29,7 @@ export class DiscordComponent implements OnInit { enabled: [x.enabled], username: [x.username], webhookUrl: [x.webhookUrl, [Validators.required]], + icon: [x.icon] }); });