This commit is contained in:
Jamie.Rees 2017-04-12 08:21:34 +01:00
commit 213e54e02d
33 changed files with 764 additions and 24 deletions

View file

@ -0,0 +1,37 @@
#region Copyright
// /************************************************************************
// Copyright (c) 2016 Jamie Rees
// File: IMattermostApi.cs
// Created By: Michel Zaleski
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// ************************************************************************/
#endregion
using System.Threading.Tasks;
using Ombi.Api.Models.Notifications;
namespace Ombi.Api.Interfaces
{
public interface IMattermostApi
{
Task<string> PushAsync(string webhook, MattermostNotificationBody message);
}
}

View file

@ -65,6 +65,7 @@
<Compile Include="IPushbulletApi.cs" /> <Compile Include="IPushbulletApi.cs" />
<Compile Include="IRadarrApi.cs" /> <Compile Include="IRadarrApi.cs" />
<Compile Include="ISlackApi.cs" /> <Compile Include="ISlackApi.cs" />
<Compile Include="IMattermostApi.cs" />
<Compile Include="IPushoverApi.cs" /> <Compile Include="IPushoverApi.cs" />
<Compile Include="ISickRageApi.cs" /> <Compile Include="ISickRageApi.cs" />
<Compile Include="ISonarrApi.cs" /> <Compile Include="ISonarrApi.cs" />

View file

@ -0,0 +1,45 @@
#region Copyright
// /************************************************************************
// Copyright (c) 2016 Jamie Rees
// File: MattermostNotificationBody.cs
// Created By: Michel Zaleski
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// ************************************************************************/
#endregion
using Newtonsoft.Json;
namespace Ombi.Api.Models.Notifications
{
public class MattermostNotificationBody
{
[JsonConstructor]
public MattermostNotificationBody()
{
username = "Ombi";
}
public string username { get; set; } = "Ombi";
public string channel { get; set; }
public string text { get; set; }
public string icon_url { get; set; }
}
}

View file

@ -96,6 +96,7 @@
<Compile Include="Notifications\PushbulletResponse.cs" /> <Compile Include="Notifications\PushbulletResponse.cs" />
<Compile Include="Notifications\PushoverResponse.cs" /> <Compile Include="Notifications\PushoverResponse.cs" />
<Compile Include="Notifications\SlackNotificationBody.cs" /> <Compile Include="Notifications\SlackNotificationBody.cs" />
<Compile Include="Notifications\MattermostNotificationBody.cs" />
<Compile Include="Plex\PlexAccount.cs" /> <Compile Include="Plex\PlexAccount.cs" />
<Compile Include="Plex\PlexAuthentication.cs" /> <Compile Include="Plex\PlexAuthentication.cs" />
<Compile Include="Plex\PlexEpisodeMetadata.cs" /> <Compile Include="Plex\PlexEpisodeMetadata.cs" />

58
Ombi.Api/MattermostApi.cs Normal file
View file

@ -0,0 +1,58 @@
#region Copyright
// /************************************************************************
// Copyright (c) 2016 Jamie Rees
// File: PlexApi.cs
// Created By: Michel Zaleski
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// ************************************************************************/
#endregion
using System;
using System.Threading.Tasks;
using Ombi.Api.Interfaces;
using Ombi.Api.Models.Notifications;
using RestSharp;
namespace Ombi.Api
{
public class MattermostApi : IMattermostApi
{
public async Task<string> PushAsync(string webhook, MattermostNotificationBody message)
{
var request = new RestRequest
{
Method = Method.POST,
Resource = "/"
};
request.AddJsonBody(message);
var api = new ApiRequest();
return await Task.Run(
() =>
{
var result = api.Execute(request, new Uri(webhook));
return result.Content;
});
}
}
}

View file

@ -85,6 +85,7 @@
<Compile Include="WatcherApi.cs" /> <Compile Include="WatcherApi.cs" />
<Compile Include="MusicBrainzApi.cs" /> <Compile Include="MusicBrainzApi.cs" />
<Compile Include="SlackApi.cs" /> <Compile Include="SlackApi.cs" />
<Compile Include="MattermostApi.cs" />
<Compile Include="PushoverApi.cs" /> <Compile Include="PushoverApi.cs" />
<Compile Include="PushbulletApi.cs" /> <Compile Include="PushbulletApi.cs" />
<Compile Include="SickrageApi.cs" /> <Compile Include="SickrageApi.cs" />

View file

@ -94,7 +94,7 @@ namespace Ombi.Core.Migration.Migrations
content.Add(new RecentlyAddedLog content.Add(new RecentlyAddedLog
{ {
AddedAt = DateTime.UtcNow, AddedAt = DateTime.UtcNow,
ProviderId = ep.ProviderId ProviderId = ep.RatingKey
}); });
} }

View file

@ -0,0 +1,134 @@
#region Copyright
// /************************************************************************
// Copyright (c) 2016 Jamie Rees
// File: Version1100.cs
// Created By: Jamie Rees
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// ************************************************************************/
#endregion
using System;
using System.Data;
using NLog;
using Ombi.Core.SettingModels;
using Ombi.Store;
using Ombi.Store.Models;
using Ombi.Store.Models.Emby;
using Ombi.Store.Models.Plex;
using Ombi.Store.Repository;
using Quartz.Collection;
namespace Ombi.Core.Migration.Migrations
{
[Migration(22100, "v2.21.0.0")]
public class Version2210 : BaseMigration, IMigration
{
public Version2210(IRepository<RecentlyAddedLog> log,
IRepository<PlexContent> content, IRepository<PlexEpisodes> plexEp, IRepository<EmbyContent> embyContent, IRepository<EmbyEpisodes> embyEp)
{
Log = log;
PlexContent = content;
PlexEpisodes = plexEp;
EmbyContent = embyContent;
EmbyEpisodes = embyEp;
}
public int Version => 22100;
private IRepository<RecentlyAddedLog> Log { get; }
private IRepository<PlexContent> PlexContent { get; }
private IRepository<PlexEpisodes> PlexEpisodes { get; }
private IRepository<EmbyContent> EmbyContent { get; }
private IRepository<EmbyEpisodes> EmbyEpisodes { get; }
public void Start(IDbConnection con)
{
UpdateRecentlyAdded(con);
UpdateSchema(con, Version);
}
private void UpdateRecentlyAdded(IDbConnection con)
{
//Delete the recently added table, lets start again
Log.DeleteAll("RecentlyAddedLog");
// Plex
var plexAllContent = PlexContent.GetAll();
var content = new HashSet<RecentlyAddedLog>();
foreach (var plexContent in plexAllContent)
{
if(plexContent.Type == PlexMediaType.Artist) continue;
content.Add(new RecentlyAddedLog
{
AddedAt = DateTime.UtcNow,
ProviderId = plexContent.ProviderId
});
}
Log.BatchInsert(content, "RecentlyAddedLog");
var plexEpisodeses = PlexEpisodes.GetAll();
content.Clear();
foreach (var ep in plexEpisodeses)
{
content.Add(new RecentlyAddedLog
{
AddedAt = DateTime.UtcNow,
ProviderId = ep.RatingKey
});
}
Log.BatchInsert(content, "RecentlyAddedLog");
// Emby
content.Clear();
var embyContent = EmbyContent.GetAll();
foreach (var plexContent in embyContent)
{
content.Add(new RecentlyAddedLog
{
AddedAt = DateTime.UtcNow,
ProviderId = plexContent.EmbyId
});
}
Log.BatchInsert(content, "RecentlyAddedLog");
var embyEpisodes = EmbyEpisodes.GetAll();
content.Clear();
foreach (var ep in embyEpisodes)
{
content.Add(new RecentlyAddedLog
{
AddedAt = DateTime.UtcNow,
ProviderId = ep.EmbyId
});
}
Log.BatchInsert(content, "RecentlyAddedLog");
}
}
}

View file

@ -69,6 +69,7 @@
<Compile Include="MigrationAttribute.cs" /> <Compile Include="MigrationAttribute.cs" />
<Compile Include="MigrationRunner.cs" /> <Compile Include="MigrationRunner.cs" />
<Compile Include="Migrations\BaseMigration.cs" /> <Compile Include="Migrations\BaseMigration.cs" />
<Compile Include="Migrations\Version2210.cs" />
<Compile Include="Migrations\Version2200.cs" /> <Compile Include="Migrations\Version2200.cs" />
<Compile Include="Migrations\Version1100.cs" /> <Compile Include="Migrations\Version1100.cs" />
<Compile Include="Migrations\Version195.cs" /> <Compile Include="Migrations\Version195.cs" />

View file

@ -70,6 +70,9 @@ namespace Ombi.Core.Notification
case TransportType.Slack: case TransportType.Slack:
content = notification.SlackNotification; content = notification.SlackNotification;
break; break;
case TransportType.Mattermost:
content = notification.MattermostNotification;
break;
default: default:
throw new ArgumentOutOfRangeException(nameof(transportType), transportType, null); throw new ArgumentOutOfRangeException(nameof(transportType), transportType, null);
} }

View file

@ -31,6 +31,7 @@ namespace Ombi.Core.Notification
Email, Email,
Pushbullet, Pushbullet,
Pushover, Pushover,
Slack Slack,
Mattermost
} }
} }

View file

@ -138,6 +138,7 @@
<Compile Include="SettingModels\RequestSettings.cs" /> <Compile Include="SettingModels\RequestSettings.cs" />
<Compile Include="SettingModels\ScheduledJobsSettings.cs" /> <Compile Include="SettingModels\ScheduledJobsSettings.cs" />
<Compile Include="SettingModels\SlackNotificationSettings.cs" /> <Compile Include="SettingModels\SlackNotificationSettings.cs" />
<Compile Include="SettingModels\MattermostNotificationSettings.cs" />
<Compile Include="SettingModels\PushoverNotificationSettings.cs" /> <Compile Include="SettingModels\PushoverNotificationSettings.cs" />
<Compile Include="SettingModels\PushBulletNotificationSettings.cs" /> <Compile Include="SettingModels\PushBulletNotificationSettings.cs" />
<Compile Include="SettingModels\EmailNotificationSettings.cs" /> <Compile Include="SettingModels\EmailNotificationSettings.cs" />

View file

@ -0,0 +1,13 @@
using System;
using Newtonsoft.Json;
namespace Ombi.Core.SettingModels
{
public sealed class MattermostNotificationSettings : NotificationSettings
{
public string WebhookUrl { get; set; }
public string Channel { get; set; }
public string Username { get; set; }
public string IconUrl { get; set; }
}
}

View file

@ -51,11 +51,13 @@ namespace Ombi.Core.SettingModels
} }
}; };
SlackNotification = new List<NotificationMessage>(); SlackNotification = new List<NotificationMessage>();
MattermostNotification = new List<NotificationMessage>();
PushoverNotification = new List<NotificationMessage>(); PushoverNotification = new List<NotificationMessage>();
PushbulletNotification = new List<NotificationMessage>(); PushbulletNotification = new List<NotificationMessage>();
} }
public List<NotificationMessage> EmailNotification { get; set; } public List<NotificationMessage> EmailNotification { get; set; }
public List<NotificationMessage> SlackNotification { get; set; } public List<NotificationMessage> SlackNotification { get; set; }
public List<NotificationMessage> MattermostNotification { get; set; }
public List<NotificationMessage> PushbulletNotification { get; set; } public List<NotificationMessage> PushbulletNotification { get; set; }
public List<NotificationMessage> PushoverNotification { get; set; } public List<NotificationMessage> PushoverNotification { get; set; }
} }

View file

@ -276,7 +276,8 @@ namespace Ombi.Services.Jobs
Title = m.Title, Title = m.Title,
Type = Store.Models.Plex.PlexMediaType.Movie, Type = Store.Models.Plex.PlexMediaType.Movie,
Url = m.Url, Url = m.Url,
ItemId = m.ItemId ItemId = m.ItemId,
AddedAt = DateTime.UtcNow,
}); });
} }
} }
@ -318,7 +319,8 @@ namespace Ombi.Services.Jobs
Type = Store.Models.Plex.PlexMediaType.Show, Type = Store.Models.Plex.PlexMediaType.Show,
Url = t.Url, Url = t.Url,
Seasons = ByteConverterHelper.ReturnBytes(t.Seasons), Seasons = ByteConverterHelper.ReturnBytes(t.Seasons),
ItemId = t.ItemId ItemId = t.ItemId,
AddedAt = DateTime.UtcNow,
}); });
} }
} }
@ -360,7 +362,8 @@ namespace Ombi.Services.Jobs
Title = a.Title, Title = a.Title,
Type = Store.Models.Plex.PlexMediaType.Artist, Type = Store.Models.Plex.PlexMediaType.Artist,
Url = a.Url, Url = a.Url,
ItemId = "album" ItemId = "album",
AddedAt = DateTime.UtcNow,
}); });
} }
} }

View file

@ -115,12 +115,12 @@ namespace Ombi.Services.Jobs.RecentlyAddedNewsletter
var firstRun = !recentlyAdded.Any(); var firstRun = !recentlyAdded.Any();
var filteredMovies = movie.Where(m => recentlyAdded.All(x => x.ProviderId != m.ProviderId)).ToList(); var filteredMovies = movie.Where(m => recentlyAdded.All(x => x.ProviderId != m.EmbyId)).ToList();
var filteredEp = episodes.Where(m => recentlyAdded.All(x => x.ProviderId != m.ProviderId)).ToList(); var filteredEp = episodes.Where(m => recentlyAdded.All(x => x.ProviderId != m.EmbyId)).ToList();
var filteredSeries = series.Where(m => recentlyAdded.All(x => x.ProviderId != m.ProviderId)).ToList(); var filteredSeries = series.Where(m => recentlyAdded.All(x => x.ProviderId != m.EmbyId)).ToList();
var info = new List<EmbyRecentlyAddedModel>(); var info = new List<EmbyRecentlyAddedModel>();
foreach (var m in filteredMovies) foreach (var m in filteredMovies.OrderByDescending(x => x.AddedAt))
{ {
var policy = RetryHandler.RetryAndWaitPolicy((exception, timespan) => var policy = RetryHandler.RetryAndWaitPolicy((exception, timespan) =>
Log.Error(exception, "Exception thrown when processing an emby movie for the newsletter, Retrying {0}", timespan)); Log.Error(exception, "Exception thrown when processing an emby movie for the newsletter, Retrying {0}", timespan));
@ -144,6 +144,11 @@ namespace Ombi.Services.Jobs.RecentlyAddedNewsletter
// Check if there are any epiosdes, then get the series info. // Check if there are any epiosdes, then get the series info.
// Otherwise then just add the series to the newsletter // Otherwise then just add the series to the newsletter
if (test && !filteredEp.Any() && episodes.Any())
{
// if this is a test make sure we show something
filteredEp = episodes.Take(5).ToList();
}
if (filteredEp.Any()) if (filteredEp.Any())
{ {
var recentlyAddedModel = new List<EmbyRecentlyAddedModel>(); var recentlyAddedModel = new List<EmbyRecentlyAddedModel>();
@ -205,7 +210,7 @@ namespace Ombi.Services.Jobs.RecentlyAddedNewsletter
} }
else else
{ {
foreach (var t in filteredSeries) foreach (var t in filteredSeries.OrderByDescending(x => x.AddedAt))
{ {
@ -239,7 +244,7 @@ namespace Ombi.Services.Jobs.RecentlyAddedNewsletter
{ {
RecentlyAddedLog.Insert(new RecentlyAddedLog RecentlyAddedLog.Insert(new RecentlyAddedLog
{ {
ProviderId = a.ProviderId, ProviderId = a.EmbyId,
AddedAt = DateTime.UtcNow AddedAt = DateTime.UtcNow
}); });
} }
@ -247,7 +252,7 @@ namespace Ombi.Services.Jobs.RecentlyAddedNewsletter
{ {
RecentlyAddedLog.Insert(new RecentlyAddedLog RecentlyAddedLog.Insert(new RecentlyAddedLog
{ {
ProviderId = a.ProviderId, ProviderId = a.EmbyId,
AddedAt = DateTime.UtcNow AddedAt = DateTime.UtcNow
}); });
} }
@ -255,7 +260,7 @@ namespace Ombi.Services.Jobs.RecentlyAddedNewsletter
{ {
RecentlyAddedLog.Insert(new RecentlyAddedLog RecentlyAddedLog.Insert(new RecentlyAddedLog
{ {
ProviderId = s.ProviderId, ProviderId = s.EmbyId,
AddedAt = DateTime.UtcNow AddedAt = DateTime.UtcNow
}); });
} }

View file

@ -117,7 +117,7 @@ namespace Ombi.Services.Jobs.RecentlyAddedNewsletter
var firstRun = !recentlyAdded.Any(); var firstRun = !recentlyAdded.Any();
var filteredMovies = movie.Where(m => recentlyAdded.All(x => x.ProviderId != m.ProviderId)).ToList(); var filteredMovies = movie.Where(m => recentlyAdded.All(x => x.ProviderId != m.ProviderId)).ToList();
var filteredEp = episodes.Where(m => recentlyAdded.All(x => x.ProviderId != m.ProviderId)).ToList(); var filteredEp = episodes.Where(m => recentlyAdded.All(x => x.ProviderId != m.RatingKey)).ToList();
var filteredSeries = series.Where(x => recentlyAdded.All(c => c.ProviderId != x.ProviderId)).ToList(); var filteredSeries = series.Where(x => recentlyAdded.All(c => c.ProviderId != x.ProviderId)).ToList();
var info = new List<PlexRecentlyAddedModel>(); var info = new List<PlexRecentlyAddedModel>();
@ -127,7 +127,7 @@ namespace Ombi.Services.Jobs.RecentlyAddedNewsletter
// if this is a test make sure we show something // if this is a test make sure we show something
filteredMovies = movie.Take(5).ToList(); filteredMovies = movie.Take(5).ToList();
} }
foreach (var m in filteredMovies) foreach (var m in filteredMovies.OrderByDescending(x => x.AddedAt))
{ {
var i = Api.GetMetadata(plexSettings.PlexAuthToken, plexSettings.FullUri, m.ItemId); var i = Api.GetMetadata(plexSettings.PlexAuthToken, plexSettings.FullUri, m.ItemId);
if (i.Video == null) if (i.Video == null)
@ -144,6 +144,11 @@ namespace Ombi.Services.Jobs.RecentlyAddedNewsletter
newsletter.MovieCount = info.Count; newsletter.MovieCount = info.Count;
info.Clear(); info.Clear();
if (test && !filteredEp.Any() && episodes.Any())
{
// if this is a test make sure we show something
filteredEp = episodes.Take(5).ToList();
}
if (filteredEp.Any()) if (filteredEp.Any())
{ {
var recentlyAddedModel = new List<PlexRecentlyAddedModel>(); var recentlyAddedModel = new List<PlexRecentlyAddedModel>();
@ -189,7 +194,7 @@ namespace Ombi.Services.Jobs.RecentlyAddedNewsletter
// if this is a test make sure we show something // if this is a test make sure we show something
filteredSeries = series.Take(5).ToList(); filteredSeries = series.Take(5).ToList();
} }
foreach (var t in filteredSeries) foreach (var t in filteredSeries.OrderByDescending(x => x.AddedAt))
{ {
var i = Api.GetMetadata(plexSettings.PlexAuthToken, plexSettings.FullUri, t.ItemId); var i = Api.GetMetadata(plexSettings.PlexAuthToken, plexSettings.FullUri, t.ItemId);
if (i.Directory == null) if (i.Directory == null)
@ -226,7 +231,7 @@ namespace Ombi.Services.Jobs.RecentlyAddedNewsletter
{ {
RecentlyAddedLog.Insert(new RecentlyAddedLog RecentlyAddedLog.Insert(new RecentlyAddedLog
{ {
ProviderId = a.ProviderId, ProviderId = a.RatingKey,
AddedAt = DateTime.UtcNow AddedAt = DateTime.UtcNow
}); });
} }
@ -335,7 +340,7 @@ namespace Ombi.Services.Jobs.RecentlyAddedNewsletter
try try
{ {
var info = TvApi.ShowLookupByTheTvDbId(int.Parse(PlexHelper.GetProviderIdFromPlexGuid(t.Metadata.Directory.Guid))); var info = TvApi.ShowLookupByTheTvDbId(int.Parse(PlexHelper.GetProviderIdFromPlexGuid(t?.Metadata?.Directory?.Guid ?? string.Empty)));
var banner = info.image?.original; var banner = info.image?.original;
if (!string.IsNullOrEmpty(banner)) if (!string.IsNullOrEmpty(banner))
@ -370,7 +375,7 @@ namespace Ombi.Services.Jobs.RecentlyAddedNewsletter
for (var i = 0; i < orderedEpisodes.Count; i++) for (var i = 0; i < orderedEpisodes.Count; i++)
{ {
var ep = orderedEpisodes[i]; var ep = orderedEpisodes[i];
if (i <= orderedEpisodes.Count - 1) if (i < orderedEpisodes.Count - 1)
{ {
epSb.Append($"{ep.Video.FirstOrDefault().Index},"); epSb.Append($"{ep.Video.FirstOrDefault().Index},");
} }

View file

@ -0,0 +1,156 @@
#region Copyright
// /************************************************************************
// Copyright (c) 2016 Jamie Rees
// File: MattermostNotification.cs
// Created By: Michel Zaleski
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// ************************************************************************/
#endregion
using System;
using System.Threading.Tasks;
using NLog;
using Ombi.Api.Interfaces;
using Ombi.Api.Models.Notifications;
using Ombi.Core;
using Ombi.Core.Models;
using Ombi.Core.SettingModels;
using Ombi.Services.Interfaces;
namespace Ombi.Services.Notification
{
public class MattermostNotification : INotification
{
public MattermostNotification(IMattermostApi api, ISettingsService<MattermostNotificationSettings> sn)
{
Api = api;
Settings = sn;
}
public string NotificationName => "MattermostNotification";
private IMattermostApi Api { get; }
private ISettingsService<MattermostNotificationSettings> Settings { get; }
private static Logger Log = LogManager.GetCurrentClassLogger();
public async Task NotifyAsync(NotificationModel model)
{
var settings = Settings.GetSettings();
await NotifyAsync(model, settings);
}
public async Task NotifyAsync(NotificationModel model, Settings settings)
{
if (settings == null) await NotifyAsync(model);
var pushSettings = (MattermostNotificationSettings)settings;
if (!ValidateConfiguration(pushSettings))
{
Log.Error("Settings for Mattermost was not correct, we cannot push a notification");
return;
}
switch (model.NotificationType)
{
case NotificationType.NewRequest:
await PushNewRequestAsync(model, pushSettings);
break;
case NotificationType.Issue:
await PushIssueAsync(model, pushSettings);
break;
case NotificationType.RequestAvailable:
break;
case NotificationType.RequestApproved:
break;
case NotificationType.AdminNote:
break;
case NotificationType.Test:
await PushTest(pushSettings);
break;
case NotificationType.RequestDeclined:
break;
case NotificationType.ItemAddedToFaultQueue:
await PushFaultQueue(model, pushSettings);
break;
default:
throw new ArgumentOutOfRangeException();
}
}
private async Task PushNewRequestAsync(NotificationModel model, MattermostNotificationSettings settings)
{
var message = $"{model.Title} has been requested by user: {model.User}";
await Push(settings, message);
}
private async Task PushIssueAsync(NotificationModel model, MattermostNotificationSettings settings)
{
var message = $"A new issue: {model.Body} has been reported by user: {model.User} for the title: {model.Title}";
await Push(settings, message);
}
private async Task PushTest(MattermostNotificationSettings 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);
}
private async Task PushFaultQueue(NotificationModel model, MattermostNotificationSettings 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);
}
private async Task Push(MattermostNotificationSettings config, string message)
{
try
{
var notification = new MattermostNotificationBody { username = config.Username, channel = config.Channel ?? string.Empty, icon_url = config.IconUrl ?? string.Empty, text = message };
var result = await Api.PushAsync(config.WebhookUrl, notification);
if (!result.Equals("ok"))
{
Log.Error("Mattermost returned a message that was not 'ok', the notification did not get pushed");
Log.Error($"Message that mattermost returned: {result}");
}
}
catch (Exception e)
{
Log.Error(e);
}
}
private bool ValidateConfiguration(MattermostNotificationSettings settings)
{
if (!settings.Enabled)
{
return false;
}
if (string.IsNullOrEmpty(settings.WebhookUrl))
{
return false;
}
return true;
}
}
}

View file

@ -157,6 +157,7 @@
<Compile Include="Notification\PushbulletNotification.cs" /> <Compile Include="Notification\PushbulletNotification.cs" />
<Compile Include="Notification\DiscordNotification.cs" /> <Compile Include="Notification\DiscordNotification.cs" />
<Compile Include="Notification\SlackNotification.cs" /> <Compile Include="Notification\SlackNotification.cs" />
<Compile Include="Notification\MattermostNotification.cs" />
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

View file

@ -34,6 +34,9 @@ namespace Ombi.Store.Models
[Table("RecentlyAddedLog")] [Table("RecentlyAddedLog")]
public class RecentlyAddedLog : Entity public class RecentlyAddedLog : Entity
{ {
/// <summary>
/// This is actually a unique id for that content...
/// </summary>
public string ProviderId { get; set; } public string ProviderId { get; set; }
public DateTime AddedAt { get; set; } public DateTime AddedAt { get; set; }
} }

View file

@ -68,7 +68,7 @@
<Compile Include="Models\Emby\EmbyContent.cs" /> <Compile Include="Models\Emby\EmbyContent.cs" />
<Compile Include="Models\Emby\EmbyEpisodes.cs" /> <Compile Include="Models\Emby\EmbyEpisodes.cs" />
<Compile Include="Models\IssueBlobs.cs" /> <Compile Include="Models\IssueBlobs.cs" />
<Compile Include="Models\RecenetlyAddedLog.cs" /> <Compile Include="Models\RecentlyAddedLog.cs" />
<Compile Include="Models\Plex\PlexEpisodes.cs" /> <Compile Include="Models\Plex\PlexEpisodes.cs" />
<Compile Include="Models\Emby\EmbyUsers.cs" /> <Compile Include="Models\Emby\EmbyUsers.cs" />
<Compile Include="Models\Plex\PlexUsers.cs" /> <Compile Include="Models\Plex\PlexUsers.cs" />

View file

@ -73,8 +73,10 @@ namespace Ombi.UI.Tests
private Mock<ICacheProvider> Cache { get; set; } private Mock<ICacheProvider> Cache { get; set; }
private Mock<ISettingsService<LogSettings>> Log { get; set; } private Mock<ISettingsService<LogSettings>> Log { get; set; }
private Mock<ISettingsService<SlackNotificationSettings>> SlackSettings { get; set; } private Mock<ISettingsService<SlackNotificationSettings>> SlackSettings { get; set; }
private Mock<ISettingsService<MattermostNotificationSettings>> MattermostSettings { get; set; }
private Mock<ISettingsService<LandingPageSettings>> LandingPageSettings { get; set; } private Mock<ISettingsService<LandingPageSettings>> LandingPageSettings { get; set; }
private Mock<ISlackApi> SlackApi { get; set; } private Mock<ISlackApi> SlackApi { get; set; }
private Mock<IMattermostApi> MattermostApi { get; set; }
private Mock<IAnalytics> Analytics { get; set; } private Mock<IAnalytics> Analytics { get; set; }
private Mock<ISettingsService<NotificationSettingsV2>> NotifyV2 { get; set; } private Mock<ISettingsService<NotificationSettingsV2>> NotifyV2 { get; set; }
private Mock<IRecentlyAdded> RecentlyAdded { get; set; } private Mock<IRecentlyAdded> RecentlyAdded { get; set; }
@ -114,6 +116,8 @@ namespace Ombi.UI.Tests
Log = new Mock<ISettingsService<LogSettings>>(); Log = new Mock<ISettingsService<LogSettings>>();
SlackApi = new Mock<ISlackApi>(); SlackApi = new Mock<ISlackApi>();
SlackSettings = new Mock<ISettingsService<SlackNotificationSettings>>(); SlackSettings = new Mock<ISettingsService<SlackNotificationSettings>>();
MattermostApi = new Mock<IMattermostApi>();
MattermostSettings = new Mock<ISettingsService<MattermostNotificationSettings>>();
LandingPageSettings = new Mock<ISettingsService<LandingPageSettings>>(); LandingPageSettings = new Mock<ISettingsService<LandingPageSettings>>();
ScheduledJobsSettingsMock = new Mock<ISettingsService<ScheduledJobsSettings>>(); ScheduledJobsSettingsMock = new Mock<ISettingsService<ScheduledJobsSettings>>();
RecorderMock = new Mock<IJobRecord>(); RecorderMock = new Mock<IJobRecord>();
@ -147,8 +151,10 @@ namespace Ombi.UI.Tests
with.Dependency(Cache.Object); with.Dependency(Cache.Object);
with.Dependency(Log.Object); with.Dependency(Log.Object);
with.Dependency(SlackApi.Object); with.Dependency(SlackApi.Object);
with.Dependency(MattermostApi.Object);
with.Dependency(LandingPageSettings.Object); with.Dependency(LandingPageSettings.Object);
with.Dependency(SlackSettings.Object); with.Dependency(SlackSettings.Object);
with.Dependency(MattermostSettings.Object);
with.Dependency(ScheduledJobsSettingsMock.Object); with.Dependency(ScheduledJobsSettingsMock.Object);
with.Dependency(RecorderMock.Object); with.Dependency(RecorderMock.Object);
with.Dependency(RecentlyAdded.Object); with.Dependency(RecentlyAdded.Object);

View file

@ -87,9 +87,11 @@ namespace Ombi.UI.Modules.Admin
private INotificationService NotificationService { get; } private INotificationService NotificationService { get; }
private ICacheProvider Cache { get; } private ICacheProvider Cache { get; }
private ISettingsService<SlackNotificationSettings> SlackSettings { get; } private ISettingsService<SlackNotificationSettings> SlackSettings { get; }
private ISettingsService<MattermostNotificationSettings> MattermostSettings { get; }
private ISettingsService<LandingPageSettings> LandingSettings { get; } private ISettingsService<LandingPageSettings> LandingSettings { get; }
private ISettingsService<ScheduledJobsSettings> ScheduledJobSettings { get; } private ISettingsService<ScheduledJobsSettings> ScheduledJobSettings { get; }
private ISlackApi SlackApi { get; } private ISlackApi SlackApi { get; }
private IMattermostApi MattermostApi { get; }
private IJobRecord JobRecorder { get; } private IJobRecord JobRecorder { get; }
private IAnalytics Analytics { get; } private IAnalytics Analytics { get; }
private IRecentlyAdded RecentlyAdded { get; } private IRecentlyAdded RecentlyAdded { get; }
@ -123,7 +125,8 @@ namespace Ombi.UI.Modules.Admin
ISettingsService<HeadphonesSettings> headphones, ISettingsService<HeadphonesSettings> headphones,
ISettingsService<LogSettings> logs, ISettingsService<LogSettings> logs,
ICacheProvider cache, ISettingsService<SlackNotificationSettings> slackSettings, ICacheProvider cache, ISettingsService<SlackNotificationSettings> slackSettings,
ISlackApi slackApi, ISettingsService<LandingPageSettings> lp, ISlackApi slackApi, ISettingsService<MattermostNotificationSettings> mattermostSettings,
IMattermostApi mattermostApi, ISettingsService<LandingPageSettings> lp,
ISettingsService<ScheduledJobsSettings> scheduler, IJobRecord rec, IAnalytics analytics, ISettingsService<ScheduledJobsSettings> scheduler, IJobRecord rec, IAnalytics analytics,
ISettingsService<NotificationSettingsV2> notifyService, IRecentlyAdded recentlyAdded, IMassEmail massEmail, ISettingsService<NotificationSettingsV2> notifyService, IRecentlyAdded recentlyAdded, IMassEmail massEmail,
ISettingsService<WatcherSettings> watcherSettings, ISettingsService<WatcherSettings> watcherSettings,
@ -154,6 +157,8 @@ namespace Ombi.UI.Modules.Admin
Cache = cache; Cache = cache;
SlackSettings = slackSettings; SlackSettings = slackSettings;
SlackApi = slackApi; SlackApi = slackApi;
MattermostSettings = mattermostSettings;
MattermostApi = mattermostApi;
LandingSettings = lp; LandingSettings = lp;
ScheduledJobSettings = scheduler; ScheduledJobSettings = scheduler;
JobRecorder = rec; JobRecorder = rec;
@ -239,6 +244,10 @@ namespace Ombi.UI.Modules.Admin
Get["/slacknotification"] = _ => SlackNotifications(); Get["/slacknotification"] = _ => SlackNotifications();
Post["/slacknotification"] = _ => SaveSlackNotifications(); Post["/slacknotification"] = _ => SaveSlackNotifications();
Post["/testmattermostnotification", true] = async (x, ct) => await TestMattermostNotification();
Get["/mattermostnotification"] = _ => MattermostNotifications();
Post["/mattermostnotification"] = _ => SaveMattermostNotifications();
Post["/testdiscordnotification", true] = async (x, ct) => await TestDiscordNotification(); Post["/testdiscordnotification", true] = async (x, ct) => await TestDiscordNotification();
Get["/discordnotification", true] = async (x, ct) => await DiscordNotification(); Get["/discordnotification", true] = async (x, ct) => await DiscordNotification();
Post["/discordnotification", true] = async (x, ct) => await SaveDiscordNotifications(); Post["/discordnotification", true] = async (x, ct) => await SaveDiscordNotifications();
@ -1051,6 +1060,71 @@ namespace Ombi.UI.Modules.Admin
: new JsonResponseModel { Result = false, Message = "Could not update the settings, take a look at the logs." }); : new JsonResponseModel { Result = false, Message = "Could not update the settings, take a look at the logs." });
} }
private async Task<Response> TestMattermostNotification()
{
var settings = this.BindAndValidate<MattermostNotificationSettings>();
if (!ModelValidationResult.IsValid)
{
return Response.AsJson(ModelValidationResult.SendJsonError());
}
var notificationModel = new NotificationModel
{
NotificationType = NotificationType.Test,
DateTime = DateTime.Now
};
var currentMattermostSettings = await MattermostSettings.GetSettingsAsync();
try
{
NotificationService.Subscribe(new MattermostNotification(MattermostApi, MattermostSettings));
settings.Enabled = true;
await NotificationService.Publish(notificationModel, settings);
Log.Info("Sent mattermost notification test");
}
catch (Exception e)
{
Log.Error(e, "Failed to subscribe and publish test Mattermost Notification");
}
finally
{
if (!currentMattermostSettings.Enabled)
{
NotificationService.UnSubscribe(new MattermostNotification(MattermostApi, MattermostSettings));
}
}
return Response.AsJson(new JsonResponseModel { Result = true, Message = "Successfully sent a test Mattermost Notification! If you do not receive it please check the logs." });
}
private Negotiator MattermostNotifications()
{
var settings = MattermostSettings.GetSettings();
return View["MattermostNotifications", settings];
}
private Response SaveMattermostNotifications()
{
var settings = this.BindAndValidate<MattermostNotificationSettings>();
if (!ModelValidationResult.IsValid)
{
return Response.AsJson(ModelValidationResult.SendJsonError());
}
var result = MattermostSettings.SaveSettings(settings);
if (settings.Enabled)
{
NotificationService.Subscribe(new MattermostNotification(MattermostApi, MattermostSettings));
}
else
{
NotificationService.UnSubscribe(new MattermostNotification(MattermostApi, MattermostSettings));
}
Log.Info("Saved mattermost settings, result: {0}", result);
return Response.AsJson(result
? new JsonResponseModel { Result = true, Message = "Successfully Updated the Settings for Mattermost Notifications!" }
: new JsonResponseModel { Result = false, Message = "Could not update the settings, take a look at the logs." });
}
private async Task<Negotiator> DiscordNotification() private async Task<Negotiator> DiscordNotification()
{ {
var settings = await DiscordSettings.GetSettingsAsync(); var settings = await DiscordSettings.GetSettingsAsync();

View file

@ -44,6 +44,7 @@ namespace Ombi.UI.NinjectModules
Bind<IMusicBrainzApi>().To<MusicBrainzApi>(); Bind<IMusicBrainzApi>().To<MusicBrainzApi>();
Bind<IHeadphonesApi>().To<HeadphonesApi>(); Bind<IHeadphonesApi>().To<HeadphonesApi>();
Bind<ISlackApi>().To<SlackApi>(); Bind<ISlackApi>().To<SlackApi>();
Bind<IMattermostApi>().To<MattermostApi>();
Bind<IApiRequest>().To<ApiRequest>(); Bind<IApiRequest>().To<ApiRequest>();
Bind<IWatcherApi>().To<WatcherApi>(); Bind<IWatcherApi>().To<WatcherApi>();
Bind<INetflixApi>().To<NetflixRouletteApi>(); Bind<INetflixApi>().To<NetflixRouletteApi>();

View file

@ -299,6 +299,7 @@
<Compile Include="Validators\RadarrValidator.cs" /> <Compile Include="Validators\RadarrValidator.cs" />
<Compile Include="Validators\WatcherValidator.cs" /> <Compile Include="Validators\WatcherValidator.cs" />
<Compile Include="Validators\SlackSettingsValidator.cs" /> <Compile Include="Validators\SlackSettingsValidator.cs" />
<Compile Include="Validators\MattermostSettingsValidator.cs" />
<Compile Include="Validators\UserViewModelValidator.cs" /> <Compile Include="Validators\UserViewModelValidator.cs" />
<Compile Include="Validators\HeadphonesValidator.cs" /> <Compile Include="Validators\HeadphonesValidator.cs" />
<Compile Include="Validators\PushoverSettingsValidator.cs" /> <Compile Include="Validators\PushoverSettingsValidator.cs" />
@ -834,6 +835,9 @@
<Content Include="Views\Admin\SlackNotifications.cshtml"> <Content Include="Views\Admin\SlackNotifications.cshtml">
<CopyToOutputDirectory>Always</CopyToOutputDirectory> <CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content> </Content>
<Content Include="Views\Admin\MattermostNotifications.cshtml">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="Views\Issues\Index.cshtml"> <Content Include="Views\Issues\Index.cshtml">
<CopyToOutputDirectory>Always</CopyToOutputDirectory> <CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content> </Content>

View file

@ -127,6 +127,10 @@ namespace Ombi.UI
var slackSettings = slackService.GetSettings(); var slackSettings = slackService.GetSettings();
SubScribeOvserver(slackSettings, notificationService, new SlackNotification(container.Get<ISlackApi>(), slackService)); SubScribeOvserver(slackSettings, notificationService, new SlackNotification(container.Get<ISlackApi>(), slackService));
var mattermostService = container.Get<ISettingsService<MattermostNotificationSettings>>();
var mattermostSettings = mattermostService.GetSettings();
SubScribeOvserver(mattermostSettings, notificationService, new MattermostNotification(container.Get<IMattermostApi>(), mattermostService));
var discordSettings = container.Get<ISettingsService<DiscordNotificationSettings>>(); var discordSettings = container.Get<ISettingsService<DiscordNotificationSettings>>();
var discordService = discordSettings.GetSettings(); var discordService = discordSettings.GetSettings();
SubScribeOvserver(discordService, notificationService, new DiscordNotification(container.Get<IDiscordApi>(), discordSettings)); SubScribeOvserver(discordService, notificationService, new DiscordNotification(container.Get<IDiscordApi>(), discordSettings));

View file

@ -0,0 +1,40 @@
#region Copyright
// /************************************************************************
// Copyright (c) 2016 Jamie Rees
// File: MattermostSettingsValidator.cs
// Created By: Michel Zaleski
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// ************************************************************************/
#endregion
using FluentValidation;
using Ombi.Core.SettingModels;
namespace Ombi.UI.Validators
{
public class MattermostSettingsValidator : AbstractValidator<MattermostNotificationSettings>
{
public MattermostSettingsValidator()
{
RuleFor(request => request.WebhookUrl).NotEmpty().WithMessage("You must specify a Webhook Url");
}
}
}

View file

@ -78,6 +78,14 @@
<a href="https://github.com/tidusjar/Ombi" target="_blank">https://github.com/tidusjar/Ombi</a> <a href="https://github.com/tidusjar/Ombi" target="_blank">https://github.com/tidusjar/Ombi</a>
</td> </td>
</tr> </tr>
<tr>
<td>
Forums
</td>
<td>
<a href="https://forums.ombi.io/" target="_blank">https://forums.ombi.io/</a>
</td>
</tr>
<tr> <tr>
<td> <td>
Wiki Wiki

View file

@ -0,0 +1,127 @@
@using Ombi.UI.Helpers
@Html.Partial("Shared/Partial/_Sidebar")
<div class="col-sm-8 col-sm-push-1">
<form class="form-horizontal" method="POST" id="mainForm">
<fieldset>
<legend>Mattermost Notifications</legend>
<div class="form-group">
<div class="checkbox">
@if (Model.Enabled)
{
<input type="checkbox" id="Enabled" name="Enabled" checked="checked"><label for="Enabled">Enabled</label>
}
else
{
<input type="checkbox" id="Enabled" name="Enabled"><label for="Enabled">Enabled</label>
}
</div>
</div>
<div class="form-group">
<label for="WebhookUrl" class="control-label">Incoming Webhook Url</label>
<small class="control-label">This is the full webhook url.</small>
<small class="control-label"> Mattermost > Integrations > Incoming Webhook > Add Incoming Webhook. You will then have a Webhook Url</small>
<div class="">
<input type="text" class="form-control form-control-custom " id="WebhookUrl" name="WebhookUrl" value="@Model.WebhookUrl">
</div>
</div>
<div class="form-group">
<label for="Channel" class="control-label">Channel Override</label>
<small class="control-label">You can override the default channel here</small>
<div class="">
<input type="text" class="form-control form-control-custom " id="Channel" name="Channel" value="@Model.Channel">
</div>
</div>
<div class="form-group">
<label for="Username" class="control-label">Username Override</label>
<small class="control-label">You can override the default username (Ombi) here</small>
<div class="">
<input type="text" class="form-control form-control-custom " id="Username" name="Username" value="@Model.Username">
</div>
</div>
<div class="form-group">
<label for="IconUrl" class="control-label">Icon Override</label>
<small class="control-label">You can override the default icon here</small>
<div class="">
<input type="text" class="form-control form-control-custom " id="IconUrl" name="IconUrl" value="@Model.IconUrl">
</div>
</div>
<div class="form-group">
<div>
<button id="testMattermost" type="submit" class="btn btn-primary-outline">Test <div id="spinner"></div></button>
</div>
</div>
<div class="form-group">
<div>
<button id="save" type="submit" class="btn btn-primary-outline">Submit</button>
</div>
</div>
</fieldset>
</form>
</div>
<script>
$(function () {
var base = '@Html.GetBaseUrl()';
$('#save').click(function (e) {
e.preventDefault();
$('#spinner').attr("class", "fa fa-spinner fa-spin");
var $form = $("#mainForm");
$.ajax({
type: $form.prop("method"),
data: $form.serialize(),
url: $form.prop("action"),
dataType: "json",
success: function (response) {
if (response.result === true) {
generateNotify(response.message, "success");
$('#spinner').attr("class", "fa fa-check");
} else {
generateNotify(response.message, "warning");
$('#spinner').attr("class", "fa fa-times");
}
},
error: function (e) {
console.log(e);
generateNotify("Something went wrong!", "danger");
$('#spinner').attr("class", "fa fa-times");
}
});
});
$('#testMattermost').click(function (e) {
e.preventDefault();
var url = createBaseUrl(base, '/admin/testMattermostnotification');
var $form = $("#mainForm");
$.ajax({
type: $form.prop("method"),
data: $form.serialize(),
url: url,
dataType: "json",
success: function (response) {
if (response.result === true) {
generateNotify(response.message, "success");
} else {
generateNotify(response.message, "warning");
}
},
error: function (e) {
console.log(e);
generateNotify("Something went wrong!", "danger");
}
});
});
});
</script>

View file

@ -33,7 +33,7 @@
<div class="form-group"> <div class="form-group">
<div> <div>
<button id="recentlyAddedBtn" class="btn btn-primary-outline">Send test email to Admin @Html.ToolTip("Note: nothing will send if there is no new content...") <button id="recentlyAddedBtn" class="btn btn-primary-outline">Send test email to Admin @Html.ToolTip("Note: If there is nothing new when testing this, we will just grab some random titles. If there are new items, then we will show those new items. Testing will not mark the content as 'Previously Sent'")
<div id="testEmailSpinner"></div></button> <div id="testEmailSpinner"></div></button>
</div> </div>
</div> </div>

View file

@ -33,6 +33,7 @@
@Html.GetSidebarUrl(Context, "/admin/pushbulletnotification", "Pushbullet Notifications","fa fa-bell-o") @Html.GetSidebarUrl(Context, "/admin/pushbulletnotification", "Pushbullet Notifications","fa fa-bell-o")
@Html.GetSidebarUrl(Context, "/admin/pushovernotification", "Pushover Notifications", "fa fa-bell-o") @Html.GetSidebarUrl(Context, "/admin/pushovernotification", "Pushover Notifications", "fa fa-bell-o")
@Html.GetSidebarUrl(Context, "/admin/slacknotification", "Slack Notifications", "fa fa-slack") @Html.GetSidebarUrl(Context, "/admin/slacknotification", "Slack Notifications", "fa fa-slack")
@Html.GetSidebarUrl(Context, "/admin/mattermostnotification", "Mattermost Notifications", "fa fa-bell-o")
@Html.GetSidebarUrl(Context, "/admin/discordnotification", "Discord Notifications", "fa fa-bell-o") @Html.GetSidebarUrl(Context, "/admin/discordnotification", "Discord Notifications", "fa fa-bell-o")
</div> </div>

View file

@ -12,6 +12,10 @@ ____
|----------|:---------------------------:|:----------------------------:|:----------------------------:| |----------|:---------------------------:|:----------------------------:|:----------------------------:|
| AppVeyor | [![Build status](https://ci.appveyor.com/api/projects/status/hgj8j6lcea7j0yhn/branch/master?svg=true)](https://ci.appveyor.com/project/tidusjar/requestplex/branch/master) | [![Build status](https://ci.appveyor.com/api/projects/status/hgj8j6lcea7j0yhn/branch/eap?svg=true)](https://ci.appveyor.com/project/tidusjar/requestplex/branch/eap) | [![Build status](https://ci.appveyor.com/api/projects/status/hgj8j6lcea7j0yhn/branch/dev?svg=true)](https://ci.appveyor.com/project/tidusjar/requestplex/branch/dev) | AppVeyor | [![Build status](https://ci.appveyor.com/api/projects/status/hgj8j6lcea7j0yhn/branch/master?svg=true)](https://ci.appveyor.com/project/tidusjar/requestplex/branch/master) | [![Build status](https://ci.appveyor.com/api/projects/status/hgj8j6lcea7j0yhn/branch/eap?svg=true)](https://ci.appveyor.com/project/tidusjar/requestplex/branch/eap) | [![Build status](https://ci.appveyor.com/api/projects/status/hgj8j6lcea7j0yhn/branch/dev?svg=true)](https://ci.appveyor.com/project/tidusjar/requestplex/branch/dev)
| Download |[![Download](http://i.imgur.com/odToka3.png)](https://github.com/tidusjar/Ombi/releases) | [![Download](http://i.imgur.com/odToka3.png)](https://ci.appveyor.com/project/tidusjar/requestplex/branch/eap/artifacts) | [![Download](http://i.imgur.com/odToka3.png)](https://ci.appveyor.com/project/tidusjar/requestplex/branch/dev/artifacts) | | Download |[![Download](http://i.imgur.com/odToka3.png)](https://github.com/tidusjar/Ombi/releases) | [![Download](http://i.imgur.com/odToka3.png)](https://ci.appveyor.com/project/tidusjar/requestplex/branch/eap/artifacts) | [![Download](http://i.imgur.com/odToka3.png)](https://ci.appveyor.com/project/tidusjar/requestplex/branch/dev/artifacts) |
We now have a forums!
Check it out: [https://forums.ombi.io/](https://forums.ombi.io)
# Features # Features
Here some of the features Ombi has: Here some of the features Ombi has:
* All your users to Request Movies, TV Shows (Whole series, whole seaons or even single episodes!) and Albums * All your users to Request Movies, TV Shows (Whole series, whole seaons or even single episodes!) and Albums

View file

@ -3,9 +3,9 @@ configuration: Release
assembly_info: assembly_info:
patch: true patch: true
file: '**\AssemblyInfo.*' file: '**\AssemblyInfo.*'
assembly_version: '2.2.0' assembly_version: '2.2.1'
assembly_file_version: '{version}' assembly_file_version: '{version}'
assembly_informational_version: '2.2.0' assembly_informational_version: '2.2.1'
before_build: before_build:
- cmd: appveyor-retry nuget restore - cmd: appveyor-retry nuget restore
build: build: