mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-08-19 12:59:39 -07:00
Finished off the discord enhancements
This commit is contained in:
parent
31060fff61
commit
466c9dada7
6 changed files with 33 additions and 5 deletions
|
@ -121,16 +121,27 @@ namespace Ombi.Notifications.Agents
|
||||||
fields.Add(new DiscordField { name = "Denied Reason", value = denyReason, inline = true });
|
fields.Add(new DiscordField { name = "Denied Reason", value = denyReason, inline = true });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var color = string.Empty;
|
||||||
if (model.Data.TryGetValue("RequestStatus", out var status))
|
if (model.Data.TryGetValue("RequestStatus", out var status))
|
||||||
{
|
{
|
||||||
if (status.HasValue())
|
if (status.HasValue())
|
||||||
{
|
{
|
||||||
fields.Add(new DiscordField { name = "Status", value = status, inline = true });
|
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
|
var author = new DiscordAuthor
|
||||||
{
|
{
|
||||||
|
iconurl = settings.Icon.HasValue() ? settings.Icon : string.Empty
|
||||||
};
|
};
|
||||||
|
|
||||||
if (model.Data.TryGetValue("ApplicationUrl", out var appUrl))
|
if (model.Data.TryGetValue("ApplicationUrl", out var appUrl))
|
||||||
|
@ -142,10 +153,13 @@ namespace Ombi.Notifications.Agents
|
||||||
author.name = appName;
|
author.name = appName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
var embed = new DiscordEmbeds
|
var embed = new DiscordEmbeds
|
||||||
{
|
{
|
||||||
fields = fields,
|
fields = fields,
|
||||||
author = author
|
author = author,
|
||||||
|
color = color
|
||||||
};
|
};
|
||||||
|
|
||||||
if (model.Data.TryGetValue("Title", out var title))
|
if (model.Data.TryGetValue("Title", out var title))
|
||||||
|
@ -162,8 +176,10 @@ namespace Ombi.Notifications.Agents
|
||||||
embed.thumbnail = new DiscordImage { url = image };
|
embed.thumbnail = new DiscordImage { url = image };
|
||||||
}
|
}
|
||||||
|
|
||||||
discordBody.embeds = new List<DiscordEmbeds> { embed };
|
if (model.Data.Any())
|
||||||
|
{
|
||||||
|
discordBody.embeds = new List<DiscordEmbeds> { embed };
|
||||||
|
}
|
||||||
await Api.SendMessage(discordBody, settings.WebHookId, settings.Token);
|
await Api.SendMessage(discordBody, settings.WebHookId, settings.Token);
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
|
|
|
@ -9,6 +9,6 @@ namespace Ombi.Notifications.Models
|
||||||
public string To { get; set; }
|
public string To { get; set; }
|
||||||
|
|
||||||
public Dictionary<string, string> Other { get; set; } = new Dictionary<string, string>();
|
public Dictionary<string, string> Other { get; set; } = new Dictionary<string, string>();
|
||||||
public IDictionary<string, string> Data { get; set; }
|
public IDictionary<string, string> Data { get; set; } = new Dictionary<string, string>();
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -8,6 +8,7 @@ namespace Ombi.Settings.Settings.Models.Notifications
|
||||||
public bool Enabled { get; set; }
|
public bool Enabled { get; set; }
|
||||||
public string WebhookUrl { get; set; }
|
public string WebhookUrl { get; set; }
|
||||||
public string Username { get; set; }
|
public string Username { get; set; }
|
||||||
|
public string Icon { get; set; }
|
||||||
|
|
||||||
[JsonIgnore]
|
[JsonIgnore]
|
||||||
public string WebHookId => SplitWebUrl(4);
|
public string WebHookId => SplitWebUrl(4);
|
||||||
|
|
|
@ -58,6 +58,7 @@ export enum NotificationType {
|
||||||
export interface IDiscordNotifcationSettings extends INotificationSettings {
|
export interface IDiscordNotifcationSettings extends INotificationSettings {
|
||||||
webhookUrl: string;
|
webhookUrl: string;
|
||||||
username: string;
|
username: string;
|
||||||
|
icon: string;
|
||||||
notificationTemplates: INotificationTemplates[];
|
notificationTemplates: INotificationTemplates[];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,8 +25,17 @@
|
||||||
<input matInput formControlName="username">
|
<input matInput formControlName="username">
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="md-form-field">
|
||||||
|
<mat-form-field appearance="outline">
|
||||||
|
<mat-label>Icon</mat-label>
|
||||||
|
<input matInput formControlName="icon">
|
||||||
|
</mat-form-field>
|
||||||
|
<div>
|
||||||
|
<img [src]="form.value.icon" style="width: 300px" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row">
|
<div class="row top-space">
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<div>
|
<div>
|
||||||
|
|
|
@ -29,6 +29,7 @@ export class DiscordComponent implements OnInit {
|
||||||
enabled: [x.enabled],
|
enabled: [x.enabled],
|
||||||
username: [x.username],
|
username: [x.username],
|
||||||
webhookUrl: [x.webhookUrl, [Validators.required]],
|
webhookUrl: [x.webhookUrl, [Validators.required]],
|
||||||
|
icon: [x.icon]
|
||||||
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue