mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-07-12 16:22:55 -07:00
Fixed telegram !wip
This commit is contained in:
parent
e526c1071a
commit
dca5d13826
6 changed files with 23 additions and 16 deletions
|
@ -1,6 +1,7 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
using System.Net.Http;
|
||||
using System.Security.Authentication;
|
||||
using System.Threading.Tasks;
|
||||
using System.Xml.Serialization;
|
||||
using Microsoft.Extensions.Caching.Memory;
|
||||
|
@ -36,7 +37,7 @@ namespace Ombi.Api
|
|||
{
|
||||
return new HttpClientHandler
|
||||
{
|
||||
ServerCertificateCustomValidationCallback = (message, certificate2, arg3, arg4) => true
|
||||
ServerCertificateCustomValidationCallback = (message, certificate2, arg3, arg4) => true,
|
||||
};
|
||||
}
|
||||
return new HttpClientHandler();
|
||||
|
@ -49,9 +50,9 @@ namespace Ombi.Api
|
|||
|
||||
public async Task<T> Request<T>(Request request)
|
||||
{
|
||||
using (var httpClient = new HttpClient(await GetHandler()))
|
||||
using(var handler = await GetHandler())
|
||||
using (var httpClient = new HttpClient(handler))
|
||||
{
|
||||
|
||||
using (var httpRequestMessage = new HttpRequestMessage(request.HttpMethod, request.FullUri))
|
||||
{
|
||||
// Add the Json Body
|
||||
|
|
|
@ -134,6 +134,7 @@ namespace Ombi.DependencyInjection
|
|||
services.AddTransient<ISlackNotification, SlackNotification>();
|
||||
services.AddTransient<IMattermostNotification, MattermostNotification>();
|
||||
services.AddTransient<IPushoverNotification, PushoverNotification>();
|
||||
services.AddTransient<ITelegramNotification, TelegramNotification>();
|
||||
|
||||
}
|
||||
|
||||
|
|
6
src/Ombi.Notifications/Agents/ITelegramNotification.cs
Normal file
6
src/Ombi.Notifications/Agents/ITelegramNotification.cs
Normal file
|
@ -0,0 +1,6 @@
|
|||
namespace Ombi.Notifications.Agents
|
||||
{
|
||||
public interface ITelegramNotification : INotification
|
||||
{
|
||||
}
|
||||
}
|
|
@ -14,7 +14,7 @@ using Ombi.Api.Telegram;
|
|||
|
||||
namespace Ombi.Notifications.Agents
|
||||
{
|
||||
public class TelegramNotification : BaseNotification<TelegramSettings>
|
||||
public class TelegramNotification : BaseNotification<TelegramSettings>, ITelegramNotification
|
||||
{
|
||||
public TelegramNotification(ITelegramApi api, ISettingsService<TelegramSettings> sn, ILogger<TelegramNotification> log, INotificationTemplatesRepository r, IMovieRequestRepository m, ITvRequestRepository t, ISettingsService<CustomizationSettings> s) : base(sn, r, m, t,s)
|
||||
{
|
||||
|
|
|
@ -51,7 +51,7 @@ namespace Ombi.Controllers.External
|
|||
public TesterController(INotificationService service, IDiscordNotification notification, IEmailNotification emailN,
|
||||
IPushbulletNotification pushbullet, ISlackNotification slack, IPushoverNotification po, IMattermostNotification mm,
|
||||
IPlexApi plex, IEmbyApi emby, IRadarrApi radarr, ISonarrApi sonarr, ILogger<TesterController> log, IEmailProvider provider,
|
||||
ICouchPotatoApi cpApi)
|
||||
ICouchPotatoApi cpApi, ITelegramNotification telegram)
|
||||
{
|
||||
Service = service;
|
||||
DiscordNotification = notification;
|
||||
|
@ -67,6 +67,7 @@ namespace Ombi.Controllers.External
|
|||
Log = log;
|
||||
EmailProvider = provider;
|
||||
CouchPotatoApi = cpApi;
|
||||
TelegramNotification = telegram;
|
||||
}
|
||||
|
||||
private INotificationService Service { get; }
|
||||
|
@ -83,6 +84,7 @@ namespace Ombi.Controllers.External
|
|||
private ICouchPotatoApi CouchPotatoApi { get; }
|
||||
private ILogger<TesterController> Log { get; }
|
||||
private IEmailProvider EmailProvider { get; }
|
||||
private ITelegramNotification TelegramNotification { get; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
|
@ -299,14 +301,14 @@ namespace Ombi.Controllers.External
|
|||
/// </summary>
|
||||
/// <param name="settings">The settings.</param>
|
||||
/// <returns></returns>
|
||||
//[HttpPost("telegram")]
|
||||
//public async Task<bool> Telegram([FromBody] TelegramSettings settings)
|
||||
//{
|
||||
// settings.Enabled = true;
|
||||
// await TelegramApi.Send("This is a test ")
|
||||
[HttpPost("telegram")]
|
||||
public async Task<bool> Telegram([FromBody] TelegramSettings settings)
|
||||
{
|
||||
settings.Enabled = true;
|
||||
await TelegramNotification.NotifyAsync(new NotificationOptions { NotificationType = NotificationType.Test, RequestId = -1 }, settings);
|
||||
|
||||
// return true;
|
||||
//}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -43,14 +43,12 @@ namespace Ombi.Controllers
|
|||
/// <param name="mapper">The mapper.</param>
|
||||
/// <param name="templateRepo">The templateRepo.</param>
|
||||
/// <param name="embyApi">The embyApi.</param>
|
||||
/// <param name="embyCacher">The embyCacher.</param>
|
||||
/// <param name="radarrCacher">The radarrCacher.</param>
|
||||
/// <param name="memCache">The memory cache.</param>
|
||||
public SettingsController(ISettingsResolver resolver,
|
||||
IMapper mapper,
|
||||
INotificationTemplatesRepository templateRepo,
|
||||
IEmbyApi embyApi,
|
||||
IEmbyContentCacher embyCacher,
|
||||
IRadarrCacher radarrCacher,
|
||||
IMemoryCache memCache)
|
||||
{
|
||||
|
@ -58,7 +56,6 @@ namespace Ombi.Controllers
|
|||
Mapper = mapper;
|
||||
TemplateRepository = templateRepo;
|
||||
_embyApi = embyApi;
|
||||
_embyContentCacher = embyCacher;
|
||||
_radarrCacher = radarrCacher;
|
||||
_cache = memCache;
|
||||
}
|
||||
|
@ -67,7 +64,6 @@ namespace Ombi.Controllers
|
|||
private IMapper Mapper { get; }
|
||||
private INotificationTemplatesRepository TemplateRepository { get; }
|
||||
private readonly IEmbyApi _embyApi;
|
||||
private readonly IEmbyContentCacher _embyContentCacher;
|
||||
private readonly IRadarrCacher _radarrCacher;
|
||||
private readonly IMemoryCache _cache;
|
||||
|
||||
|
@ -90,6 +86,7 @@ namespace Ombi.Controllers
|
|||
public async Task<bool> OmbiSettings([FromBody]OmbiSettings ombi)
|
||||
{
|
||||
ombi.Wizard = true;
|
||||
_cache.Remove(CacheKeys.OmbiSettings);
|
||||
return await Save(ombi);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue