mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-07-08 06:00:50 -07:00
31 lines
No EOL
833 B
C#
31 lines
No EOL
833 B
C#
using System;
|
|
using Newtonsoft.Json;
|
|
|
|
namespace Ombi.Core.SettingModels
|
|
{
|
|
public sealed class DiscordNotificationSettings : NotificationSettings
|
|
{
|
|
public string WebhookUrl { get; set; }
|
|
public string Username { get; set; }
|
|
|
|
[JsonIgnore]
|
|
public string WebookId => SplitWebUrl(4);
|
|
|
|
[JsonIgnore]
|
|
public string Token => SplitWebUrl(5);
|
|
|
|
private string SplitWebUrl(int index)
|
|
{
|
|
if (!WebhookUrl.StartsWith("http", StringComparison.InvariantCulture))
|
|
{
|
|
WebhookUrl = "https://" + WebhookUrl;
|
|
}
|
|
var split = WebhookUrl.Split(new[] { '/' }, StringSplitOptions.RemoveEmptyEntries);
|
|
|
|
return split.Length < index
|
|
? string.Empty
|
|
: split[index];
|
|
}
|
|
|
|
}
|
|
} |