Compare commits
No commits in common. "06427d53f37febef21f57ab45fae531cb2695edb" and "5b8f0beb6ecdda9e8a23d9658d36ed0195d46476" have entirely different histories.
06427d53f3
...
5b8f0beb6e
60
Newsbot.Collector.Api/Controllers/ArticlesController.cs
Normal file
60
Newsbot.Collector.Api/Controllers/ArticlesController.cs
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
using Microsoft.AspNetCore.Authentication.JwtBearer;
|
||||||
|
using Microsoft.AspNetCore.Authorization;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using Microsoft.Extensions.Options;
|
||||||
|
using Newsbot.Collector.Domain.Dto;
|
||||||
|
using Newsbot.Collector.Domain.Interfaces;
|
||||||
|
using Newsbot.Collector.Domain.Models;
|
||||||
|
|
||||||
|
namespace Newsbot.Collector.Api.Controllers;
|
||||||
|
|
||||||
|
[ApiController]
|
||||||
|
[Route("api/articles")]
|
||||||
|
[Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme)]
|
||||||
|
public class ArticlesController : ControllerBase
|
||||||
|
{
|
||||||
|
private readonly ILogger<ArticlesController> _logger;
|
||||||
|
private readonly IArticlesRepository _articles;
|
||||||
|
private readonly ISourcesRepository _sources;
|
||||||
|
|
||||||
|
public ArticlesController(ILogger<ArticlesController> logger, IArticlesRepository articles, ISourcesRepository sources)
|
||||||
|
{
|
||||||
|
_logger = logger;
|
||||||
|
_articles = articles;
|
||||||
|
_sources = sources;
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet(Name = "GetArticles")]
|
||||||
|
public IEnumerable<ArticleDto> Get()
|
||||||
|
{
|
||||||
|
var res = new List<ArticleDto>();
|
||||||
|
var items = _articles.List(0, 25);
|
||||||
|
foreach (var item in items) res.Add(ArticleDto.Convert(item));
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet("{id:guid}")]
|
||||||
|
[EndpointDescription("Returns the article based on the Id value given.")]
|
||||||
|
public ArticleDto GetById(Guid id)
|
||||||
|
{
|
||||||
|
var item = _articles.GetById(id);
|
||||||
|
return ArticleDto.Convert(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet("{id:guid}/details")]
|
||||||
|
public ArticleDetailsDto GetDetailsById(Guid id)
|
||||||
|
{
|
||||||
|
var item = _articles.GetById(id);
|
||||||
|
var sourceItem = _sources.GetById(item.SourceId);
|
||||||
|
return ArticleDetailsDto.Convert(item, sourceItem);
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet("by/{sourceId:guid}")]
|
||||||
|
public IEnumerable<ArticleDto> GetBySourceId(Guid sourceId, int page = 0, int count = 25)
|
||||||
|
{
|
||||||
|
var res = new List<ArticleDto>();
|
||||||
|
var items = _articles.ListBySourceId(sourceId, page, count);
|
||||||
|
foreach (var item in items) res.Add(ArticleDto.Convert(item));
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
}
|
@ -7,10 +7,10 @@ using Newsbot.Collector.Api.Domain;
|
|||||||
using Newsbot.Collector.Domain.Models.Config;
|
using Newsbot.Collector.Domain.Models.Config;
|
||||||
using Newsbot.Collector.Services.Jobs;
|
using Newsbot.Collector.Services.Jobs;
|
||||||
|
|
||||||
namespace Newsbot.Collector.Api.Controllers.v1;
|
namespace Newsbot.Collector.Api.Controllers;
|
||||||
|
|
||||||
[ApiController]
|
[ApiController]
|
||||||
[Route("api/v1/codeprojects")]
|
[Route("api/codeprojects")]
|
||||||
[Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme)]
|
[Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme)]
|
||||||
public class CodeProjectController
|
public class CodeProjectController
|
||||||
{
|
{
|
||||||
@ -26,7 +26,7 @@ public class CodeProjectController
|
|||||||
|
|
||||||
[HttpPost("check")]
|
[HttpPost("check")]
|
||||||
[Authorize(Roles = Authorization.AdministratorsRole)]
|
[Authorize(Roles = Authorization.AdministratorsRole)]
|
||||||
public ActionResult PullNow()
|
public void PullNow()
|
||||||
{
|
{
|
||||||
BackgroundJob.Enqueue<CodeProjectWatcherJob>(x => x.InitAndExecute(new CodeProjectWatcherJobOptions
|
BackgroundJob.Enqueue<CodeProjectWatcherJob>(x => x.InitAndExecute(new CodeProjectWatcherJobOptions
|
||||||
{
|
{
|
||||||
@ -34,7 +34,5 @@ public class CodeProjectController
|
|||||||
FeaturePullReleases = true,
|
FeaturePullReleases = true,
|
||||||
FeaturePullCommits = true
|
FeaturePullCommits = true
|
||||||
}));
|
}));
|
||||||
|
|
||||||
return new AcceptedResult();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -0,0 +1,130 @@
|
|||||||
|
using Microsoft.AspNetCore.Authentication.JwtBearer;
|
||||||
|
using Microsoft.AspNetCore.Authorization;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using Newsbot.Collector.Domain.Dto;
|
||||||
|
using Newsbot.Collector.Domain.Entities;
|
||||||
|
using Newsbot.Collector.Domain.Interfaces;
|
||||||
|
|
||||||
|
namespace Newsbot.Collector.Api.Controllers;
|
||||||
|
|
||||||
|
[ApiController]
|
||||||
|
[Route("api/subscriptions")]
|
||||||
|
[Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme)]
|
||||||
|
public class DiscordNotificationController : ControllerBase
|
||||||
|
{
|
||||||
|
private readonly ILogger<DiscordNotificationController> _logger;
|
||||||
|
private readonly IDiscordWebHooksRepository _discord;
|
||||||
|
private readonly ISourcesRepository _sources;
|
||||||
|
private readonly IDiscordNotificationRepository _discordNotification;
|
||||||
|
|
||||||
|
public DiscordNotificationController(ILogger<DiscordNotificationController> logger, IDiscordWebHooksRepository discord, ISourcesRepository sources, IDiscordNotificationRepository discordNotification)
|
||||||
|
{
|
||||||
|
_logger = logger;
|
||||||
|
_discord = discord;
|
||||||
|
_sources = sources;
|
||||||
|
_discordNotification = discordNotification;
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet(Name = "ListSubscriptions")]
|
||||||
|
public IEnumerable<DiscordNotificationDto> List(int page)
|
||||||
|
{
|
||||||
|
var res = new List<DiscordNotificationDto>();
|
||||||
|
var items = _discordNotification.List(page);
|
||||||
|
foreach (var item in items) res.Add(DiscordNotificationDto.Convert(item));
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet("{id}")]
|
||||||
|
public DiscordNotificationDto GetById(Guid id)
|
||||||
|
{
|
||||||
|
return DiscordNotificationDto.Convert(_discordNotification.GetById(id));
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet("{id}/details")]
|
||||||
|
public DiscordNotificationDetailsDto GetDetailsById(Guid id)
|
||||||
|
{
|
||||||
|
var sub = _discordNotification.GetById(id);
|
||||||
|
var webhook = _discord.GetById(sub.DiscordWebHookId);
|
||||||
|
var source = _sources.GetById(sub.SourceId);
|
||||||
|
|
||||||
|
return DiscordNotificationDetailsDto.Convert(sub, source, webhook);
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPost("{id}/delete")]
|
||||||
|
public void DeleteById(Guid id)
|
||||||
|
{
|
||||||
|
_discordNotification.Delete(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet("by/discordId/{id}")]
|
||||||
|
public IEnumerable<DiscordNotificationDto> GetByDiscordId(Guid id)
|
||||||
|
{
|
||||||
|
var res = new List<DiscordNotificationDto>();
|
||||||
|
var items = _discordNotification.ListByWebhook(id);
|
||||||
|
foreach (var item in items) res.Add(DiscordNotificationDto.Convert(item));
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet("by/sourceId/{id}")]
|
||||||
|
public IEnumerable<DiscordNotificationDto> GetBySourceId(Guid id)
|
||||||
|
{
|
||||||
|
var res = new List<DiscordNotificationDto>();
|
||||||
|
var items = _discordNotification.ListBySourceId(id);
|
||||||
|
foreach (var item in items) res.Add(DiscordNotificationDto.Convert(item));
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPost(Name = "New Subscription")]
|
||||||
|
public ActionResult<DiscordNotificationDto> New(Guid sourceId, Guid discordId)
|
||||||
|
{
|
||||||
|
if (sourceId == Guid.Empty) return new BadRequestResult();
|
||||||
|
if (discordId == Guid.Empty) return new BadRequestResult();
|
||||||
|
|
||||||
|
var exists = _discordNotification.GetByWebhookAndSource(discordId, sourceId);
|
||||||
|
if (exists.Id != Guid.Empty) return DiscordNotificationDto.Convert(exists);
|
||||||
|
|
||||||
|
var discord = _discord.GetById(discordId);
|
||||||
|
if (discord.Id == Guid.Empty) return new BadRequestResult();
|
||||||
|
|
||||||
|
var source = _sources.GetById(sourceId);
|
||||||
|
if (source.Id == Guid.Empty) return new BadRequestResult();
|
||||||
|
|
||||||
|
var item = _discordNotification.New(new DiscordNotificationEntity
|
||||||
|
{
|
||||||
|
Id = Guid.NewGuid(),
|
||||||
|
SourceId = sourceId,
|
||||||
|
DiscordWebHookId = discordId,
|
||||||
|
CodeAllowCommits = false,
|
||||||
|
CodeAllowReleases = false
|
||||||
|
});
|
||||||
|
|
||||||
|
return DiscordNotificationDto.Convert(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPost("new/codeproject")]
|
||||||
|
public ActionResult<DiscordNotificationDto> NewCodeProjectSubscription(Guid sourceId, Guid discordId, bool allowReleases,
|
||||||
|
bool allowCommits)
|
||||||
|
{
|
||||||
|
if (sourceId == Guid.Empty) return new BadRequestResult();
|
||||||
|
if (discordId == Guid.Empty) return new BadRequestResult();
|
||||||
|
|
||||||
|
var exists = _discordNotification.GetByWebhookAndSource(discordId, sourceId);
|
||||||
|
if (exists.Id != Guid.Empty) return DiscordNotificationDto.Convert(exists);
|
||||||
|
|
||||||
|
var discord = _discord.GetById(discordId);
|
||||||
|
if (discord.Id == Guid.Empty) return new BadRequestResult();
|
||||||
|
|
||||||
|
var source = _sources.GetById(sourceId);
|
||||||
|
if (source.Id == Guid.Empty) return new BadRequestResult();
|
||||||
|
|
||||||
|
var sub = _discordNotification.New(new DiscordNotificationEntity
|
||||||
|
{
|
||||||
|
DiscordWebHookId = discordId,
|
||||||
|
SourceId = sourceId,
|
||||||
|
CodeAllowCommits = allowCommits,
|
||||||
|
CodeAllowReleases = allowReleases
|
||||||
|
});
|
||||||
|
|
||||||
|
return new DiscordNotificationDto();
|
||||||
|
}
|
||||||
|
}
|
@ -1,19 +1,18 @@
|
|||||||
|
using System.Net;
|
||||||
using Microsoft.AspNetCore.Authentication.JwtBearer;
|
using Microsoft.AspNetCore.Authentication.JwtBearer;
|
||||||
using Microsoft.AspNetCore.Authorization;
|
using Microsoft.AspNetCore.Authorization;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.Extensions.Options;
|
using Microsoft.Extensions.Options;
|
||||||
using Newsbot.Collector.Api.Middleware;
|
using Newsbot.Collector.Database.Repositories;
|
||||||
using Newsbot.Collector.Domain.Dto;
|
using Newsbot.Collector.Domain.Dto;
|
||||||
using Newsbot.Collector.Domain.Entities;
|
using Newsbot.Collector.Domain.Entities;
|
||||||
using Newsbot.Collector.Domain.Interfaces;
|
using Newsbot.Collector.Domain.Interfaces;
|
||||||
using Newsbot.Collector.Domain.Models;
|
using Newsbot.Collector.Domain.Models;
|
||||||
using Newsbot.Collector.Domain.Requests;
|
|
||||||
using Newsbot.Collector.Domain.Results;
|
|
||||||
|
|
||||||
namespace Newsbot.Collector.Api.Controllers.v1;
|
namespace Newsbot.Collector.Api.Controllers;
|
||||||
|
|
||||||
[ApiController]
|
[ApiController]
|
||||||
[Route("api/v1/discord/webhooks")]
|
[Route("api/discord/webhooks")]
|
||||||
[Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme)]
|
[Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme)]
|
||||||
public class DiscordWebHookController : ControllerBase
|
public class DiscordWebHookController : ControllerBase
|
||||||
{
|
{
|
||||||
@ -27,64 +26,43 @@ public class DiscordWebHookController : ControllerBase
|
|||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet(Name = "GetDiscordWebhooks")]
|
[HttpGet(Name = "GetDiscordWebhooks")]
|
||||||
public ActionResult<IEnumerable<DiscordWebHookDto>> Get(int page)
|
public IEnumerable<DiscordWebHookDto> Get(int page)
|
||||||
{
|
{
|
||||||
var userId = HttpContext.GetUserId();
|
|
||||||
if (userId.Equals(string.Empty))
|
|
||||||
{
|
|
||||||
_logger.LogWarning("Unable to find the user ID in the JWD Token");
|
|
||||||
return new BadRequestResult();
|
|
||||||
}
|
|
||||||
|
|
||||||
var items = new List<DiscordWebHookDto>();
|
var items = new List<DiscordWebHookDto>();
|
||||||
var res = _webhooks.ListByUserId(userId, page);
|
var res = _webhooks.List(page);
|
||||||
foreach (var item in res)
|
foreach (var item in res)
|
||||||
{
|
{
|
||||||
items.Add(DiscordWebHookDto.Convert(item));
|
items.Add(DiscordWebHookDto.Convert(item));
|
||||||
}
|
}
|
||||||
|
return items;
|
||||||
return new OkObjectResult(items);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost(Name = "New")]
|
[HttpPost(Name = "New")]
|
||||||
public ActionResult<DiscordWebhookResult> New([FromBody] NewDiscordWebhookRequest request)
|
public DiscordWebHookDto New(string url, string server, string channel)
|
||||||
{
|
{
|
||||||
var userId = HttpContext.GetUserId();
|
var exists = _webhooks.GetByUrl(url);
|
||||||
|
// ReSharper disable once ConditionIsAlwaysTrueOrFalseAccordingToNullableAPIContract
|
||||||
var exists = _webhooks.GetByUrl(request.Url ?? "");
|
|
||||||
if (exists.Id != Guid.Empty)
|
if (exists.Id != Guid.Empty)
|
||||||
{
|
{
|
||||||
return new BadRequestObjectResult(new DiscordWebhookResult
|
return DiscordWebHookDto.Convert(exists);
|
||||||
{
|
|
||||||
IsSuccessful = true,
|
|
||||||
Items = new List<DiscordWebHookDto> { DiscordWebHookDto.Convert(exists) }
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var res = _webhooks.New(new DiscordWebhookEntity
|
var res = _webhooks.New(new DiscordWebhookEntity
|
||||||
{
|
{
|
||||||
UserId = userId,
|
Url = url,
|
||||||
Url = request.Url ?? "",
|
Server = server,
|
||||||
Server = request.Server ?? "",
|
Channel = channel,
|
||||||
Channel = request.Channel ?? "",
|
|
||||||
Enabled = true,
|
Enabled = true,
|
||||||
});
|
});
|
||||||
|
|
||||||
return new OkObjectResult(new DiscordWebhookResult
|
return DiscordWebHookDto.Convert(res);
|
||||||
{
|
|
||||||
IsSuccessful = true,
|
|
||||||
Items = new List<DiscordWebHookDto>
|
|
||||||
{
|
|
||||||
DiscordWebHookDto.Convert(res)
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet("by/serverAndChannel")]
|
[HttpGet("by/serverAndChannel")]
|
||||||
public IEnumerable<DiscordWebHookDto> GetByServerAndChannel(string server, string channel)
|
public IEnumerable<DiscordWebHookDto> GetByServerAndChannel(string server, string channel)
|
||||||
{
|
{
|
||||||
var items = new List<DiscordWebHookDto>();
|
var items = new List<DiscordWebHookDto>();
|
||||||
var res = _webhooks.ListByServerAndChannel(HttpContext.GetUserId(), server, channel, 25);
|
var res = _webhooks.ListByServerAndChannel(server, channel, 25);
|
||||||
|
|
||||||
foreach (var item in res)
|
foreach (var item in res)
|
||||||
{
|
{
|
||||||
@ -94,21 +72,21 @@ public class DiscordWebHookController : ControllerBase
|
|||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet("{id}")]
|
[HttpGet("{id}")]
|
||||||
public DiscordWebHookDto GetById(string userId, Guid id)
|
public DiscordWebHookDto GetById(Guid id)
|
||||||
{
|
{
|
||||||
var res = _webhooks.GetById(userId, id);
|
var res = _webhooks.GetById(id);
|
||||||
return DiscordWebHookDto.Convert(res);
|
return DiscordWebHookDto.Convert(res);
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost("{id}/disable")]
|
[HttpPost("{id}/disable")]
|
||||||
public void DisableById(Guid id)
|
public void DisableById(Guid id)
|
||||||
{
|
{
|
||||||
_webhooks.Disable(HttpContext.GetUserId(), id);
|
_webhooks.Disable(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost("{id}/enable")]
|
[HttpPost("{id}/enable")]
|
||||||
public void EnableById(Guid id)
|
public void EnableById(Guid id)
|
||||||
{
|
{
|
||||||
_webhooks.Enable(HttpContext.GetUserId(), id);
|
_webhooks.Enable(id);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -8,10 +8,10 @@ using Newsbot.Collector.Domain.Models.Config;
|
|||||||
using Newsbot.Collector.Domain.Models.Config.Sources;
|
using Newsbot.Collector.Domain.Models.Config.Sources;
|
||||||
using Newsbot.Collector.Services.Jobs;
|
using Newsbot.Collector.Services.Jobs;
|
||||||
|
|
||||||
namespace Newsbot.Collector.Api.Controllers.v1;
|
namespace Newsbot.Collector.Api.Controllers;
|
||||||
|
|
||||||
[ApiController]
|
[ApiController]
|
||||||
[Route("api/v1/rss")]
|
[Route("api/rss")]
|
||||||
[Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme)]
|
[Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme)]
|
||||||
public class RssController
|
public class RssController
|
||||||
{
|
{
|
@ -9,10 +9,10 @@ using Newsbot.Collector.Domain.Models.Config.Sources;
|
|||||||
using Newsbot.Collector.Services.Jobs;
|
using Newsbot.Collector.Services.Jobs;
|
||||||
using ILogger = Grpc.Core.Logging.ILogger;
|
using ILogger = Grpc.Core.Logging.ILogger;
|
||||||
|
|
||||||
namespace Newsbot.Collector.Api.Controllers.v1;
|
namespace Newsbot.Collector.Api.Controllers;
|
||||||
|
|
||||||
[ApiController]
|
[ApiController]
|
||||||
[Route("api/v1/youtube")]
|
[Route("api/youtube")]
|
||||||
[Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme)]
|
[Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme)]
|
||||||
public class YoutubeController
|
public class YoutubeController
|
||||||
{
|
{
|
@ -1,84 +0,0 @@
|
|||||||
using Microsoft.AspNetCore.Authentication.JwtBearer;
|
|
||||||
using Microsoft.AspNetCore.Authorization;
|
|
||||||
using Microsoft.AspNetCore.Mvc;
|
|
||||||
using Newsbot.Collector.Domain.Dto;
|
|
||||||
using Newsbot.Collector.Domain.Interfaces;
|
|
||||||
using Newsbot.Collector.Domain.Results;
|
|
||||||
|
|
||||||
namespace Newsbot.Collector.Api.Controllers.v1;
|
|
||||||
|
|
||||||
[ApiController]
|
|
||||||
[Route("api/v1/articles")]
|
|
||||||
[Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme)]
|
|
||||||
public class ArticlesController : ControllerBase
|
|
||||||
{
|
|
||||||
//private readonly ILogger<ArticlesController> _logger;
|
|
||||||
private readonly IArticlesRepository _articles;
|
|
||||||
private readonly ISourcesRepository _sources;
|
|
||||||
|
|
||||||
public ArticlesController(IArticlesRepository articles, ISourcesRepository sources)
|
|
||||||
{
|
|
||||||
_articles = articles;
|
|
||||||
_sources = sources;
|
|
||||||
}
|
|
||||||
|
|
||||||
[HttpGet(Name = "GetArticles")]
|
|
||||||
public ActionResult<ArticleResult> Get()
|
|
||||||
{
|
|
||||||
var res = new List<ArticleDto>();
|
|
||||||
var items = _articles.List(0);
|
|
||||||
foreach (var item in items)
|
|
||||||
{
|
|
||||||
res.Add(ArticleDto.Convert(item));
|
|
||||||
}
|
|
||||||
|
|
||||||
return new OkObjectResult(new ArticleResult
|
|
||||||
{
|
|
||||||
IsSuccessful = true,
|
|
||||||
Items = res
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
[HttpGet("{id:guid}")]
|
|
||||||
[EndpointDescription("Returns the article based on the Id value given.")]
|
|
||||||
public ActionResult<ArticleResult> GetById(Guid id)
|
|
||||||
{
|
|
||||||
var item = _articles.GetById(id);
|
|
||||||
return new OkObjectResult(new ArticleResult
|
|
||||||
{
|
|
||||||
IsSuccessful = true,
|
|
||||||
Items = new List<ArticleDto>
|
|
||||||
{
|
|
||||||
ArticleDto.Convert(item)
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
[HttpGet("{id:guid}/details")]
|
|
||||||
public ActionResult<ArticleDetailsResult> GetDetailsById(Guid id)
|
|
||||||
{
|
|
||||||
var item = _articles.GetById(id);
|
|
||||||
var sourceItem = _sources.GetById(item.SourceId);
|
|
||||||
|
|
||||||
return new OkObjectResult(new ArticleDetailsResult
|
|
||||||
{
|
|
||||||
IsSuccessful = true,
|
|
||||||
Item = ArticleDetailsDto.Convert(item, sourceItem)
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
[HttpGet("by/{sourceId:guid}")]
|
|
||||||
public ActionResult<ArticleResult> GetBySourceId(Guid sourceId, int page = 0)
|
|
||||||
{
|
|
||||||
var res = new List<ArticleDto>();
|
|
||||||
var items = _articles.ListBySourceId(sourceId, page);
|
|
||||||
foreach (var item in items) res.Add(ArticleDto.Convert(item));
|
|
||||||
|
|
||||||
return new OkObjectResult(new ArticleResult
|
|
||||||
{
|
|
||||||
IsSuccessful = true,
|
|
||||||
Items = res
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,239 +0,0 @@
|
|||||||
using Microsoft.AspNetCore.Authentication.JwtBearer;
|
|
||||||
using Microsoft.AspNetCore.Authorization;
|
|
||||||
using Microsoft.AspNetCore.Mvc;
|
|
||||||
using Newsbot.Collector.Api.Middleware;
|
|
||||||
using Newsbot.Collector.Domain.Dto;
|
|
||||||
using Newsbot.Collector.Domain.Entities;
|
|
||||||
using Newsbot.Collector.Domain.Interfaces;
|
|
||||||
using Newsbot.Collector.Domain.Requests;
|
|
||||||
using Newsbot.Collector.Domain.Results;
|
|
||||||
|
|
||||||
namespace Newsbot.Collector.Api.Controllers.v1;
|
|
||||||
|
|
||||||
[ApiController]
|
|
||||||
[Route("api/v1/subscriptions")]
|
|
||||||
[Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme)]
|
|
||||||
public class DiscordNotificationController : ControllerBase
|
|
||||||
{
|
|
||||||
private readonly ILogger<DiscordNotificationController> _logger;
|
|
||||||
private readonly IDiscordWebHooksRepository _discord;
|
|
||||||
private readonly ISourcesRepository _sources;
|
|
||||||
private readonly IDiscordNotificationRepository _discordNotification;
|
|
||||||
|
|
||||||
public DiscordNotificationController(ILogger<DiscordNotificationController> logger, IDiscordWebHooksRepository discord, ISourcesRepository sources, IDiscordNotificationRepository discordNotification)
|
|
||||||
{
|
|
||||||
_logger = logger;
|
|
||||||
_discord = discord;
|
|
||||||
_sources = sources;
|
|
||||||
_discordNotification = discordNotification;
|
|
||||||
}
|
|
||||||
|
|
||||||
[HttpGet(Name = "ListSubscriptions")]
|
|
||||||
public ActionResult<DiscordNotificationResult> List(int page)
|
|
||||||
{
|
|
||||||
var userId = HttpContext.GetUserId();
|
|
||||||
if (userId.Equals(string.Empty))
|
|
||||||
{
|
|
||||||
return new BadRequestObjectResult(new DiscordNotificationResult
|
|
||||||
{
|
|
||||||
IsSuccessful = false,
|
|
||||||
ErrorMessage = new List<string> { "User Id is missing from the request." }
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
var res = new List<DiscordNotificationDto>();
|
|
||||||
var items = _discordNotification.List(userId, page);
|
|
||||||
foreach (var item in items) res.Add(DiscordNotificationDto.Convert(item));
|
|
||||||
|
|
||||||
return new OkObjectResult(new DiscordNotificationResult
|
|
||||||
{
|
|
||||||
IsSuccessful = true,
|
|
||||||
Items = res
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
[HttpGet("{id}")]
|
|
||||||
public ActionResult<DiscordNotificationResult> GetById(Guid id)
|
|
||||||
{
|
|
||||||
var userId = HttpContext.GetUserId();
|
|
||||||
if (userId.Equals(string.Empty))
|
|
||||||
{
|
|
||||||
return new BadRequestObjectResult(new DiscordNotificationResult
|
|
||||||
{
|
|
||||||
IsSuccessful = false,
|
|
||||||
ErrorMessage = new List<string> { "User Id is missing from the request." }
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
var res = DiscordNotificationDto.Convert(_discordNotification.GetById(userId, id));
|
|
||||||
|
|
||||||
return new OkObjectResult(new DiscordNotificationResult
|
|
||||||
{
|
|
||||||
IsSuccessful = true,
|
|
||||||
Items = new List<DiscordNotificationDto>
|
|
||||||
{
|
|
||||||
res
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
[HttpGet("{id}/details")]
|
|
||||||
public ActionResult<DiscordNotificationDetailsResult> GetDetailsById(Guid id)
|
|
||||||
{
|
|
||||||
var userId = HttpContext.GetUserId();
|
|
||||||
if (userId.Equals(string.Empty))
|
|
||||||
{
|
|
||||||
return new BadRequestObjectResult(new DiscordNotificationResult
|
|
||||||
{
|
|
||||||
IsSuccessful = false,
|
|
||||||
ErrorMessage = new List<string> { "User Id is missing from the request." }
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
var sub = _discordNotification.GetById(userId, id);
|
|
||||||
var webhook = _discord.GetById(userId, sub.DiscordWebHookId);
|
|
||||||
var source = _sources.GetById(sub.SourceId);
|
|
||||||
|
|
||||||
return new OkObjectResult(new DiscordNotificationDetailsResult
|
|
||||||
{
|
|
||||||
IsSuccessful = true,
|
|
||||||
Item = DiscordNotificationDetailsDto.Convert(sub, source, webhook)
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
[HttpPost("{id}/delete")]
|
|
||||||
public ActionResult<DiscordNotificationResult> DeleteById(Guid id)
|
|
||||||
{
|
|
||||||
var userId = HttpContext.GetUserId();
|
|
||||||
if (userId.Equals(string.Empty))
|
|
||||||
{
|
|
||||||
return new BadRequestObjectResult(new DiscordNotificationResult
|
|
||||||
{
|
|
||||||
IsSuccessful = false,
|
|
||||||
ErrorMessage = new List<string> { "User Id is missing from the request." }
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
var rowsUpdated = _discordNotification.Delete(userId, id);
|
|
||||||
if (rowsUpdated == -1)
|
|
||||||
{
|
|
||||||
return new OkObjectResult(new DiscordNotificationResult
|
|
||||||
{
|
|
||||||
IsSuccessful = false,
|
|
||||||
ErrorMessage = new List<string> { "Record was not own by requested user." }
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
return new OkObjectResult(new DiscordNotificationResult
|
|
||||||
{
|
|
||||||
IsSuccessful = true
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
[HttpGet("by/discordId/{id}")]
|
|
||||||
public ActionResult<DiscordNotificationResult> GetByDiscordId(Guid id)
|
|
||||||
{
|
|
||||||
var userId = HttpContext.GetUserId();
|
|
||||||
if (userId.Equals(string.Empty))
|
|
||||||
{
|
|
||||||
return new BadRequestObjectResult(new DiscordNotificationResult
|
|
||||||
{
|
|
||||||
IsSuccessful = false,
|
|
||||||
ErrorMessage = new List<string> { "User Id is missing from the request." }
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
var res = new List<DiscordNotificationDto>();
|
|
||||||
var items = _discordNotification.ListByWebhook(userId, id);
|
|
||||||
foreach (var item in items) res.Add(DiscordNotificationDto.Convert(item));
|
|
||||||
|
|
||||||
return new OkObjectResult(new DiscordNotificationResult
|
|
||||||
{
|
|
||||||
IsSuccessful = true,
|
|
||||||
Items = res
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
[HttpGet("by/sourceId/{id}")]
|
|
||||||
public ActionResult<DiscordNotificationResult> GetBySourceId(Guid id)
|
|
||||||
{
|
|
||||||
var userId = HttpContext.GetUserId();
|
|
||||||
if (userId.Equals(string.Empty))
|
|
||||||
{
|
|
||||||
return new BadRequestObjectResult(new DiscordNotificationResult
|
|
||||||
{
|
|
||||||
IsSuccessful = false,
|
|
||||||
ErrorMessage = new List<string> { "User Id is missing from the request." }
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
var res = new List<DiscordNotificationDto>();
|
|
||||||
var items = _discordNotification.ListBySourceId(userId, id);
|
|
||||||
foreach (var item in items) res.Add(DiscordNotificationDto.Convert(item));
|
|
||||||
|
|
||||||
return new OkObjectResult(new DiscordNotificationResult
|
|
||||||
{
|
|
||||||
IsSuccessful = true,
|
|
||||||
Items = res
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
[HttpPost(Name = "New Subscription")]
|
|
||||||
public ActionResult<DiscordNotificationDto> New([FromBody] NewDiscordNotificationRequest request)
|
|
||||||
{
|
|
||||||
var userId = HttpContext.GetUserId();
|
|
||||||
if (userId.Equals(string.Empty))
|
|
||||||
{
|
|
||||||
return new BadRequestObjectResult(new DiscordNotificationResult
|
|
||||||
{
|
|
||||||
IsSuccessful = false,
|
|
||||||
ErrorMessage = new List<string> { "User Id is missing from the request." }
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
if (request.SourceId == Guid.Empty) return new BadRequestObjectResult(new DiscordNotificationResult
|
|
||||||
{
|
|
||||||
IsSuccessful = false,
|
|
||||||
ErrorMessage = new List<string> { "SourceId is missing from the request." }
|
|
||||||
});
|
|
||||||
if (request.DiscordId == Guid.Empty) return new BadRequestObjectResult(new DiscordNotificationResult
|
|
||||||
{
|
|
||||||
IsSuccessful = false,
|
|
||||||
ErrorMessage = new List<string> { "DiscordId is missing from the request." }
|
|
||||||
});
|
|
||||||
|
|
||||||
var exists = _discordNotification.GetByWebhookAndSource(userId, request.DiscordId, request.SourceId);
|
|
||||||
if (exists.Id != Guid.Empty) return DiscordNotificationDto.Convert(exists);
|
|
||||||
|
|
||||||
var discord = _discord.GetById(userId, request.DiscordId);
|
|
||||||
if (discord.Id == Guid.Empty) return new BadRequestObjectResult(new DiscordNotificationResult
|
|
||||||
{
|
|
||||||
IsSuccessful = false,
|
|
||||||
ErrorMessage = new List<string> { "Unable to find the requested DiscordId in the database." }
|
|
||||||
});
|
|
||||||
|
|
||||||
var source = _sources.GetById(request.SourceId);
|
|
||||||
if (source.Id == Guid.Empty) return new BadRequestObjectResult(new DiscordNotificationResult
|
|
||||||
{
|
|
||||||
IsSuccessful = false,
|
|
||||||
ErrorMessage = new List<string> { "Unable to find the requested SourceId in the database." }
|
|
||||||
});
|
|
||||||
|
|
||||||
var item = _discordNotification.New(new DiscordNotificationEntity
|
|
||||||
{
|
|
||||||
Id = Guid.NewGuid(),
|
|
||||||
SourceId = request.SourceId,
|
|
||||||
DiscordWebHookId = request.DiscordId,
|
|
||||||
CodeAllowCommits = request.AllowCommits,
|
|
||||||
CodeAllowReleases = request.AllowReleases,
|
|
||||||
UserId = userId
|
|
||||||
});
|
|
||||||
|
|
||||||
return new OkObjectResult(new DiscordNotificationResult
|
|
||||||
{
|
|
||||||
IsSuccessful = true,
|
|
||||||
Items = new List<DiscordNotificationDto> { DiscordNotificationDto.Convert(item) }
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,10 +1,10 @@
|
|||||||
using Microsoft.AspNetCore.Authorization;
|
using Microsoft.AspNetCore.Authorization;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Newsbot.Collector.Api.Domain;
|
using Newsbot.Collector.Api.Domain;
|
||||||
using Newsbot.Collector.Domain.Requests;
|
using Newsbot.Collector.Api.Domain.Requests;
|
||||||
using Newsbot.Collector.Domain.Response;
|
using Newsbot.Collector.Api.Domain.Response;
|
||||||
using Newsbot.Collector.Domain.Results;
|
using Newsbot.Collector.Api.Domain.Results;
|
||||||
using Newsbot.Collector.Services;
|
using Newsbot.Collector.Api.Services;
|
||||||
|
|
||||||
namespace Newsbot.Collector.Api.Controllers.v1;
|
namespace Newsbot.Collector.Api.Controllers.v1;
|
||||||
|
|
||||||
@ -12,13 +12,11 @@ namespace Newsbot.Collector.Api.Controllers.v1;
|
|||||||
[Route("/api/v1/account")]
|
[Route("/api/v1/account")]
|
||||||
public class IdentityController : ControllerBase
|
public class IdentityController : ControllerBase
|
||||||
{
|
{
|
||||||
private readonly ILogger<IdentityController> _logger;
|
private IIdentityService _identityService;
|
||||||
private readonly IIdentityService _identityService;
|
|
||||||
|
|
||||||
public IdentityController(IIdentityService identityService, ILogger<IdentityController> logger)
|
public IdentityController(IIdentityService identityService)
|
||||||
{
|
{
|
||||||
_identityService = identityService;
|
_identityService = identityService;
|
||||||
_logger = logger;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost("register")]
|
[HttpPost("register")]
|
||||||
@ -83,7 +81,6 @@ public class IdentityController : ControllerBase
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
_logger.LogWarning(ex, "Failed to add role to user");
|
|
||||||
return new BadRequestResult();
|
return new BadRequestResult();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,6 @@ using Microsoft.AspNetCore.Authentication.JwtBearer;
|
|||||||
using Microsoft.AspNetCore.Authorization;
|
using Microsoft.AspNetCore.Authorization;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Newsbot.Collector.Api.Authentication;
|
using Newsbot.Collector.Api.Authentication;
|
||||||
using Newsbot.Collector.Api.Middleware;
|
|
||||||
using Newsbot.Collector.Domain.Entities;
|
using Newsbot.Collector.Domain.Entities;
|
||||||
using Newsbot.Collector.Domain.Interfaces;
|
using Newsbot.Collector.Domain.Interfaces;
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
namespace Newsbot.Collector.Domain.Requests;
|
namespace Newsbot.Collector.Api.Domain.Requests;
|
||||||
|
|
||||||
public class AddRoleRequest
|
public class AddRoleRequest
|
||||||
{
|
{
|
@ -1,6 +1,6 @@
|
|||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
|
||||||
namespace Newsbot.Collector.Domain.Requests;
|
namespace Newsbot.Collector.Api.Domain.Requests;
|
||||||
|
|
||||||
public class RegisterUserRequest
|
public class RegisterUserRequest
|
||||||
{
|
{
|
@ -1,6 +1,6 @@
|
|||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
|
||||||
namespace Newsbot.Collector.Domain.Requests;
|
namespace Newsbot.Collector.Api.Domain.Requests;
|
||||||
|
|
||||||
public class UserLoginRequest
|
public class UserLoginRequest
|
||||||
{
|
{
|
@ -1,4 +1,4 @@
|
|||||||
namespace Newsbot.Collector.Domain.Requests;
|
namespace Newsbot.Collector.Api.Domain.Requests;
|
||||||
|
|
||||||
public class UserRefreshTokenRequest
|
public class UserRefreshTokenRequest
|
||||||
{
|
{
|
@ -1,4 +1,4 @@
|
|||||||
namespace Newsbot.Collector.Domain.Response;
|
namespace Newsbot.Collector.Api.Domain.Response;
|
||||||
|
|
||||||
public class AuthFailedResponse
|
public class AuthFailedResponse
|
||||||
{
|
{
|
@ -1,4 +1,4 @@
|
|||||||
namespace Newsbot.Collector.Domain.Response;
|
namespace Newsbot.Collector.Api.Domain.Response;
|
||||||
|
|
||||||
public class AuthSuccessfulResponse
|
public class AuthSuccessfulResponse
|
||||||
{
|
{
|
12
Newsbot.Collector.Api/Domain/Results/AuthenticationResult.cs
Normal file
12
Newsbot.Collector.Api/Domain/Results/AuthenticationResult.cs
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
using System.Collections;
|
||||||
|
|
||||||
|
namespace Newsbot.Collector.Api.Domain.Results;
|
||||||
|
|
||||||
|
public class AuthenticationResult
|
||||||
|
{
|
||||||
|
public string? Token { get; set; }
|
||||||
|
public string? RefreshToken { get; set; }
|
||||||
|
|
||||||
|
public bool IsSuccessful { get; set; }
|
||||||
|
public IEnumerable<string>? ErrorMessage { get; set; }
|
||||||
|
}
|
@ -1,9 +1,14 @@
|
|||||||
namespace Newsbot.Collector.Api.Middleware;
|
namespace Newsbot.Collector.Api.Authentication;
|
||||||
|
|
||||||
public static class JwtUserIdExtension
|
public static class JwtUserIdExtension
|
||||||
{
|
{
|
||||||
public static string GetUserId(this HttpContext context)
|
public static string GetUserId(this HttpContext context)
|
||||||
{
|
{
|
||||||
|
if (context.User == null)
|
||||||
|
{
|
||||||
|
return string.Empty;
|
||||||
|
}
|
||||||
|
|
||||||
return context.User.Claims.Single(x => x.Type == "id").Value;
|
return context.User.Claims.Single(x => x.Type == "id").Value;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -4,8 +4,6 @@
|
|||||||
<TargetFramework>net7.0</TargetFramework>
|
<TargetFramework>net7.0</TargetFramework>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
|
||||||
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
|
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
@ -35,7 +35,7 @@ GlobalConfiguration.Configuration.UseSerilogLogProvider();
|
|||||||
|
|
||||||
// Build Health Checks
|
// Build Health Checks
|
||||||
builder.Services.AddHealthChecks()
|
builder.Services.AddHealthChecks()
|
||||||
.AddNpgSql(config.GetValue<string>(ConfigConst.ConnectionStringDatabase) ?? "");
|
.AddNpgSql(config.GetValue<string>(ConfigConnectionStringConst.Database) ?? "");
|
||||||
|
|
||||||
|
|
||||||
builder.Services.AddControllers();
|
builder.Services.AddControllers();
|
||||||
@ -109,7 +109,7 @@ static IConfiguration GetConfiguration()
|
|||||||
|
|
||||||
static ILogger GetLogger(IConfiguration configuration)
|
static ILogger GetLogger(IConfiguration configuration)
|
||||||
{
|
{
|
||||||
var otel = configuration.GetValue<string>(ConfigConst.ConnectionStringOpenTelemetry) ?? "";
|
var otel = configuration.GetValue<string>(ConfigConnectionStringConst.OpenTelemetry) ?? "";
|
||||||
|
|
||||||
if (otel == "")
|
if (otel == "")
|
||||||
return Log.Logger = new LoggerConfiguration()
|
return Log.Logger = new LoggerConfiguration()
|
||||||
|
@ -3,13 +3,13 @@ using System.Security.Claims;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using Microsoft.AspNetCore.Identity;
|
using Microsoft.AspNetCore.Identity;
|
||||||
using Microsoft.IdentityModel.Tokens;
|
using Microsoft.IdentityModel.Tokens;
|
||||||
using Newsbot.Collector.Domain.Results;
|
using Newsbot.Collector.Api.Domain.Results;
|
||||||
|
using Newsbot.Collector.Database;
|
||||||
using Newsbot.Collector.Domain.Entities;
|
using Newsbot.Collector.Domain.Entities;
|
||||||
using Newsbot.Collector.Domain.Interfaces;
|
using Newsbot.Collector.Domain.Interfaces;
|
||||||
using Newsbot.Collector.Domain.Models.Config;
|
using Newsbot.Collector.Domain.Models.Config;
|
||||||
using JwtRegisteredClaimNames = Microsoft.IdentityModel.JsonWebTokens.JwtRegisteredClaimNames;
|
|
||||||
|
|
||||||
namespace Newsbot.Collector.Services;
|
namespace Newsbot.Collector.Api.Services;
|
||||||
|
|
||||||
public interface IIdentityService
|
public interface IIdentityService
|
||||||
{
|
{
|
||||||
@ -60,7 +60,7 @@ public class IdentityService : IIdentityService
|
|||||||
{
|
{
|
||||||
return new AuthenticationResult
|
return new AuthenticationResult
|
||||||
{
|
{
|
||||||
ErrorMessage = new List<string>(createdUser.Result.Errors.Select(x => x.Description))
|
ErrorMessage = new[] { createdUser.Result.Errors.Select(x => x.Description).ToString() }
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
@ -1,10 +1,10 @@
|
|||||||
using Microsoft.AspNetCore.Identity;
|
using Microsoft.AspNetCore.Identity;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Newsbot.Collector.Api.Domain;
|
using Newsbot.Collector.Api.Domain;
|
||||||
|
using Newsbot.Collector.Api.Services;
|
||||||
using Newsbot.Collector.Database;
|
using Newsbot.Collector.Database;
|
||||||
using Newsbot.Collector.Database.Repositories;
|
using Newsbot.Collector.Database.Repositories;
|
||||||
using Newsbot.Collector.Domain.Interfaces;
|
using Newsbot.Collector.Domain.Interfaces;
|
||||||
using Newsbot.Collector.Services;
|
|
||||||
|
|
||||||
namespace Newsbot.Collector.Api.Startup;
|
namespace Newsbot.Collector.Api.Startup;
|
||||||
|
|
||||||
|
@ -17,8 +17,8 @@ public class DatabaseContext : IdentityDbContext
|
|||||||
public DbSet<SourceEntity> Sources { get; set; } = null!;
|
public DbSet<SourceEntity> Sources { get; set; } = null!;
|
||||||
|
|
||||||
public DbSet<UserSourceSubscriptionEntity> UserSourceSubscription { get; set; } = null!;
|
public DbSet<UserSourceSubscriptionEntity> UserSourceSubscription { get; set; } = null!;
|
||||||
|
|
||||||
public DbSet<RefreshTokenEntity> RefreshTokens { get; set; } = null!;
|
public DbSet<RefreshTokenEntity> RefreshTokens { get; set; }
|
||||||
|
|
||||||
private string ConnectionString { get; set; } = "";
|
private string ConnectionString { get; set; } = "";
|
||||||
|
|
||||||
|
@ -21,9 +21,6 @@
|
|||||||
<TargetFramework>net7.0</TargetFramework>
|
<TargetFramework>net7.0</TargetFramework>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
|
|
||||||
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
|
|
||||||
<NoWarn>8981</NoWarn>
|
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
@ -1,5 +1,10 @@
|
|||||||
|
using System.Data;
|
||||||
|
using Dapper;
|
||||||
|
using Microsoft.Extensions.Configuration;
|
||||||
using Newsbot.Collector.Domain.Entities;
|
using Newsbot.Collector.Domain.Entities;
|
||||||
using Newsbot.Collector.Domain.Interfaces;
|
using Newsbot.Collector.Domain.Interfaces;
|
||||||
|
using Newsbot.Collector.Domain.Models;
|
||||||
|
using Npgsql;
|
||||||
|
|
||||||
namespace Newsbot.Collector.Database.Repositories;
|
namespace Newsbot.Collector.Database.Repositories;
|
||||||
|
|
||||||
@ -22,76 +27,66 @@ public class DiscordNotificationTable : IDiscordNotificationRepository
|
|||||||
public DiscordNotificationEntity New(DiscordNotificationEntity model)
|
public DiscordNotificationEntity New(DiscordNotificationEntity model)
|
||||||
{
|
{
|
||||||
model.Id = new Guid();
|
model.Id = new Guid();
|
||||||
|
//using var context = new DatabaseContext(_connectionString);
|
||||||
_context.DiscordNotification.Add(model);
|
_context.DiscordNotification.Add(model);
|
||||||
_context.SaveChanges();
|
_context.SaveChanges();
|
||||||
|
|
||||||
return model;
|
return model;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<DiscordNotificationEntity> List(string userId, int page = 0, int count = 25)
|
public List<DiscordNotificationEntity> List(int page = 0, int count = 25)
|
||||||
{
|
{
|
||||||
return _context.DiscordNotification
|
//using var context = new DatabaseContext(_connectionString);
|
||||||
.Where(x => x.UserId != null && x.UserId.Equals(userId))
|
return _context.DiscordNotification.Skip(page * count).Take(count).ToList();
|
||||||
.Skip(page * count)
|
|
||||||
.Take(count)
|
|
||||||
.ToList();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<DiscordNotificationEntity> ListBySourceId(string userId, Guid id, int page = 0, int count = 25)
|
|
||||||
{
|
|
||||||
return _context.DiscordNotification
|
|
||||||
.Where(f => f.SourceId.Equals(id))
|
|
||||||
.Where(f => f.UserId != null && f.UserId.Equals(userId))
|
|
||||||
.Skip(page * count)
|
|
||||||
.ToList();
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<DiscordNotificationEntity> ListBySourceId(Guid id, int page = 0, int count = 25)
|
public List<DiscordNotificationEntity> ListBySourceId(Guid id, int page = 0, int count = 25)
|
||||||
{
|
{
|
||||||
return _context.DiscordNotification
|
//using var context = new DatabaseContext(_connectionString);
|
||||||
.Where(f => f.SourceId.Equals(id))
|
return _context.DiscordNotification.Where(f => f.SourceId.Equals(id))
|
||||||
.Skip(page * count)
|
.Skip(page * count)
|
||||||
.ToList();
|
.ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<DiscordNotificationEntity> ListByWebhook(string userId, Guid id, int page = 0, int count = 25)
|
public List<DiscordNotificationEntity> ListByWebhook(Guid id, int page = 0, int count = 25)
|
||||||
{
|
{
|
||||||
return _context.DiscordNotification
|
//using var context = new DatabaseContext(_connectionString);
|
||||||
.Where(f => f.DiscordWebHookId.Equals(id))
|
return _context.DiscordNotification.Where(f => f.DiscordWebHookId.Equals(id)).Skip(page * count).ToList();
|
||||||
.Where(f => f.UserId != null && f.UserId.Equals(userId))
|
|
||||||
.Skip(page * count)
|
|
||||||
.ToList();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public DiscordNotificationEntity GetById(string userId, Guid id)
|
public DiscordNotificationEntity GetById(Guid id)
|
||||||
{
|
{
|
||||||
|
//using var context = new DatabaseContext(_connectionString);
|
||||||
var res = _context.DiscordNotification
|
var res = _context.DiscordNotification
|
||||||
.Where(f => f.UserId != null && f.UserId.Equals(userId))
|
|
||||||
.FirstOrDefault(f => f.Id.Equals(id));
|
.FirstOrDefault(f => f.Id.Equals(id));
|
||||||
return res ??= new DiscordNotificationEntity();
|
return res ??= new DiscordNotificationEntity();
|
||||||
}
|
}
|
||||||
|
|
||||||
public DiscordNotificationEntity GetByWebhookAndSource(string userId, Guid webhookId, Guid sourceId)
|
public DiscordNotificationEntity GetByWebhookAndSource(Guid webhookId, Guid sourceId)
|
||||||
{
|
{
|
||||||
|
//using var context = new DatabaseContext(_connectionString);
|
||||||
var res = _context.DiscordNotification
|
var res = _context.DiscordNotification
|
||||||
.Where(f => f.UserId != null && f.UserId.Equals(userId))
|
|
||||||
.Where(f => f.DiscordWebHookId.Equals(webhookId))
|
.Where(f => f.DiscordWebHookId.Equals(webhookId))
|
||||||
.FirstOrDefault(f => f.SourceId.Equals(sourceId));
|
.FirstOrDefault(f => f.SourceId.Equals(sourceId));
|
||||||
return res ??= new DiscordNotificationEntity();
|
return res ??= new DiscordNotificationEntity();
|
||||||
}
|
}
|
||||||
|
|
||||||
public int Delete(string userId, Guid id)
|
public void Delete(Guid id)
|
||||||
{
|
{
|
||||||
var res = _context.DiscordNotification
|
//using var context = new DatabaseContext(_connectionString);
|
||||||
.Where(f => f.UserId != null && f.UserId.Equals(userId))
|
var res = _context.DiscordNotification.FirstOrDefault(f => f.Id.Equals(id));
|
||||||
.FirstOrDefault(f => f.Id.Equals(id));
|
|
||||||
if (res is null)
|
if (res is null)
|
||||||
{
|
{
|
||||||
return -1;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
_context.DiscordNotification.Remove(res);
|
_context.DiscordNotification.Remove(res);
|
||||||
return _context.SaveChanges();
|
_context.SaveChanges();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//private IDbConnection OpenConnection(string connectionString)
|
||||||
|
//{
|
||||||
|
// var conn = new NpgsqlConnection(_connectionString);
|
||||||
|
// conn.Open();
|
||||||
|
// return conn;
|
||||||
|
//}
|
||||||
}
|
}
|
@ -1,6 +1,5 @@
|
|||||||
using System.Data;
|
using System.Data;
|
||||||
using Dapper;
|
using Dapper;
|
||||||
using Microsoft.EntityFrameworkCore;
|
|
||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Configuration;
|
||||||
using Newsbot.Collector.Domain.Interfaces;
|
using Newsbot.Collector.Domain.Interfaces;
|
||||||
using Newsbot.Collector.Domain.Entities;
|
using Newsbot.Collector.Domain.Entities;
|
||||||
@ -34,20 +33,10 @@ public class DiscordWebhooksTable : IDiscordWebHooksRepository
|
|||||||
return model;
|
return model;
|
||||||
}
|
}
|
||||||
|
|
||||||
public DiscordWebhookEntity GetById(string userId, Guid id)
|
|
||||||
{
|
|
||||||
//using var context = new DatabaseContext(_connectionString);
|
|
||||||
var res = _context.DiscordWebhooks
|
|
||||||
.Where(i => i.UserId != null && i.UserId.Equals(userId))
|
|
||||||
.FirstOrDefault(d => d.Id.Equals(id));
|
|
||||||
res ??= new DiscordWebhookEntity();
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
public DiscordWebhookEntity GetById(Guid id)
|
public DiscordWebhookEntity GetById(Guid id)
|
||||||
{
|
{
|
||||||
var res = _context.DiscordWebhooks
|
//using var context = new DatabaseContext(_connectionString);
|
||||||
.FirstOrDefault(d => d.Id.Equals(id));
|
var res = _context.DiscordWebhooks.FirstOrDefault(d => d.Id.Equals(id));
|
||||||
res ??= new DiscordWebhookEntity();
|
res ??= new DiscordWebhookEntity();
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
@ -71,16 +60,6 @@ public class DiscordWebhooksTable : IDiscordWebHooksRepository
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<DiscordWebhookEntity> ListByUserId(string userId, int page)
|
|
||||||
{
|
|
||||||
var query = _context.DiscordWebhooks
|
|
||||||
.Where(p => p.UserId != null && p.UserId.Equals(userId))
|
|
||||||
.Skip(page * 25)
|
|
||||||
.Take(25)
|
|
||||||
.ToList();
|
|
||||||
return query;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<DiscordWebhookEntity> ListByServer(string server, int limit = 25)
|
public List<DiscordWebhookEntity> ListByServer(string server, int limit = 25)
|
||||||
{
|
{
|
||||||
//using var context = new DatabaseContext(_connectionString);
|
//using var context = new DatabaseContext(_connectionString);
|
||||||
@ -92,11 +71,10 @@ public class DiscordWebhooksTable : IDiscordWebHooksRepository
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<DiscordWebhookEntity> ListByServerAndChannel(string userId, string server, string channel, int limit = 25)
|
public List<DiscordWebhookEntity> ListByServerAndChannel(string server, string channel, int limit = 25)
|
||||||
{
|
{
|
||||||
//using var context = new DatabaseContext(_connectionString);
|
//using var context = new DatabaseContext(_connectionString);
|
||||||
var res = _context.DiscordWebhooks
|
var res = _context.DiscordWebhooks
|
||||||
.Where(i => i.UserId != null && i.UserId.Equals(userId))
|
|
||||||
.Where(s => s.Server.Equals(server))
|
.Where(s => s.Server.Equals(server))
|
||||||
.Where(c => c.Channel.Equals(channel))
|
.Where(c => c.Channel.Equals(channel))
|
||||||
.Take(limit)
|
.Take(limit)
|
||||||
@ -105,9 +83,9 @@ public class DiscordWebhooksTable : IDiscordWebHooksRepository
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int Disable(string userId, Guid id)
|
public int Disable(Guid id)
|
||||||
{
|
{
|
||||||
var res = GetById(userId, id);
|
var res = GetById(id);
|
||||||
//using var context = new DatabaseContext(_connectionString);
|
//using var context = new DatabaseContext(_connectionString);
|
||||||
|
|
||||||
res.Enabled = true;
|
res.Enabled = true;
|
||||||
@ -125,9 +103,9 @@ public class DiscordWebhooksTable : IDiscordWebHooksRepository
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public int Enable(string userId, Guid id)
|
public int Enable(Guid id)
|
||||||
{
|
{
|
||||||
var res = GetById(userId, id);
|
var res = GetById(id);
|
||||||
//using var context = new DatabaseContext(_connectionString);
|
//using var context = new DatabaseContext(_connectionString);
|
||||||
|
|
||||||
res.Enabled = false;
|
res.Enabled = false;
|
||||||
|
@ -19,8 +19,7 @@ public class UserSourceSubscriptionTable : IUserSourceSubscription
|
|||||||
|
|
||||||
public List<UserSourceSubscriptionEntity> ListUserSubscriptions(Guid userId)
|
public List<UserSourceSubscriptionEntity> ListUserSubscriptions(Guid userId)
|
||||||
{
|
{
|
||||||
var results =_context.UserSourceSubscription
|
var results =_context.UserSourceSubscription.Where(i => i.UserId.Equals(userId)).ToList();
|
||||||
.Where(i => i.UserId != null && i.UserId.Equals(userId)).ToList();
|
|
||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,10 @@
|
|||||||
|
namespace Newsbot.Collector.Domain.Consts;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// This class contains const entries to access keys within IConfiguration.
|
||||||
|
/// </summary>
|
||||||
|
public static class ConfigConnectionStringConst
|
||||||
|
{
|
||||||
|
public const string Database = "ConnectionStrings:Database";
|
||||||
|
public const string OpenTelemetry = "ConnectionStrings:OpenTelemetry";
|
||||||
|
}
|
11
Newsbot.Collector.Domain/Consts/ConfigTwitchConst.cs
Normal file
11
Newsbot.Collector.Domain/Consts/ConfigTwitchConst.cs
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
namespace Newsbot.Collector.Domain.Consts;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// This class contains const entries to access keys within IConfiguration.
|
||||||
|
/// </summary>
|
||||||
|
public class ConfigTwitchConst
|
||||||
|
{
|
||||||
|
public const string IsEnabled = "Twitch:IsEnabled";
|
||||||
|
public const string ClientID = "Twitch:ClientID";
|
||||||
|
public const string ClientSecret = "Twitch:ClientSecret";
|
||||||
|
}
|
10
Newsbot.Collector.Domain/Consts/ConfigYoutubeConst.cs
Normal file
10
Newsbot.Collector.Domain/Consts/ConfigYoutubeConst.cs
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
namespace Newsbot.Collector.Domain.Consts;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// This class contains const entries to access keys within IConfiguration.
|
||||||
|
/// </summary>
|
||||||
|
public class ConfigYoutubeConst
|
||||||
|
{
|
||||||
|
public const string IsEnable = "Youtube:IsEnabled";
|
||||||
|
public const string Debug = "Youtube:Debug";
|
||||||
|
}
|
@ -1,6 +1,3 @@
|
|||||||
using System.ComponentModel.DataAnnotations.Schema;
|
|
||||||
using Microsoft.AspNetCore.Identity;
|
|
||||||
|
|
||||||
namespace Newsbot.Collector.Domain.Entities;
|
namespace Newsbot.Collector.Domain.Entities;
|
||||||
|
|
||||||
public class DiscordWebhookEntity
|
public class DiscordWebhookEntity
|
||||||
@ -10,8 +7,4 @@ public class DiscordWebhookEntity
|
|||||||
public string Server { get; set; } = "";
|
public string Server { get; set; } = "";
|
||||||
public string Channel { get; set; } = "";
|
public string Channel { get; set; } = "";
|
||||||
public bool Enabled { get; set; }
|
public bool Enabled { get; set; }
|
||||||
|
|
||||||
public string? UserId { get; set; }
|
|
||||||
[ForeignKey(nameof(UserId))]
|
|
||||||
public IdentityUser? User { get; set; }
|
|
||||||
}
|
}
|
@ -5,7 +5,7 @@ namespace Newsbot.Collector.Domain.Interfaces;
|
|||||||
|
|
||||||
public interface IArticlesRepository : ITableRepository
|
public interface IArticlesRepository : ITableRepository
|
||||||
{
|
{
|
||||||
List<ArticlesEntity> List(int page, int count = 25);
|
List<ArticlesEntity> List(int page, int count);
|
||||||
List<ArticlesEntity> ListBySourceId(Guid id, int page = 0, int count = 25);
|
List<ArticlesEntity> ListBySourceId(Guid id, int page = 0, int count = 25);
|
||||||
ArticlesEntity GetById(Guid id);
|
ArticlesEntity GetById(Guid id);
|
||||||
ArticlesEntity GetByUrl(string url);
|
ArticlesEntity GetByUrl(string url);
|
||||||
|
@ -7,22 +7,12 @@ public interface IDiscordNotificationRepository
|
|||||||
{
|
{
|
||||||
DiscordNotificationEntity New(DiscordNotificationEntity model);
|
DiscordNotificationEntity New(DiscordNotificationEntity model);
|
||||||
|
|
||||||
List<DiscordNotificationEntity> List(string userId, int page = 0, int count = 25);
|
List<DiscordNotificationEntity> List(int page = 0, int count = 25);
|
||||||
List<DiscordNotificationEntity> ListBySourceId(string userId, Guid id, int page = 0, int count = 25);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// This will collect all the records based on the SourceId.
|
|
||||||
/// Background jobs can use this but user facing calls need to define UserId
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="id"></param>
|
|
||||||
/// <param name="page"></param>
|
|
||||||
/// <param name="count"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
List<DiscordNotificationEntity> ListBySourceId(Guid id, int page = 0, int count = 25);
|
List<DiscordNotificationEntity> ListBySourceId(Guid id, int page = 0, int count = 25);
|
||||||
List<DiscordNotificationEntity> ListByWebhook(string userId, Guid id, int page = 0, int count = 25);
|
List<DiscordNotificationEntity> ListByWebhook(Guid id, int page = 0, int count = 25);
|
||||||
|
|
||||||
DiscordNotificationEntity GetById(string userId, Guid id);
|
DiscordNotificationEntity GetById(Guid id);
|
||||||
DiscordNotificationEntity GetByWebhookAndSource(string userId, Guid webhookId, Guid sourceId);
|
DiscordNotificationEntity GetByWebhookAndSource(Guid webhookId, Guid sourceId);
|
||||||
|
|
||||||
int Delete(string userId, Guid id);
|
void Delete(Guid id);
|
||||||
}
|
}
|
@ -6,16 +6,13 @@ public interface IDiscordWebHooksRepository
|
|||||||
{
|
{
|
||||||
DiscordWebhookEntity New(DiscordWebhookEntity model);
|
DiscordWebhookEntity New(DiscordWebhookEntity model);
|
||||||
|
|
||||||
DiscordWebhookEntity GetById(string userId, Guid id);
|
|
||||||
DiscordWebhookEntity GetById(Guid id);
|
DiscordWebhookEntity GetById(Guid id);
|
||||||
|
|
||||||
DiscordWebhookEntity GetByUrl(string url);
|
DiscordWebhookEntity GetByUrl(string url);
|
||||||
|
|
||||||
List<DiscordWebhookEntity> List(int page, int count = 25);
|
List<DiscordWebhookEntity> List(int page, int count = 25);
|
||||||
List<DiscordWebhookEntity> ListByUserId(string userId, int page);
|
|
||||||
List<DiscordWebhookEntity> ListByServer(string server, int limit);
|
List<DiscordWebhookEntity> ListByServer(string server, int limit);
|
||||||
List<DiscordWebhookEntity> ListByServerAndChannel(string userId, string server, string channel, int limit);
|
List<DiscordWebhookEntity> ListByServerAndChannel(string server, string channel, int limit);
|
||||||
|
|
||||||
int Disable(string userId, Guid id);
|
int Disable(Guid id);
|
||||||
int Enable(string userId, Guid id);
|
int Enable(Guid id);
|
||||||
}
|
}
|
@ -1,24 +1,13 @@
|
|||||||
using Newsbot.Collector.Domain.Models.Config;
|
|
||||||
|
|
||||||
namespace Newsbot.Collector.Domain.Models;
|
namespace Newsbot.Collector.Domain.Models;
|
||||||
|
|
||||||
public class ConfigModel
|
public class ConfigModel
|
||||||
{
|
{
|
||||||
public ConnectionStrings? ConnectionStrings { get; set; }
|
public string? ServerAddress { get; set; }
|
||||||
public RedditConfig? Reddit { get; set; }
|
public string? SqlConnectionString { get; set; }
|
||||||
public YoutubeConfig? Youtube { get; set; }
|
public RedditConfigModel? Reddit { get; set; }
|
||||||
public TwitchConfig? Twitch { get; set; }
|
|
||||||
public BasicSourceConfig? FinalFantasyXiv { get; set; }
|
|
||||||
public BasicSourceConfig? Rss { get; set; }
|
|
||||||
public BasicSourceConfig? CodeProjects { get; set; }
|
|
||||||
public NotificationsConfig? Notifications { get; set; }
|
|
||||||
public bool EnableSwagger { get; set; }
|
|
||||||
public bool RunDatabaseMigrationsOnStartup { get; set; }
|
|
||||||
public List<string>? ApiKeys { get; set; }
|
|
||||||
public JwtSettings? JwtSettings { get; set; }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public class RedditConfig
|
public class RedditConfigModel
|
||||||
{
|
{
|
||||||
public bool IsEnabled { get; set; }
|
public bool IsEnabled { get; set; }
|
||||||
public bool PullHot { get; set; }
|
public bool PullHot { get; set; }
|
||||||
@ -28,29 +17,5 @@ public class RedditConfig
|
|||||||
|
|
||||||
public class ConnectionStrings
|
public class ConnectionStrings
|
||||||
{
|
{
|
||||||
public string? Database { get; set; }
|
public string Database { get; set; } = "";
|
||||||
public string? OpenTelemetry { get; set; }
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public class BasicSourceConfig
|
|
||||||
{
|
|
||||||
public bool IsEnabled { get; set; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public class YoutubeConfig
|
|
||||||
{
|
|
||||||
public bool IsEnabled { get; set; }
|
|
||||||
public bool Debug { get; set; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public class TwitchConfig
|
|
||||||
{
|
|
||||||
public bool IsEnabled { get; set; }
|
|
||||||
public string? ClientId { get; set; }
|
|
||||||
public string? ClientSecret { get; set; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public class NotificationsConfig
|
|
||||||
{
|
|
||||||
public BasicSourceConfig? Discord { get; set; }
|
|
||||||
}
|
|
@ -0,0 +1,9 @@
|
|||||||
|
namespace Newsbot.Collector.Domain.Models.Config.Sources;
|
||||||
|
|
||||||
|
public class ConfigSectionRedditModel
|
||||||
|
{
|
||||||
|
public bool IsEnabled { get; set; }
|
||||||
|
public bool PullHot { get; set; }
|
||||||
|
public bool PullNsfw { get; set; }
|
||||||
|
public bool PullTop { get; set; }
|
||||||
|
}
|
@ -4,8 +4,6 @@
|
|||||||
<TargetFramework>net7.0</TargetFramework>
|
<TargetFramework>net7.0</TargetFramework>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
|
|
||||||
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
|
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
@ -1,10 +0,0 @@
|
|||||||
namespace Newsbot.Collector.Domain.Requests;
|
|
||||||
|
|
||||||
public class NewDiscordNotificationRequest
|
|
||||||
{
|
|
||||||
public Guid SourceId { get; set; }
|
|
||||||
public Guid DiscordId { get; set; }
|
|
||||||
|
|
||||||
public bool AllowReleases { get; set; } = false;
|
|
||||||
public bool AllowCommits { get; set; } = false;
|
|
||||||
}
|
|
@ -1,8 +0,0 @@
|
|||||||
namespace Newsbot.Collector.Domain.Requests;
|
|
||||||
|
|
||||||
public class NewDiscordWebhookRequest
|
|
||||||
{
|
|
||||||
public string? Url { get; set; }
|
|
||||||
public string? Server { get; set; }
|
|
||||||
public string? Channel { get; set; }
|
|
||||||
}
|
|
@ -1,8 +0,0 @@
|
|||||||
using Newsbot.Collector.Domain.Dto;
|
|
||||||
|
|
||||||
namespace Newsbot.Collector.Domain.Results;
|
|
||||||
|
|
||||||
public class ArticleDetailsResult : BaseResult
|
|
||||||
{
|
|
||||||
public ArticleDetailsDto? Item { get; set; }
|
|
||||||
}
|
|
@ -1,8 +0,0 @@
|
|||||||
using Newsbot.Collector.Domain.Dto;
|
|
||||||
|
|
||||||
namespace Newsbot.Collector.Domain.Results;
|
|
||||||
|
|
||||||
public class ArticleResult : BaseResult
|
|
||||||
{
|
|
||||||
public IEnumerable<ArticleDto>? Items { get; set; }
|
|
||||||
}
|
|
@ -1,7 +0,0 @@
|
|||||||
namespace Newsbot.Collector.Domain.Results;
|
|
||||||
|
|
||||||
public class AuthenticationResult : BaseResult
|
|
||||||
{
|
|
||||||
public string? Token { get; set; }
|
|
||||||
public string? RefreshToken { get; set; }
|
|
||||||
}
|
|
@ -1,7 +0,0 @@
|
|||||||
namespace Newsbot.Collector.Domain.Results;
|
|
||||||
|
|
||||||
public class BaseResult
|
|
||||||
{
|
|
||||||
public bool IsSuccessful { get; set; }
|
|
||||||
public IEnumerable<string>? ErrorMessage { get; set; }
|
|
||||||
}
|
|
@ -1,8 +0,0 @@
|
|||||||
using Newsbot.Collector.Domain.Dto;
|
|
||||||
|
|
||||||
namespace Newsbot.Collector.Domain.Results;
|
|
||||||
|
|
||||||
public class DiscordNotificationDetailsResult : BaseResult
|
|
||||||
{
|
|
||||||
public DiscordNotificationDetailsDto? Item { get; set; }
|
|
||||||
}
|
|
@ -1,8 +0,0 @@
|
|||||||
using Newsbot.Collector.Domain.Dto;
|
|
||||||
|
|
||||||
namespace Newsbot.Collector.Domain.Results;
|
|
||||||
|
|
||||||
public class DiscordNotificationResult : BaseResult
|
|
||||||
{
|
|
||||||
public IEnumerable<DiscordNotificationDto>? Items { get; set; }
|
|
||||||
}
|
|
@ -1,8 +0,0 @@
|
|||||||
using Newsbot.Collector.Domain.Dto;
|
|
||||||
|
|
||||||
namespace Newsbot.Collector.Domain.Results;
|
|
||||||
|
|
||||||
public class DiscordWebhookResult : BaseResult
|
|
||||||
{
|
|
||||||
public List<DiscordWebHookDto>? Items { get; set; }
|
|
||||||
}
|
|
@ -11,14 +11,11 @@
|
|||||||
<PrivateAssets>all</PrivateAssets>
|
<PrivateAssets>all</PrivateAssets>
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
<PackageReference Include="Microsoft.IdentityModel.JsonWebTokens" Version="6.15.1" />
|
|
||||||
<PackageReference Include="Microsoft.IdentityModel.Tokens" Version="6.15.1" />
|
|
||||||
<PackageReference Include="Selenium.WebDriver" Version="4.8.1" />
|
<PackageReference Include="Selenium.WebDriver" Version="4.8.1" />
|
||||||
<PackageReference Include="Selenium.WebDriver.GeckoDriver" Version="0.32.2" />
|
<PackageReference Include="Selenium.WebDriver.GeckoDriver" Version="0.32.2" />
|
||||||
<PackageReference Include="Serilog" Version="2.12.0" />
|
<PackageReference Include="Serilog" Version="2.12.0" />
|
||||||
<PackageReference Include="Serilog.Sinks.Console" Version="4.1.0" />
|
<PackageReference Include="Serilog.Sinks.Console" Version="4.1.0" />
|
||||||
<PackageReference Include="Serilog.Sinks.OpenTelemetry" Version="1.0.0-dev-00113" />
|
<PackageReference Include="Serilog.Sinks.OpenTelemetry" Version="1.0.0-dev-00113" />
|
||||||
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="6.15.1" />
|
|
||||||
<PackageReference Include="System.ServiceModel.Syndication" Version="7.0.0" />
|
<PackageReference Include="System.ServiceModel.Syndication" Version="7.0.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
@ -26,8 +23,6 @@
|
|||||||
<TargetFramework>net7.0</TargetFramework>
|
<TargetFramework>net7.0</TargetFramework>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
|
|
||||||
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
|
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
Loading…
Reference in New Issue
Block a user