#164 has been resolved

This commit is contained in:
tidusjar 2016-05-23 13:28:16 +01:00
commit 5a6863456f
22 changed files with 663 additions and 8 deletions

View file

@ -0,0 +1,37 @@
using System;
using Newtonsoft.Json;
namespace PlexRequests.Core.SettingModels
{
public class SlackNotificationSettings : Settings
{
public bool Enabled { get; set; }
public string WebhookUrl { get; set; }
public string Channel { get; set; }
public string Username { get; set; }
[JsonIgnore]
public string Team => SplitWebUrl(3);
[JsonIgnore]
public string Service => 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];
}
}
}