Compare commits
105 Commits
features/c
...
main
Author | SHA1 | Date | |
---|---|---|---|
d1408ce6a4 | |||
bb6d36cfd8 | |||
ff272ab146 | |||
97fc34481c | |||
338edf8d4e | |||
22e9638f88 | |||
3e1a8e8419 | |||
bd05c45e6e | |||
a89c80ed3c | |||
7c88967f7f | |||
a3085bb27f | |||
751bbd3a7b | |||
2aa14548aa | |||
0d751cc571 | |||
56a655e4f1 | |||
2ea971af54 | |||
dcb81315bf | |||
06427d53f3 | |||
82dea60126 | |||
c92d13797f | |||
463cb893e8 | |||
a416746269 | |||
7344d2bdd2 | |||
19d8e3e925 | |||
fa14562fd4 | |||
2bc99afe63 | |||
5df2996947 | |||
7b24ba16f7 | |||
d7242c12c8 | |||
9b86f9e84d | |||
83203f967d | |||
5b8f0beb6e | |||
3697093df1 | |||
c4a84e9adc | |||
64f167c0c5 | |||
16e63aa4a1 | |||
b9c07eda7d | |||
2bc20fccc8 | |||
71319c05ef | |||
bc79b507ac | |||
d5278a8be9 | |||
0aa6c1489d | |||
712ce4f4da | |||
5c06865b1f | |||
558f9d352c | |||
4cacc03fb8 | |||
226a4876ff | |||
59d3306364 | |||
788124dfa0 | |||
6af7fb75be | |||
42258ec56f | |||
df348bea5a | |||
008d79cf3d | |||
fd60906a20 | |||
d28ad7424f | |||
597470fd69 | |||
58229b1348 | |||
7b1407c2cb | |||
9e2b44df7c | |||
3f4de34115 | |||
06218af516 | |||
dff5556e06 | |||
f081a59229 | |||
f388d642be | |||
9d5c5903bd | |||
d15ae49ff8 | |||
bfd185906c | |||
c25cafb0a7 | |||
1aeb96db5b | |||
3b9f1bb707 | |||
f92480e717 | |||
52e86c01ce | |||
54155bfc3f | |||
3c302d2f0e | |||
d6e6527091 | |||
b4b09b0e27 | |||
aa5296d084 | |||
4720c23915 | |||
d286c4fd9a | |||
49342a8c39 | |||
c2b0f47d1c | |||
0797fb8502 | |||
2c886d22ad | |||
0b68261181 | |||
f2995ff156 | |||
a6ea89be62 | |||
7d176cb643 | |||
3e3da9027f | |||
4f46247d0c | |||
731b2cf9b7 | |||
a343fa2d7f | |||
ae8b0266e5 | |||
bb8b3c4b74 | |||
79c4da89e4 | |||
eeb6327046 | |||
d2a5d2ed81 | |||
8149ce2151 | |||
7cae2600ec | |||
557e5d757c | |||
67911d2a65 | |||
0d61cdf268 | |||
1257e8b166 | |||
c36dad769c | |||
a89162d130 | |||
1e8c489df7 |
@ -1,3 +1,4 @@
|
|||||||
appsettings.json
|
appsettings.json
|
||||||
**/bin/
|
**/bin/**
|
||||||
**/obj/
|
**/obj/**
|
||||||
|
**/efbundle
|
42
.drone.yml
42
.drone.yml
@ -1,29 +1,53 @@
|
|||||||
---
|
---
|
||||||
kind: pipeline
|
kind: pipeline
|
||||||
type: docker
|
type: docker
|
||||||
name: build
|
name: buildLatestImage
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: build image
|
- name: buildLatestImage
|
||||||
image: plugins/docker
|
image: plugins/docker
|
||||||
settings:
|
settings:
|
||||||
repo: 192.168.1.196:5000/jtom38/newsbot-collector
|
repo: jtom38/newsbot-collector
|
||||||
registry: 192.168.1.196:5000
|
username: jtom38
|
||||||
insecure: true
|
password:
|
||||||
tags:
|
from_secret: DockerPushPat
|
||||||
- latest
|
|
||||||
trigger:
|
trigger:
|
||||||
branch:
|
branch:
|
||||||
include:
|
include:
|
||||||
- master
|
- main
|
||||||
|
|
||||||
|
event:
|
||||||
|
exclude:
|
||||||
|
- pull_request
|
||||||
|
---
|
||||||
|
kind: pipeline
|
||||||
|
type: docker
|
||||||
|
name: buildReleaseImage
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: buildReleaseImage
|
||||||
|
image: plugins/docker
|
||||||
|
settings:
|
||||||
|
repo: jtom38/newsbot-collector
|
||||||
|
username: jtom38
|
||||||
|
password:
|
||||||
|
from_secret: DockerPushPat
|
||||||
|
trigger:
|
||||||
|
branch:
|
||||||
|
include:
|
||||||
|
- releases/*
|
||||||
|
ref:
|
||||||
|
include:
|
||||||
|
- refs/tags/**
|
||||||
event:
|
event:
|
||||||
exclude:
|
exclude:
|
||||||
- pull_request
|
- pull_request
|
||||||
|
|
||||||
|
|
||||||
---
|
---
|
||||||
kind: pipeline
|
kind: pipeline
|
||||||
type: docker
|
type: docker
|
||||||
name: compile
|
name: PullRequestCompileTest
|
||||||
steps:
|
steps:
|
||||||
- name: Compile project
|
- name: Compile project
|
||||||
image: mcr.microsoft.com/dotnet/sdk:7.0.103
|
image: mcr.microsoft.com/dotnet/sdk:7.0.103
|
||||||
|
2
.gitignore
vendored
2
.gitignore
vendored
@ -4,6 +4,8 @@
|
|||||||
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
|
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
|
||||||
|
|
||||||
seed.secrects.json
|
seed.secrects.json
|
||||||
|
efbundle
|
||||||
|
efbundle.exe
|
||||||
out/
|
out/
|
||||||
|
|
||||||
#Docker Compose Secrets
|
#Docker Compose Secrets
|
||||||
|
15
Dockerfile
15
Dockerfile
@ -1,6 +1,6 @@
|
|||||||
FROM golang:latest as goose
|
#FROM golang:latest as goose
|
||||||
|
|
||||||
RUN go install github.com/pressly/goose/v3/cmd/goose@latest
|
#RUN go install github.com/pressly/goose/v3/cmd/goose@latest
|
||||||
|
|
||||||
FROM mcr.microsoft.com/dotnet/sdk:7.0.103 as build
|
FROM mcr.microsoft.com/dotnet/sdk:7.0.103 as build
|
||||||
|
|
||||||
@ -14,21 +14,20 @@ FROM build AS publish
|
|||||||
RUN dotnet publish -c Release -o /app/publish
|
RUN dotnet publish -c Release -o /app/publish
|
||||||
|
|
||||||
RUN dotnet publish -o build
|
RUN dotnet publish -o build
|
||||||
#--self-contained true -p:PublishSingleFile=true -p:IncludeNativeLibrariesForSelfExtract=true
|
|
||||||
RUN ls build
|
RUN ls build
|
||||||
|
|
||||||
|
FROM build as ef
|
||||||
|
RUN dotnet tool install dotnet-ef --tool-path /usr/bin --version 7.0.8
|
||||||
|
RUN dotnet ef migrations bundle --project "Newsbot.Collector.Database" --force
|
||||||
|
|
||||||
FROM mcr.microsoft.com/dotnet/aspnet:7.0.3 as app
|
FROM mcr.microsoft.com/dotnet/aspnet:7.0.3 as app
|
||||||
|
|
||||||
ENV ASPNETCORE_URLS=http://*:5000
|
ENV ASPNETCORE_URLS=http://*:5000
|
||||||
ENV DOTNET_URLS=http://*:5000
|
ENV DOTNET_URLS=http://*:5000
|
||||||
|
|
||||||
#RUN apt-get install chromium -y
|
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
RUN mkdir /migrations
|
|
||||||
COPY --from=publish /app/build /app
|
COPY --from=publish /app/build /app
|
||||||
COPY --from=build ./app/Newsbot.Collector.Database/Migrations /app/migrations
|
COPY --from=ef /app/efbundle /app
|
||||||
COPY --from=goose /go/bin/goose /app
|
|
||||||
|
|
||||||
CMD [ "dotnet", "Newsbot.Collector.Api.dll" ]
|
CMD [ "dotnet", "Newsbot.Collector.Api.dll" ]
|
@ -1,58 +0,0 @@
|
|||||||
using Microsoft.AspNetCore.Mvc;
|
|
||||||
using Microsoft.Extensions.Options;
|
|
||||||
using Newsbot.Collector.Database.Repositories;
|
|
||||||
using Newsbot.Collector.Domain.Dto;
|
|
||||||
using Newsbot.Collector.Domain.Interfaces;
|
|
||||||
using Newsbot.Collector.Domain.Models;
|
|
||||||
|
|
||||||
namespace Newsbot.Collector.Api.Controllers;
|
|
||||||
|
|
||||||
[ApiController]
|
|
||||||
[Route("api/articles")]
|
|
||||||
public class ArticlesController : ControllerBase
|
|
||||||
{
|
|
||||||
private readonly IArticlesRepository _articles;
|
|
||||||
private readonly ILogger<ArticlesController> _logger;
|
|
||||||
private readonly ISourcesRepository _sources;
|
|
||||||
|
|
||||||
public ArticlesController(ILogger<ArticlesController> logger, IOptions<ConnectionStrings> settings)
|
|
||||||
{
|
|
||||||
_logger = logger;
|
|
||||||
_articles = new ArticlesTable(settings.Value.Database);
|
|
||||||
_sources = new SourcesTable(settings.Value.Database);
|
|
||||||
}
|
|
||||||
|
|
||||||
[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;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,90 +0,0 @@
|
|||||||
using System.Net;
|
|
||||||
using Microsoft.AspNetCore.Mvc;
|
|
||||||
using Microsoft.Extensions.Options;
|
|
||||||
using Newsbot.Collector.Database.Repositories;
|
|
||||||
using Newsbot.Collector.Domain.Dto;
|
|
||||||
using Newsbot.Collector.Domain.Interfaces;
|
|
||||||
using Newsbot.Collector.Domain.Models;
|
|
||||||
|
|
||||||
namespace Newsbot.Collector.Api.Controllers;
|
|
||||||
|
|
||||||
[ApiController]
|
|
||||||
[Route("api/discord/webhooks")]
|
|
||||||
public class DiscordWebHookController : ControllerBase
|
|
||||||
{
|
|
||||||
private readonly ILogger<DiscordWebHookController> _logger;
|
|
||||||
private readonly ConnectionStrings _settings;
|
|
||||||
private readonly IDiscordWebHooksRepository _webhooks;
|
|
||||||
|
|
||||||
public DiscordWebHookController(ILogger<DiscordWebHookController> logger, IOptions<ConnectionStrings> settings)
|
|
||||||
{
|
|
||||||
_logger = logger;
|
|
||||||
_settings = settings.Value;
|
|
||||||
_webhooks = new DiscordWebhooksTable(_settings.Database);
|
|
||||||
}
|
|
||||||
|
|
||||||
[HttpGet(Name = "GetDiscordWebhooks")]
|
|
||||||
public IEnumerable<DiscordWebHookDto> Get(int page)
|
|
||||||
{
|
|
||||||
var items = new List<DiscordWebHookDto>();
|
|
||||||
var res = _webhooks.List(page);
|
|
||||||
foreach (var item in res)
|
|
||||||
{
|
|
||||||
items.Add(DiscordWebHookDto.Convert(item));
|
|
||||||
}
|
|
||||||
return items;
|
|
||||||
}
|
|
||||||
|
|
||||||
[HttpPost(Name = "New")]
|
|
||||||
public DiscordWebHookDto New(string url, string server, string channel)
|
|
||||||
{
|
|
||||||
var exists = _webhooks.GetByUrl(url);
|
|
||||||
// ReSharper disable once ConditionIsAlwaysTrueOrFalseAccordingToNullableAPIContract
|
|
||||||
if (exists.ID != Guid.Empty)
|
|
||||||
{
|
|
||||||
return DiscordWebHookDto.Convert(exists);
|
|
||||||
}
|
|
||||||
|
|
||||||
var res = _webhooks.New(new DiscordWebHookModel
|
|
||||||
{
|
|
||||||
Url = url,
|
|
||||||
Server = server,
|
|
||||||
Channel = channel,
|
|
||||||
Enabled = true,
|
|
||||||
});
|
|
||||||
|
|
||||||
return DiscordWebHookDto.Convert(res);
|
|
||||||
}
|
|
||||||
|
|
||||||
[HttpGet("by/serverAndChannel")]
|
|
||||||
public IEnumerable<DiscordWebHookDto> GetByServerAndChannel(string server, string channel)
|
|
||||||
{
|
|
||||||
var items = new List<DiscordWebHookDto>();
|
|
||||||
var res = _webhooks.ListByServerAndChannel(server, channel, 25);
|
|
||||||
|
|
||||||
foreach (var item in res)
|
|
||||||
{
|
|
||||||
items.Add(DiscordWebHookDto.Convert(item));
|
|
||||||
}
|
|
||||||
return items;
|
|
||||||
}
|
|
||||||
|
|
||||||
[HttpGet("{id}")]
|
|
||||||
public DiscordWebHookDto GetById(Guid id)
|
|
||||||
{
|
|
||||||
var res = _webhooks.GetByID(id);
|
|
||||||
return DiscordWebHookDto.Convert(res);
|
|
||||||
}
|
|
||||||
|
|
||||||
[HttpPost("{id}/disable")]
|
|
||||||
public void DisableById(Guid id)
|
|
||||||
{
|
|
||||||
_webhooks.Disable(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
[HttpPost("{id}/enable")]
|
|
||||||
public void EnableById(Guid id)
|
|
||||||
{
|
|
||||||
_webhooks.Enable(id);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,129 +0,0 @@
|
|||||||
using Microsoft.AspNetCore.Mvc;
|
|
||||||
using Microsoft.Extensions.Options;
|
|
||||||
using Newsbot.Collector.Database.Repositories;
|
|
||||||
using Newsbot.Collector.Domain.Dto;
|
|
||||||
using Newsbot.Collector.Domain.Interfaces;
|
|
||||||
using Newsbot.Collector.Domain.Models;
|
|
||||||
|
|
||||||
namespace Newsbot.Collector.Api.Controllers;
|
|
||||||
|
|
||||||
[ApiController]
|
|
||||||
[Route("api/subscriptions")]
|
|
||||||
public class SubscriptionsController : ControllerBase
|
|
||||||
{
|
|
||||||
private readonly IDiscordWebHooksRepository _discord;
|
|
||||||
private readonly ILogger<SubscriptionsController> _logger;
|
|
||||||
private readonly ISourcesRepository _sources;
|
|
||||||
private readonly ISubscriptionRepository _subscription;
|
|
||||||
|
|
||||||
public SubscriptionsController(ILogger<SubscriptionsController> logger, IOptions<ConnectionStrings> settings)
|
|
||||||
{
|
|
||||||
_logger = logger;
|
|
||||||
_subscription = new SubscriptionsTable(settings.Value.Database);
|
|
||||||
_discord = new DiscordWebhooksTable(settings.Value.Database);
|
|
||||||
_sources = new SourcesTable(settings.Value.Database);
|
|
||||||
}
|
|
||||||
|
|
||||||
[HttpGet(Name = "ListSubscriptions")]
|
|
||||||
public IEnumerable<SubscriptionDto> List(int page)
|
|
||||||
{
|
|
||||||
var res = new List<SubscriptionDto>();
|
|
||||||
var items = _subscription.List(page);
|
|
||||||
foreach (var item in items) res.Add(SubscriptionDto.Convert(item));
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
[HttpGet("{id}")]
|
|
||||||
public SubscriptionDto GetById(Guid id)
|
|
||||||
{
|
|
||||||
return SubscriptionDto.Convert(_subscription.GetById(id));
|
|
||||||
}
|
|
||||||
|
|
||||||
[HttpGet("{id}/details")]
|
|
||||||
public SubscriptionDetailsDto GetDetailsById(Guid id)
|
|
||||||
{
|
|
||||||
var sub = _subscription.GetById(id);
|
|
||||||
var webhook = _discord.GetByID(sub.DiscordWebHookId);
|
|
||||||
var source = _sources.GetByID(sub.SourceId);
|
|
||||||
|
|
||||||
return SubscriptionDetailsDto.Convert(sub, source, webhook);
|
|
||||||
}
|
|
||||||
|
|
||||||
[HttpPost("{id}/delete")]
|
|
||||||
public void DeleteById(Guid id)
|
|
||||||
{
|
|
||||||
_subscription.Delete(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
[HttpGet("by/discordid/{id}")]
|
|
||||||
public IEnumerable<SubscriptionDto> GetByDiscordId(Guid id)
|
|
||||||
{
|
|
||||||
var res = new List<SubscriptionDto>();
|
|
||||||
var items = _subscription.ListByWebhook(id);
|
|
||||||
foreach (var item in items) res.Add(SubscriptionDto.Convert(item));
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
[HttpGet("by/sourceId/{id}")]
|
|
||||||
public IEnumerable<SubscriptionDto> GetBySourceId(Guid id)
|
|
||||||
{
|
|
||||||
var res = new List<SubscriptionDto>();
|
|
||||||
var items = _subscription.ListBySourceID(id);
|
|
||||||
foreach (var item in items) res.Add(SubscriptionDto.Convert(item));
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
[HttpPost(Name = "New Subscription")]
|
|
||||||
public ActionResult<SubscriptionDto> New(Guid sourceId, Guid discordId)
|
|
||||||
{
|
|
||||||
if (sourceId == Guid.Empty) return new BadRequestResult();
|
|
||||||
if (discordId == Guid.Empty) return new BadRequestResult();
|
|
||||||
|
|
||||||
var exists = _subscription.GetByWebhookAndSource(discordId, sourceId);
|
|
||||||
if (exists.Id != Guid.Empty) return SubscriptionDto.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 = _subscription.New(new SubscriptionModel
|
|
||||||
{
|
|
||||||
Id = Guid.NewGuid(),
|
|
||||||
SourceId = sourceId,
|
|
||||||
DiscordWebHookId = discordId,
|
|
||||||
CodeAllowCommits = false,
|
|
||||||
CodeAllowReleases = false
|
|
||||||
});
|
|
||||||
|
|
||||||
return SubscriptionDto.Convert(item);
|
|
||||||
}
|
|
||||||
|
|
||||||
[HttpPost("new/codeproject")]
|
|
||||||
public ActionResult<SubscriptionDto> 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 = _subscription.GetByWebhookAndSource(discordId, sourceId);
|
|
||||||
if (exists.Id != Guid.Empty) return SubscriptionDto.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 = _subscription.New(new SubscriptionModel
|
|
||||||
{
|
|
||||||
DiscordWebHookId = discordId,
|
|
||||||
SourceId = sourceId,
|
|
||||||
CodeAllowCommits = allowCommits,
|
|
||||||
CodeAllowReleases = allowReleases
|
|
||||||
});
|
|
||||||
|
|
||||||
return new SubscriptionDto();
|
|
||||||
}
|
|
||||||
}
|
|
89
Newsbot.Collector.Api/Controllers/v1/ArticlesController.cs
Normal file
89
Newsbot.Collector.Api/Controllers/v1/ArticlesController.cs
Normal file
@ -0,0 +1,89 @@
|
|||||||
|
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;
|
||||||
|
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;
|
||||||
|
private readonly IAuthorTable _author;
|
||||||
|
|
||||||
|
public ArticlesController(IArticlesRepository articles, ISourcesRepository sources, IAuthorTable author)
|
||||||
|
{
|
||||||
|
_articles = articles;
|
||||||
|
_sources = sources;
|
||||||
|
_author = author;
|
||||||
|
}
|
||||||
|
|
||||||
|
[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);
|
||||||
|
var author = _author.GetBySourceIdAndNameAsync(sourceItem.Id, sourceItem.Name);
|
||||||
|
author.Wait();
|
||||||
|
|
||||||
|
return new OkObjectResult(new ArticleDetailsResult
|
||||||
|
{
|
||||||
|
IsSuccessful = true,
|
||||||
|
Item = ArticleDetailsDto.Convert(item, sourceItem, author.Result)
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
[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,13 +1,17 @@
|
|||||||
using Hangfire;
|
using Hangfire;
|
||||||
|
using Microsoft.AspNetCore.Authentication.JwtBearer;
|
||||||
|
using Microsoft.AspNetCore.Authorization;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.Extensions.Options;
|
using Microsoft.Extensions.Options;
|
||||||
|
using Newsbot.Collector.Api.Domain.Consts;
|
||||||
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;
|
namespace Newsbot.Collector.Api.Controllers.v1;
|
||||||
|
|
||||||
[ApiController]
|
[ApiController]
|
||||||
[Route("api/codeprojects")]
|
[Route("api/v1/codeprojects")]
|
||||||
|
[Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme)]
|
||||||
public class CodeProjectController
|
public class CodeProjectController
|
||||||
{
|
{
|
||||||
private readonly ConfigSectionConnectionStrings _connectionStrings;
|
private readonly ConfigSectionConnectionStrings _connectionStrings;
|
||||||
@ -21,7 +25,8 @@ public class CodeProjectController
|
|||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost("check")]
|
[HttpPost("check")]
|
||||||
public void PullNow()
|
[Authorize(Roles = Authorization.AdministratorsRole)]
|
||||||
|
public ActionResult PullNow()
|
||||||
{
|
{
|
||||||
BackgroundJob.Enqueue<CodeProjectWatcherJob>(x => x.InitAndExecute(new CodeProjectWatcherJobOptions
|
BackgroundJob.Enqueue<CodeProjectWatcherJob>(x => x.InitAndExecute(new CodeProjectWatcherJobOptions
|
||||||
{
|
{
|
||||||
@ -29,5 +34,7 @@ public class CodeProjectController
|
|||||||
FeaturePullReleases = true,
|
FeaturePullReleases = true,
|
||||||
FeaturePullCommits = true
|
FeaturePullCommits = true
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
return new AcceptedResult();
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -0,0 +1,239 @@
|
|||||||
|
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) }
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,114 @@
|
|||||||
|
using Microsoft.AspNetCore.Authentication.JwtBearer;
|
||||||
|
using Microsoft.AspNetCore.Authorization;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using Microsoft.Extensions.Options;
|
||||||
|
using Newsbot.Collector.Api.Middleware;
|
||||||
|
using Newsbot.Collector.Domain.Dto;
|
||||||
|
using Newsbot.Collector.Domain.Entities;
|
||||||
|
using Newsbot.Collector.Domain.Interfaces;
|
||||||
|
using Newsbot.Collector.Domain.Models;
|
||||||
|
using Newsbot.Collector.Domain.Requests;
|
||||||
|
using Newsbot.Collector.Domain.Results;
|
||||||
|
|
||||||
|
namespace Newsbot.Collector.Api.Controllers.v1;
|
||||||
|
|
||||||
|
[ApiController]
|
||||||
|
[Route("api/v1/discord/webhooks")]
|
||||||
|
[Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme)]
|
||||||
|
public class DiscordWebHookController : ControllerBase
|
||||||
|
{
|
||||||
|
private readonly ILogger<DiscordWebHookController> _logger;
|
||||||
|
private readonly IDiscordWebHooksRepository _webhooks;
|
||||||
|
|
||||||
|
public DiscordWebHookController(ILogger<DiscordWebHookController> logger, IOptions<ConnectionStrings> settings, IDiscordWebHooksRepository webhooks)
|
||||||
|
{
|
||||||
|
_logger = logger;
|
||||||
|
_webhooks = webhooks;
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet(Name = "GetDiscordWebhooks")]
|
||||||
|
public ActionResult<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 res = _webhooks.ListByUserId(userId, page);
|
||||||
|
foreach (var item in res)
|
||||||
|
{
|
||||||
|
items.Add(DiscordWebHookDto.Convert(item));
|
||||||
|
}
|
||||||
|
|
||||||
|
return new OkObjectResult(items);
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPost(Name = "New")]
|
||||||
|
public ActionResult<DiscordWebhookResult> New([FromBody] NewDiscordWebhookRequest request)
|
||||||
|
{
|
||||||
|
var userId = HttpContext.GetUserId();
|
||||||
|
|
||||||
|
var exists = _webhooks.GetByUrl(request.Url ?? "");
|
||||||
|
if (exists.Id != Guid.Empty)
|
||||||
|
{
|
||||||
|
return new BadRequestObjectResult(new DiscordWebhookResult
|
||||||
|
{
|
||||||
|
IsSuccessful = true,
|
||||||
|
Items = new List<DiscordWebHookDto> { DiscordWebHookDto.Convert(exists) }
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
var res = _webhooks.New(new DiscordWebhookEntity
|
||||||
|
{
|
||||||
|
UserId = userId,
|
||||||
|
Url = request.Url ?? "",
|
||||||
|
Server = request.Server ?? "",
|
||||||
|
Channel = request.Channel ?? "",
|
||||||
|
Enabled = true,
|
||||||
|
});
|
||||||
|
|
||||||
|
return new OkObjectResult(new DiscordWebhookResult
|
||||||
|
{
|
||||||
|
IsSuccessful = true,
|
||||||
|
Items = new List<DiscordWebHookDto>
|
||||||
|
{
|
||||||
|
DiscordWebHookDto.Convert(res)
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet("by/serverAndChannel")]
|
||||||
|
public IEnumerable<DiscordWebHookDto> GetByServerAndChannel(string server, string channel)
|
||||||
|
{
|
||||||
|
var items = new List<DiscordWebHookDto>();
|
||||||
|
var res = _webhooks.ListByServerAndChannel(HttpContext.GetUserId(), server, channel, 25);
|
||||||
|
|
||||||
|
foreach (var item in res)
|
||||||
|
{
|
||||||
|
items.Add(DiscordWebHookDto.Convert(item));
|
||||||
|
}
|
||||||
|
return items;
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet("{id}")]
|
||||||
|
public DiscordWebHookDto GetById(string userId, Guid id)
|
||||||
|
{
|
||||||
|
var res = _webhooks.GetById(userId, id);
|
||||||
|
return DiscordWebHookDto.Convert(res);
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPost("{id}/disable")]
|
||||||
|
public void DisableById(Guid id)
|
||||||
|
{
|
||||||
|
_webhooks.Disable(HttpContext.GetUserId(), id);
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPost("{id}/enable")]
|
||||||
|
public void EnableById(Guid id)
|
||||||
|
{
|
||||||
|
_webhooks.Enable(HttpContext.GetUserId(), id);
|
||||||
|
}
|
||||||
|
}
|
107
Newsbot.Collector.Api/Controllers/v1/IdentityController.cs
Normal file
107
Newsbot.Collector.Api/Controllers/v1/IdentityController.cs
Normal file
@ -0,0 +1,107 @@
|
|||||||
|
using Microsoft.AspNetCore.Authorization;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using Newsbot.Collector.Api.Domain.Consts;
|
||||||
|
using Newsbot.Collector.Domain.Requests;
|
||||||
|
using Newsbot.Collector.Domain.Response;
|
||||||
|
using Newsbot.Collector.Domain.Results;
|
||||||
|
using Newsbot.Collector.Services;
|
||||||
|
|
||||||
|
namespace Newsbot.Collector.Api.Controllers.v1;
|
||||||
|
|
||||||
|
[ApiController]
|
||||||
|
[Route("/api/v1/account")]
|
||||||
|
public class IdentityController : ControllerBase
|
||||||
|
{
|
||||||
|
private readonly ILogger<IdentityController> _logger;
|
||||||
|
private readonly IIdentityService _identityService;
|
||||||
|
|
||||||
|
public IdentityController(IIdentityService identityService, ILogger<IdentityController> logger)
|
||||||
|
{
|
||||||
|
_identityService = identityService;
|
||||||
|
_logger = logger;
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPost("register")]
|
||||||
|
public IActionResult Register([FromBody] RegisterUserRequest user)
|
||||||
|
{
|
||||||
|
if (!ModelState.IsValid)
|
||||||
|
{
|
||||||
|
return new BadRequestObjectResult(new AuthFailedResponse
|
||||||
|
{
|
||||||
|
Errors = ModelState.Values
|
||||||
|
.Select(x => x.Errors
|
||||||
|
.Select(y => y.ErrorMessage).FirstOrDefault())
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (user.Email is null)
|
||||||
|
{
|
||||||
|
return new BadRequestResult();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (user.Password is null)
|
||||||
|
{
|
||||||
|
return new BadRequestResult();
|
||||||
|
}
|
||||||
|
|
||||||
|
var response = _identityService.Register(user.Email, user.Password);
|
||||||
|
return CheckIfSuccessful(response);
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPost("login")]
|
||||||
|
public IActionResult Login([FromBody] UserLoginRequest request)
|
||||||
|
{
|
||||||
|
if (request.Email is null)
|
||||||
|
{
|
||||||
|
return new BadRequestResult();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (request.Password is null)
|
||||||
|
{
|
||||||
|
return new BadRequestResult();
|
||||||
|
}
|
||||||
|
|
||||||
|
var response = _identityService.Login(request.Email, request.Password);
|
||||||
|
return CheckIfSuccessful(response);
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPost("refresh")]
|
||||||
|
public ActionResult RefreshToken([FromBody] UserRefreshTokenRequest request)
|
||||||
|
{
|
||||||
|
var response = _identityService.RefreshToken(request.Token ?? "", request.RefreshToken ?? "");
|
||||||
|
return CheckIfSuccessful(response);
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPost("addRole")]
|
||||||
|
[Authorize(Roles = Authorization.AdministratorsRole)]
|
||||||
|
public ActionResult AddRole([FromBody] AddRoleRequest request)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_identityService.AddRole(request.RoleName ?? "", request.UserId ?? "");
|
||||||
|
return new OkResult();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogWarning(ex, "Failed to add role to user");
|
||||||
|
return new BadRequestResult();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private ActionResult CheckIfSuccessful(AuthenticationResult result)
|
||||||
|
{
|
||||||
|
if (!result.IsSuccessful)
|
||||||
|
{
|
||||||
|
return new BadRequestObjectResult( new AuthFailedResponse
|
||||||
|
{
|
||||||
|
Errors = result.ErrorMessage
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return new OkObjectResult(new AuthSuccessfulResponse
|
||||||
|
{
|
||||||
|
Token = result.Token,
|
||||||
|
RefreshToken = result.RefreshToken
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
@ -1,13 +1,18 @@
|
|||||||
using Hangfire;
|
using Hangfire;
|
||||||
|
using Microsoft.AspNetCore.Authentication.JwtBearer;
|
||||||
|
using Microsoft.AspNetCore.Authorization;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.Extensions.Options;
|
using Microsoft.Extensions.Options;
|
||||||
|
using Newsbot.Collector.Api.Domain.Consts;
|
||||||
using Newsbot.Collector.Domain.Models.Config;
|
using Newsbot.Collector.Domain.Models.Config;
|
||||||
|
using Newsbot.Collector.Domain.Models.Config.Sources;
|
||||||
using Newsbot.Collector.Services.Jobs;
|
using Newsbot.Collector.Services.Jobs;
|
||||||
|
|
||||||
namespace Newsbot.Collector.Api.Controllers;
|
namespace Newsbot.Collector.Api.Controllers.v1;
|
||||||
|
|
||||||
[ApiController]
|
[ApiController]
|
||||||
[Route("api/rss")]
|
[Route("api/v1/rss")]
|
||||||
|
[Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme)]
|
||||||
public class RssController
|
public class RssController
|
||||||
{
|
{
|
||||||
private readonly ConfigSectionConnectionStrings _connectionStrings;
|
private readonly ConfigSectionConnectionStrings _connectionStrings;
|
||||||
@ -23,6 +28,7 @@ public class RssController
|
|||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost("check")]
|
[HttpPost("check")]
|
||||||
|
[Authorize(Roles = Authorization.AdministratorsRole)]
|
||||||
public void CheckReddit()
|
public void CheckReddit()
|
||||||
{
|
{
|
||||||
BackgroundJob.Enqueue<RssWatcherJob>(x => x.InitAndExecute(new RssWatcherJobOptions
|
BackgroundJob.Enqueue<RssWatcherJob>(x => x.InitAndExecute(new RssWatcherJobOptions
|
@ -1,32 +1,29 @@
|
|||||||
|
using Microsoft.AspNetCore.Authentication.JwtBearer;
|
||||||
|
using Microsoft.AspNetCore.Authorization;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.Extensions.Options;
|
using Newsbot.Collector.Api.Domain.Consts;
|
||||||
using Newsbot.Collector.Database.Repositories;
|
|
||||||
using Newsbot.Collector.Domain.Consts;
|
using Newsbot.Collector.Domain.Consts;
|
||||||
using Newsbot.Collector.Domain.Dto;
|
using Newsbot.Collector.Domain.Dto;
|
||||||
|
using Newsbot.Collector.Domain.Entities;
|
||||||
using Newsbot.Collector.Domain.Interfaces;
|
using Newsbot.Collector.Domain.Interfaces;
|
||||||
using Newsbot.Collector.Domain.Models;
|
|
||||||
using Newsbot.Collector.Services.HtmlParser;
|
using Newsbot.Collector.Services.HtmlParser;
|
||||||
|
|
||||||
namespace Newsbot.Collector.Api.Controllers;
|
namespace Newsbot.Collector.Api.Controllers.v1;
|
||||||
|
|
||||||
[ApiController]
|
[ApiController]
|
||||||
[Route("api/sources")]
|
[Route("api/sources")]
|
||||||
|
[Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme)]
|
||||||
public class SourcesController : ControllerBase
|
public class SourcesController : ControllerBase
|
||||||
{
|
{
|
||||||
private readonly IArticlesRepository _articles;
|
|
||||||
|
|
||||||
//private readonly ConnectionStrings _settings;
|
|
||||||
private readonly IIconsRepository _icons;
|
|
||||||
private readonly ILogger<SourcesController> _logger;
|
private readonly ILogger<SourcesController> _logger;
|
||||||
|
private readonly IIconsRepository _icons;
|
||||||
private readonly ISourcesRepository _sources;
|
private readonly ISourcesRepository _sources;
|
||||||
|
|
||||||
public SourcesController(ILogger<SourcesController> logger, IOptions<ConnectionStrings> settings)
|
public SourcesController(ILogger<SourcesController> logger, IIconsRepository icons, ISourcesRepository sources)
|
||||||
{
|
{
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
//_settings = settings.Value;
|
_icons = icons;
|
||||||
_sources = new SourcesTable(settings.Value.Database);
|
_sources = sources;
|
||||||
_icons = new IconsTable(settings.Value.Database);
|
|
||||||
_articles = new ArticlesTable(settings.Value.Database);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet(Name = "GetSources")]
|
[HttpGet(Name = "GetSources")]
|
||||||
@ -39,10 +36,10 @@ public class SourcesController : ControllerBase
|
|||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet("by/type")]
|
[HttpGet("by/type")]
|
||||||
public IEnumerable<SourceDto> GetByType(string type)
|
public IEnumerable<SourceDto> GetByType(string type, int page)
|
||||||
{
|
{
|
||||||
var res = new List<SourceDto>();
|
var res = new List<SourceDto>();
|
||||||
var temp = _sources.ListByType(type);
|
var temp = _sources.ListByType(type, page);
|
||||||
foreach (var item in temp) res.Add(SourceDto.Convert(item));
|
foreach (var item in temp) res.Add(SourceDto.Convert(item));
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
@ -51,7 +48,7 @@ public class SourcesController : ControllerBase
|
|||||||
public SourceDto NewReddit(string name)
|
public SourceDto NewReddit(string name)
|
||||||
{
|
{
|
||||||
var res = _sources.GetByNameAndType(name, SourceTypes.Reddit);
|
var res = _sources.GetByNameAndType(name, SourceTypes.Reddit);
|
||||||
if (res.ID != Guid.Empty) return SourceDto.Convert(res);
|
if (res.Id != Guid.Empty) return SourceDto.Convert(res);
|
||||||
|
|
||||||
var uri = new Uri($"https://reddit.com/r/{name}");
|
var uri = new Uri($"https://reddit.com/r/{name}");
|
||||||
|
|
||||||
@ -61,7 +58,7 @@ public class SourcesController : ControllerBase
|
|||||||
});
|
});
|
||||||
pageReader.Parse();
|
pageReader.Parse();
|
||||||
|
|
||||||
var item = _sources.New(new SourceModel
|
var item = _sources.New(new SourceEntity
|
||||||
{
|
{
|
||||||
Site = SourceTypes.Reddit,
|
Site = SourceTypes.Reddit,
|
||||||
Name = name,
|
Name = name,
|
||||||
@ -74,11 +71,11 @@ public class SourcesController : ControllerBase
|
|||||||
|
|
||||||
// Not all subreddits have an Icon, so we only want to add a record when it has one.
|
// Not all subreddits have an Icon, so we only want to add a record when it has one.
|
||||||
if (pageReader.Data.Header.Image != "")
|
if (pageReader.Data.Header.Image != "")
|
||||||
_icons.New(new IconModel
|
_icons.New(new IconEntity()
|
||||||
{
|
{
|
||||||
Id = Guid.NewGuid(),
|
Id = Guid.NewGuid(),
|
||||||
FileName = pageReader.Data.Header.Image,
|
FileName = pageReader.Data.Header.Image,
|
||||||
SourceId = item.ID
|
SourceId = item.Id
|
||||||
});
|
});
|
||||||
return SourceDto.Convert(item);
|
return SourceDto.Convert(item);
|
||||||
}
|
}
|
||||||
@ -87,9 +84,9 @@ public class SourcesController : ControllerBase
|
|||||||
public SourceDto NewRss(string name, string url)
|
public SourceDto NewRss(string name, string url)
|
||||||
{
|
{
|
||||||
var res = _sources.GetByNameAndType(name, SourceTypes.Rss);
|
var res = _sources.GetByNameAndType(name, SourceTypes.Rss);
|
||||||
if (res.ID != Guid.Empty) return SourceDto.Convert(res);
|
if (res.Id != Guid.Empty) return SourceDto.Convert(res);
|
||||||
|
|
||||||
var m = new SourceModel
|
var m = new SourceEntity
|
||||||
{
|
{
|
||||||
Site = SourceTypes.Rss,
|
Site = SourceTypes.Rss,
|
||||||
Name = name,
|
Name = name,
|
||||||
@ -107,7 +104,7 @@ public class SourcesController : ControllerBase
|
|||||||
public SourceDto NewYoutube(string url)
|
public SourceDto NewYoutube(string url)
|
||||||
{
|
{
|
||||||
var res = _sources.GetByUrl(url);
|
var res = _sources.GetByUrl(url);
|
||||||
if (res.ID != Guid.Empty) return SourceDto.Convert(res);
|
if (res.Id != Guid.Empty) return SourceDto.Convert(res);
|
||||||
|
|
||||||
var htmlClient = new HtmlPageReader(new HtmlPageReaderOptions
|
var htmlClient = new HtmlPageReader(new HtmlPageReaderOptions
|
||||||
{
|
{
|
||||||
@ -115,7 +112,7 @@ public class SourcesController : ControllerBase
|
|||||||
});
|
});
|
||||||
htmlClient.Parse();
|
htmlClient.Parse();
|
||||||
|
|
||||||
var item = _sources.New(new SourceModel
|
var item = _sources.New(new SourceEntity
|
||||||
{
|
{
|
||||||
Site = SourceTypes.YouTube,
|
Site = SourceTypes.YouTube,
|
||||||
Type = SourceTypes.YouTube,
|
Type = SourceTypes.YouTube,
|
||||||
@ -127,11 +124,11 @@ public class SourcesController : ControllerBase
|
|||||||
YoutubeId = htmlClient.Data.Header.YoutubeChannelID ?? ""
|
YoutubeId = htmlClient.Data.Header.YoutubeChannelID ?? ""
|
||||||
});
|
});
|
||||||
|
|
||||||
_icons.New(new IconModel
|
_icons.New(new IconEntity()
|
||||||
{
|
{
|
||||||
Id = Guid.NewGuid(),
|
Id = Guid.NewGuid(),
|
||||||
FileName = htmlClient.Data.Header.Image,
|
FileName = htmlClient.Data.Header.Image,
|
||||||
SourceId = item.ID
|
SourceId = item.Id
|
||||||
});
|
});
|
||||||
|
|
||||||
return SourceDto.Convert(item);
|
return SourceDto.Convert(item);
|
||||||
@ -141,9 +138,9 @@ public class SourcesController : ControllerBase
|
|||||||
public SourceDto NewTwitch(string name)
|
public SourceDto NewTwitch(string name)
|
||||||
{
|
{
|
||||||
var res = _sources.GetByNameAndType(name, SourceTypes.Twitch);
|
var res = _sources.GetByNameAndType(name, SourceTypes.Twitch);
|
||||||
if (res.ID != Guid.Empty) return SourceDto.Convert(res);
|
if (res.Id != Guid.Empty) return SourceDto.Convert(res);
|
||||||
|
|
||||||
var item = _sources.New(new SourceModel
|
var item = _sources.New(new SourceEntity
|
||||||
{
|
{
|
||||||
Site = SourceTypes.Twitch,
|
Site = SourceTypes.Twitch,
|
||||||
Type = SourceTypes.Twitch,
|
Type = SourceTypes.Twitch,
|
||||||
@ -162,7 +159,7 @@ public class SourcesController : ControllerBase
|
|||||||
//if (!url.Contains("github.com")) return new SourceDto();
|
//if (!url.Contains("github.com")) return new SourceDto();
|
||||||
|
|
||||||
var res = _sources.GetByUrl(url);
|
var res = _sources.GetByUrl(url);
|
||||||
if (res.ID != Guid.Empty) return SourceDto.Convert(res);
|
if (res.Id != Guid.Empty) return SourceDto.Convert(res);
|
||||||
|
|
||||||
var slice = url.Split('/');
|
var slice = url.Split('/');
|
||||||
|
|
||||||
@ -172,7 +169,7 @@ public class SourcesController : ControllerBase
|
|||||||
});
|
});
|
||||||
pageReader.Parse();
|
pageReader.Parse();
|
||||||
|
|
||||||
var item = _sources.New(new SourceModel
|
var item = _sources.New(new SourceEntity
|
||||||
{
|
{
|
||||||
Site = SourceTypes.CodeProject,
|
Site = SourceTypes.CodeProject,
|
||||||
Type = SourceTypes.CodeProject,
|
Type = SourceTypes.CodeProject,
|
||||||
@ -183,11 +180,11 @@ public class SourcesController : ControllerBase
|
|||||||
Tags = $"{slice[2]},{slice[3]},{slice[4]}"
|
Tags = $"{slice[2]},{slice[3]},{slice[4]}"
|
||||||
});
|
});
|
||||||
|
|
||||||
_icons.New(new IconModel
|
_icons.New(new IconEntity()
|
||||||
{
|
{
|
||||||
Id = Guid.NewGuid(),
|
Id = Guid.NewGuid(),
|
||||||
FileName = pageReader.Data.Header.Image,
|
FileName = pageReader.Data.Header.Image,
|
||||||
SourceId = item.ID
|
SourceId = item.Id
|
||||||
});
|
});
|
||||||
|
|
||||||
return SourceDto.Convert(item);
|
return SourceDto.Convert(item);
|
||||||
@ -196,16 +193,18 @@ public class SourcesController : ControllerBase
|
|||||||
[HttpGet("{id}")]
|
[HttpGet("{id}")]
|
||||||
public SourceDto GetById(Guid id)
|
public SourceDto GetById(Guid id)
|
||||||
{
|
{
|
||||||
var item = _sources.GetByID(id);
|
var item = _sources.GetById(id);
|
||||||
return SourceDto.Convert(item);
|
return SourceDto.Convert(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Authorize(Roles = Authorization.AdministratorsRole)]
|
||||||
[HttpPost("{id}/disable")]
|
[HttpPost("{id}/disable")]
|
||||||
public void Disable(Guid id)
|
public void Disable(Guid id)
|
||||||
{
|
{
|
||||||
_sources.Disable(id);
|
_sources.Disable(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Authorize(Roles = Authorization.AdministratorsRole)]
|
||||||
[HttpPost("{id}/enable")]
|
[HttpPost("{id}/enable")]
|
||||||
public void Enable(Guid id)
|
public void Enable(Guid id)
|
||||||
{
|
{
|
||||||
@ -213,6 +212,7 @@ public class SourcesController : ControllerBase
|
|||||||
}
|
}
|
||||||
|
|
||||||
[HttpDelete("{id}")]
|
[HttpDelete("{id}")]
|
||||||
|
[Authorize(Roles = Authorization.AdministratorsRole)]
|
||||||
public void Delete(Guid id, bool purgeOrphanedRecords)
|
public void Delete(Guid id, bool purgeOrphanedRecords)
|
||||||
{
|
{
|
||||||
_sources.Delete(id);
|
_sources.Delete(id);
|
49
Newsbot.Collector.Api/Controllers/v1/UserController.cs
Normal file
49
Newsbot.Collector.Api/Controllers/v1/UserController.cs
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
using Microsoft.AspNetCore.Authentication.JwtBearer;
|
||||||
|
using Microsoft.AspNetCore.Authorization;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using Newsbot.Collector.Api.Authentication;
|
||||||
|
using Newsbot.Collector.Api.Middleware;
|
||||||
|
using Newsbot.Collector.Domain.Entities;
|
||||||
|
using Newsbot.Collector.Domain.Interfaces;
|
||||||
|
|
||||||
|
namespace Newsbot.Collector.Api.Controllers.v1;
|
||||||
|
|
||||||
|
[Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme)]
|
||||||
|
[ApiController]
|
||||||
|
[Route("api/v1/user")]
|
||||||
|
public class UserController : Controller
|
||||||
|
{
|
||||||
|
private readonly ILogger<UserController> _logger;
|
||||||
|
private readonly IUserSourceSubscription _subscription;
|
||||||
|
|
||||||
|
public UserController(ILogger<UserController> logger, IUserSourceSubscription subscription)
|
||||||
|
{
|
||||||
|
_logger = logger;
|
||||||
|
_subscription = subscription;
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPost("listSubscriptions")]
|
||||||
|
public ActionResult ListSubscriptions()
|
||||||
|
{
|
||||||
|
_logger.LogInformation("'/api/v1/user/listSubscriptions' was requested");
|
||||||
|
|
||||||
|
var userId = HttpContext.GetUserId();
|
||||||
|
if (userId.Equals(string.Empty))
|
||||||
|
{
|
||||||
|
_logger.LogWarning("Unable to find the user ID in the JWD Token");
|
||||||
|
return new BadRequestResult();
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var results = _subscription.ListUserSubscriptions(Guid.Parse(userId));
|
||||||
|
return new OkObjectResult(results);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Failed to pull subscriptions for userId \'{UserId}\'", userId);
|
||||||
|
return new NoContentResult();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -1,14 +1,18 @@
|
|||||||
using Hangfire;
|
using Hangfire;
|
||||||
|
using Microsoft.AspNetCore.Authentication.JwtBearer;
|
||||||
|
using Microsoft.AspNetCore.Authorization;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.Extensions.Options;
|
using Microsoft.Extensions.Options;
|
||||||
|
using Newsbot.Collector.Api.Domain.Consts;
|
||||||
using Newsbot.Collector.Domain.Models.Config;
|
using Newsbot.Collector.Domain.Models.Config;
|
||||||
|
using Newsbot.Collector.Domain.Models.Config.Sources;
|
||||||
using Newsbot.Collector.Services.Jobs;
|
using Newsbot.Collector.Services.Jobs;
|
||||||
using ILogger = Grpc.Core.Logging.ILogger;
|
|
||||||
|
|
||||||
namespace Newsbot.Collector.Api.Controllers;
|
namespace Newsbot.Collector.Api.Controllers.v1;
|
||||||
|
|
||||||
[ApiController]
|
[ApiController]
|
||||||
[Route("api/youtube")]
|
[Route("api/v1/youtube")]
|
||||||
|
[Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme)]
|
||||||
public class YoutubeController
|
public class YoutubeController
|
||||||
{
|
{
|
||||||
private readonly ILogger<YoutubeController> _logger;
|
private readonly ILogger<YoutubeController> _logger;
|
||||||
@ -23,6 +27,7 @@ public class YoutubeController
|
|||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost("check")]
|
[HttpPost("check")]
|
||||||
|
[Authorize(Policy = Authorization.AdministratorsRole)]
|
||||||
public void CheckYoutube()
|
public void CheckYoutube()
|
||||||
{
|
{
|
||||||
BackgroundJob.Enqueue<YoutubeWatcherJob>(x => x.InitAndExecute(new YoutubeWatcherJobOptions
|
BackgroundJob.Enqueue<YoutubeWatcherJob>(x => x.InitAndExecute(new YoutubeWatcherJobOptions
|
32
Newsbot.Collector.Api/Filters/ApiKeyAuthAttribute.cs
Normal file
32
Newsbot.Collector.Api/Filters/ApiKeyAuthAttribute.cs
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using Microsoft.AspNetCore.Mvc.Filters;
|
||||||
|
using Newsbot.Collector.Domain.Consts;
|
||||||
|
|
||||||
|
namespace Newsbot.Collector.Api.Filters;
|
||||||
|
|
||||||
|
[AttributeUsage(AttributeTargets.Class| AttributeTargets.Method)]
|
||||||
|
public class ApiKeyAuthAttribute : Attribute, IAsyncActionFilter
|
||||||
|
{
|
||||||
|
private const string ApiKeyHeaderName = "X-API-KEY";
|
||||||
|
|
||||||
|
public async Task OnActionExecutionAsync(ActionExecutingContext context, ActionExecutionDelegate next)
|
||||||
|
{
|
||||||
|
if (!context.HttpContext.Request.Headers.TryGetValue(ApiKeyHeaderName, out var foundKey))
|
||||||
|
{
|
||||||
|
context.Result = new BadRequestResult();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var config = context.HttpContext.RequestServices.GetRequiredService<IConfiguration>();
|
||||||
|
var apiKeys = config.GetValue<string[]>(ConfigConst.ApiKeys);
|
||||||
|
|
||||||
|
foreach (var key in apiKeys ?? Array.Empty<string?>())
|
||||||
|
{
|
||||||
|
if (key != foundKey) continue;
|
||||||
|
await next();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
context.Result = new BadRequestResult();
|
||||||
|
}
|
||||||
|
}
|
9
Newsbot.Collector.Api/Middleware/JwtUserIdExtension.cs
Normal file
9
Newsbot.Collector.Api/Middleware/JwtUserIdExtension.cs
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
namespace Newsbot.Collector.Api.Middleware;
|
||||||
|
|
||||||
|
public static class JwtUserIdExtension
|
||||||
|
{
|
||||||
|
public static string GetUserId(this HttpContext context)
|
||||||
|
{
|
||||||
|
return context.User.Claims.Single(x => x.Type == "id").Value;
|
||||||
|
}
|
||||||
|
}
|
@ -4,6 +4,8 @@
|
|||||||
<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>
|
||||||
@ -13,7 +15,13 @@
|
|||||||
<PackageReference Include="AspNetCore.HealthChecks.UI.Core" Version="6.0.5" />
|
<PackageReference Include="AspNetCore.HealthChecks.UI.Core" Version="6.0.5" />
|
||||||
<PackageReference Include="Hangfire.AspNetCore" Version="1.7.33" />
|
<PackageReference Include="Hangfire.AspNetCore" Version="1.7.33" />
|
||||||
<PackageReference Include="Hangfire.MemoryStorage" Version="1.7.0" />
|
<PackageReference Include="Hangfire.MemoryStorage" Version="1.7.0" />
|
||||||
|
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="7.0.8" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="7.0.0" />
|
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="7.0.0" />
|
||||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.8" />
|
||||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.8">
|
||||||
|
<PrivateAssets>all</PrivateAssets>
|
||||||
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
|
</PackageReference>
|
||||||
<PackageReference Include="Microsoft.Extensions.Configuration" Version="7.0.0" />
|
<PackageReference Include="Microsoft.Extensions.Configuration" Version="7.0.0" />
|
||||||
<PackageReference Include="OpenTelemetry.Exporter.Console" Version="1.4.0" />
|
<PackageReference Include="OpenTelemetry.Exporter.Console" Version="1.4.0" />
|
||||||
<PackageReference Include="OpenTelemetry.Exporter.OpenTelemetryProtocol" Version="1.4.0" />
|
<PackageReference Include="OpenTelemetry.Exporter.OpenTelemetryProtocol" Version="1.4.0" />
|
||||||
|
@ -2,14 +2,12 @@ using Hangfire;
|
|||||||
using Hangfire.MemoryStorage;
|
using Hangfire.MemoryStorage;
|
||||||
using HealthChecks.UI.Client;
|
using HealthChecks.UI.Client;
|
||||||
using Microsoft.AspNetCore.Diagnostics.HealthChecks;
|
using Microsoft.AspNetCore.Diagnostics.HealthChecks;
|
||||||
using Microsoft.OpenApi.Models;
|
using Newsbot.Collector.Api.Startup;
|
||||||
using Newsbot.Collector.Api;
|
|
||||||
using Newsbot.Collector.Api.Authentication;
|
|
||||||
using Newsbot.Collector.Domain.Consts;
|
using Newsbot.Collector.Domain.Consts;
|
||||||
using Newsbot.Collector.Domain.Models;
|
using Newsbot.Collector.Domain.Models;
|
||||||
using Newsbot.Collector.Domain.Models.Config;
|
using Newsbot.Collector.Domain.Models.Config;
|
||||||
|
using Newsbot.Collector.Domain.Models.Config.Sources;
|
||||||
using Serilog;
|
using Serilog;
|
||||||
using Serilog.Events;
|
|
||||||
using ILogger = Serilog.ILogger;
|
using ILogger = Serilog.ILogger;
|
||||||
|
|
||||||
var builder = WebApplication.CreateBuilder(args);
|
var builder = WebApplication.CreateBuilder(args);
|
||||||
@ -22,59 +20,41 @@ var config = GetConfiguration();
|
|||||||
builder.Configuration.AddConfiguration(config);
|
builder.Configuration.AddConfiguration(config);
|
||||||
|
|
||||||
Log.Logger = GetLogger(config);
|
Log.Logger = GetLogger(config);
|
||||||
|
|
||||||
Log.Information("Starting up");
|
Log.Information("Starting up");
|
||||||
|
|
||||||
|
// configure Entity Framework
|
||||||
|
// Allow the controllers to access all the table repositories based on the interface
|
||||||
|
DatabaseStartup.BuildDatabase(builder.Services, config);
|
||||||
|
DatabaseStartup.InjectTableClasses(builder.Services);
|
||||||
|
DatabaseStartup.InjectIdentityService(builder.Services);
|
||||||
|
|
||||||
// Configure Hangfire
|
// Configure Hangfire
|
||||||
builder.Services.AddHangfire(f => f.UseMemoryStorage());
|
builder.Services.AddHangfire(f => f.UseMemoryStorage());
|
||||||
builder.Services.AddHangfireServer();
|
builder.Services.AddHangfireServer();
|
||||||
GlobalConfiguration.Configuration.UseSerilogLogProvider();
|
GlobalConfiguration.Configuration.UseSerilogLogProvider();
|
||||||
|
|
||||||
|
// Build Health Checks
|
||||||
builder.Services.AddHealthChecks()
|
builder.Services.AddHealthChecks()
|
||||||
.AddNpgSql(config.GetValue<string>(ConfigConnectionStringConst.Database) ?? "");
|
.AddNpgSql(config.GetValue<string>(ConfigConst.ConnectionStringDatabase) ?? "");
|
||||||
|
|
||||||
|
|
||||||
builder.Services.AddControllers();
|
builder.Services.AddControllers();
|
||||||
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
|
|
||||||
builder.Services.AddEndpointsApiExplorer();
|
SwaggerStartup.ConfigureSwagger(builder.Services);
|
||||||
builder.Services.AddSwaggerGen();
|
|
||||||
|
|
||||||
builder.Services.Configure<ConnectionStrings>(config.GetSection("ConnectionStrings"));
|
builder.Services.Configure<ConnectionStrings>(config.GetSection("ConnectionStrings"));
|
||||||
|
|
||||||
builder.Services.Configure<ConfigSectionConnectionStrings>(config.GetSection(ConfigSectionsConst.ConnectionStrings));
|
builder.Services.Configure<ConfigSectionConnectionStrings>(config.GetSection(ConfigSectionsConst.ConnectionStrings));
|
||||||
builder.Services.Configure<ConfigSectionRssModel>(config.GetSection(ConfigSectionsConst.Rss));
|
builder.Services.Configure<ConfigSectionRssModel>(config.GetSection(ConfigSectionsConst.Rss));
|
||||||
builder.Services.Configure<ConfigSectionYoutubeModel>(config.GetSection(ConfigSectionsConst.Youtube));
|
builder.Services.Configure<ConfigSectionYoutubeModel>(config.GetSection(ConfigSectionsConst.Youtube));
|
||||||
//builder.Services.Configure<
|
|
||||||
|
|
||||||
builder.Services.AddSwaggerGen(cfg =>
|
IdentityStartup.DefineJwtRequirements(builder.Services, config);
|
||||||
{
|
|
||||||
cfg.AddSecurityDefinition("ApiKey", new OpenApiSecurityScheme
|
|
||||||
{
|
|
||||||
Description = "The API key to access the API",
|
|
||||||
Type = SecuritySchemeType.ApiKey,
|
|
||||||
Name = "x-api-key",
|
|
||||||
In = ParameterLocation.Header,
|
|
||||||
Scheme = "ApiKeyScheme"
|
|
||||||
});
|
|
||||||
|
|
||||||
var scheme = new OpenApiSecurityScheme
|
|
||||||
{
|
|
||||||
Reference = new OpenApiReference
|
|
||||||
{
|
|
||||||
Type = ReferenceType.SecurityScheme,
|
|
||||||
Id = "ApiKey"
|
|
||||||
},
|
|
||||||
In = ParameterLocation.Header
|
|
||||||
};
|
|
||||||
var requirement = new OpenApiSecurityRequirement
|
|
||||||
{
|
|
||||||
{ scheme, new List<string>() }
|
|
||||||
};
|
|
||||||
cfg.AddSecurityRequirement(requirement);
|
|
||||||
});
|
|
||||||
|
|
||||||
var app = builder.Build();
|
var app = builder.Build();
|
||||||
|
|
||||||
// Configure the HTTP request pipeline.
|
// Configure the HTTP request pipeline.
|
||||||
if (config.GetValue<bool>("EnableSwagger"))
|
|
||||||
|
// Enable Swagger if requested based on config
|
||||||
|
if (config.GetValue<bool>(ConfigConst.EnableSwagger))
|
||||||
{
|
{
|
||||||
app.UseSwagger();
|
app.UseSwagger();
|
||||||
app.UseSwaggerUI();
|
app.UseSwaggerUI();
|
||||||
@ -82,13 +62,17 @@ if (config.GetValue<bool>("EnableSwagger"))
|
|||||||
|
|
||||||
app.UseHttpsRedirection();
|
app.UseHttpsRedirection();
|
||||||
|
|
||||||
|
// Enable Hangfire background jobs
|
||||||
app.UseHangfireDashboard();
|
app.UseHangfireDashboard();
|
||||||
BackgroundJobs.SetupRecurringJobs(config);
|
BackgroundJobs.SetupRecurringJobs(config);
|
||||||
|
|
||||||
app.UseAuthorization();
|
app.UseAuthorization();
|
||||||
|
app.UseAuthentication();
|
||||||
|
|
||||||
app.UseMiddleware<ApiKeyAuthAuthentication>();
|
// Add middleware
|
||||||
|
//app.UseMiddleware<ApiKeyAuthAuthentication>();
|
||||||
|
|
||||||
|
// Add HealthChecks
|
||||||
app.MapHealthChecks("/health", new HealthCheckOptions
|
app.MapHealthChecks("/health", new HealthCheckOptions
|
||||||
{
|
{
|
||||||
Predicate = _ => true,
|
Predicate = _ => true,
|
||||||
@ -96,6 +80,21 @@ app.MapHealthChecks("/health", new HealthCheckOptions
|
|||||||
});
|
});
|
||||||
app.MapControllers();
|
app.MapControllers();
|
||||||
|
|
||||||
|
// Run Database Migrations if requested
|
||||||
|
using var serviceScope = app.Services.CreateScope();
|
||||||
|
if (config.GetValue<bool>(ConfigConst.RunDatabaseMigrationsOnStartup))
|
||||||
|
{
|
||||||
|
await DatabaseStartup.RunDatabaseMigrationsAsync(serviceScope);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Log.Warning("Database Migrations have been skipped. Make sure you run them on your own");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Inject the roles
|
||||||
|
await DatabaseStartup.InjectIdentityRolesAsync(serviceScope);
|
||||||
|
|
||||||
|
// Start the application
|
||||||
app.Run();
|
app.Run();
|
||||||
|
|
||||||
|
|
||||||
@ -103,13 +102,14 @@ static IConfiguration GetConfiguration()
|
|||||||
{
|
{
|
||||||
return new ConfigurationBuilder()
|
return new ConfigurationBuilder()
|
||||||
.AddJsonFile("appsettings.json", true)
|
.AddJsonFile("appsettings.json", true)
|
||||||
|
.AddJsonFile("config/appsettings.json", true)
|
||||||
.AddEnvironmentVariables()
|
.AddEnvironmentVariables()
|
||||||
.Build();
|
.Build();
|
||||||
}
|
}
|
||||||
|
|
||||||
static ILogger GetLogger(IConfiguration configuration)
|
static ILogger GetLogger(IConfiguration configuration)
|
||||||
{
|
{
|
||||||
var otel = configuration.GetValue<string>(ConfigConnectionStringConst.OpenTelemetry) ?? "";
|
var otel = configuration.GetValue<string>(ConfigConst.ConnectionStringOpenTelemetry) ?? "";
|
||||||
|
|
||||||
if (otel == "")
|
if (otel == "")
|
||||||
return Log.Logger = new LoggerConfiguration()
|
return Log.Logger = new LoggerConfiguration()
|
||||||
@ -128,4 +128,4 @@ static ILogger GetLogger(IConfiguration configuration)
|
|||||||
{ "service.name", "newsbot-collector-api" }
|
{ "service.name", "newsbot-collector-api" }
|
||||||
})
|
})
|
||||||
.CreateLogger();
|
.CreateLogger();
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,7 @@ using Newsbot.Collector.Domain.Consts;
|
|||||||
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;
|
namespace Newsbot.Collector.Api.Startup;
|
||||||
|
|
||||||
public static class BackgroundJobs
|
public static class BackgroundJobs
|
||||||
{
|
{
|
62
Newsbot.Collector.Api/Startup/DatabaseStartup.cs
Normal file
62
Newsbot.Collector.Api/Startup/DatabaseStartup.cs
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
using Microsoft.AspNetCore.Identity;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Newsbot.Collector.Api.Domain.Consts;
|
||||||
|
using Newsbot.Collector.Database;
|
||||||
|
using Newsbot.Collector.Database.Repositories;
|
||||||
|
using Newsbot.Collector.Domain.Interfaces;
|
||||||
|
using Newsbot.Collector.Services;
|
||||||
|
|
||||||
|
namespace Newsbot.Collector.Api.Startup;
|
||||||
|
|
||||||
|
public class DatabaseStartup
|
||||||
|
{
|
||||||
|
public static void BuildDatabase(IServiceCollection services, IConfiguration config)
|
||||||
|
{
|
||||||
|
var dbconn = config.GetConnectionString("Database");
|
||||||
|
services.AddDbContext<DatabaseContext>(o => o.UseNpgsql(dbconn ?? ""));
|
||||||
|
|
||||||
|
// Add identity to our ef connection
|
||||||
|
services.AddIdentity<IdentityUser, IdentityRole>()
|
||||||
|
.AddRoles<IdentityRole>()
|
||||||
|
.AddEntityFrameworkStores<DatabaseContext>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void InjectTableClasses(IServiceCollection services)
|
||||||
|
{
|
||||||
|
services.AddScoped<IArticlesRepository, ArticlesTable>();
|
||||||
|
services.AddScoped<IDiscordQueueRepository, DiscordQueueTable>();
|
||||||
|
services.AddScoped<IDiscordWebHooksRepository, DiscordWebhooksTable>();
|
||||||
|
services.AddScoped<IIconsRepository, IconsTable>();
|
||||||
|
services.AddScoped<ISourcesRepository, SourcesTable>();
|
||||||
|
services.AddScoped<IDiscordNotificationRepository, DiscordNotificationTable>();
|
||||||
|
services.AddScoped<IUserSourceSubscription, UserSourceSubscriptionTable>();
|
||||||
|
services.AddScoped<IRefreshTokenRepository, RefreshTokenTable>();
|
||||||
|
services.AddScoped<IAuthorTable, AuthorsTable>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void InjectIdentityService(IServiceCollection services)
|
||||||
|
{
|
||||||
|
// Configure Identity
|
||||||
|
services.AddScoped<IIdentityService, IdentityService>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static async Task RunDatabaseMigrationsAsync(IServiceScope serviceScope)
|
||||||
|
{
|
||||||
|
var dbContext = serviceScope.ServiceProvider.GetRequiredService<DatabaseContext>();
|
||||||
|
await dbContext.Database.MigrateAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static async Task InjectIdentityRolesAsync(IServiceScope serviceScope)
|
||||||
|
{
|
||||||
|
var roleManager = serviceScope.ServiceProvider.GetRequiredService<RoleManager<IdentityRole>>();
|
||||||
|
if (!await roleManager.RoleExistsAsync(Authorization.AdministratorsRole))
|
||||||
|
{
|
||||||
|
await roleManager.CreateAsync(new IdentityRole(Authorization.AdministratorsRole));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!await roleManager.RoleExistsAsync(Authorization.UsersRole))
|
||||||
|
{
|
||||||
|
await roleManager.CreateAsync(new IdentityRole(Authorization.UsersRole));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
52
Newsbot.Collector.Api/Startup/IdentityStartup.cs
Normal file
52
Newsbot.Collector.Api/Startup/IdentityStartup.cs
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
using System.Text;
|
||||||
|
using Microsoft.AspNetCore.Authentication.JwtBearer;
|
||||||
|
using Microsoft.IdentityModel.Tokens;
|
||||||
|
using Newsbot.Collector.Api.Domain.Consts;
|
||||||
|
using Newsbot.Collector.Domain.Models.Config;
|
||||||
|
|
||||||
|
namespace Newsbot.Collector.Api.Startup;
|
||||||
|
|
||||||
|
public static class IdentityStartup
|
||||||
|
{
|
||||||
|
public static void DefineJwtRequirements(IServiceCollection services, IConfiguration config)
|
||||||
|
{
|
||||||
|
// Configure JWT for auth and load it into DI so we can use it in the controllers
|
||||||
|
|
||||||
|
var jwtSettings = new JwtSettings();
|
||||||
|
config.Bind(nameof(jwtSettings), jwtSettings);
|
||||||
|
services.AddSingleton(jwtSettings);
|
||||||
|
|
||||||
|
// Configure how the Token Validation will be handled
|
||||||
|
var tokenValidationParameters = new TokenValidationParameters
|
||||||
|
{
|
||||||
|
ValidateIssuerSigningKey = true,
|
||||||
|
IssuerSigningKey = new SymmetricSecurityKey(Encoding.ASCII.GetBytes(jwtSettings.Secret ?? "")),
|
||||||
|
ValidateIssuer = false,
|
||||||
|
ValidateAudience = false,
|
||||||
|
RequireExpirationTime = false,
|
||||||
|
ValidateLifetime = true
|
||||||
|
};
|
||||||
|
services.AddSingleton(tokenValidationParameters);
|
||||||
|
|
||||||
|
// Build the Authentication that will be used
|
||||||
|
services.AddAuthentication(x =>
|
||||||
|
{
|
||||||
|
x.DefaultScheme = JwtBearerDefaults.AuthenticationScheme;
|
||||||
|
x.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme;
|
||||||
|
x.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme;
|
||||||
|
}).AddJwtBearer(x =>
|
||||||
|
{
|
||||||
|
x.SaveToken = true;
|
||||||
|
x.TokenValidationParameters = tokenValidationParameters;
|
||||||
|
});
|
||||||
|
|
||||||
|
// Build the Authorization Policy that the users will conform to.
|
||||||
|
services.AddAuthorization(options =>
|
||||||
|
{
|
||||||
|
options.AddPolicy(Authorization.AdministratorPolicy,
|
||||||
|
b => b.RequireRole(Authorization.AdministratorsRole, "true"));
|
||||||
|
options.AddPolicy(Authorization.UserPolicy,
|
||||||
|
b => b.RequireRole(Authorization.UsersRole, "true"));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
67
Newsbot.Collector.Api/Startup/SwaggerStartup.cs
Normal file
67
Newsbot.Collector.Api/Startup/SwaggerStartup.cs
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
using Microsoft.OpenApi.Models;
|
||||||
|
|
||||||
|
namespace Newsbot.Collector.Api.Startup;
|
||||||
|
|
||||||
|
public static class SwaggerStartup
|
||||||
|
{
|
||||||
|
public static void ConfigureSwagger(IServiceCollection services)
|
||||||
|
{
|
||||||
|
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
|
||||||
|
services.AddEndpointsApiExplorer();
|
||||||
|
services.AddSwaggerGen();
|
||||||
|
|
||||||
|
services.AddEndpointsApiExplorer();
|
||||||
|
services.AddSwaggerGen();
|
||||||
|
|
||||||
|
// Configure swagger authentication
|
||||||
|
services.AddSwaggerGen(cfg =>
|
||||||
|
{
|
||||||
|
cfg.AddSecurityDefinition("ApiKey", new OpenApiSecurityScheme
|
||||||
|
{
|
||||||
|
Description = "The API key to access the API",
|
||||||
|
Type = SecuritySchemeType.ApiKey,
|
||||||
|
Name = "x-api-key",
|
||||||
|
In = ParameterLocation.Header,
|
||||||
|
Scheme = "ApiKeyScheme"
|
||||||
|
});
|
||||||
|
|
||||||
|
cfg.AddSecurityDefinition("Bearer", new OpenApiSecurityScheme
|
||||||
|
{
|
||||||
|
Description = "JWT Authorization Header using the bearer scheme",
|
||||||
|
Name = "Authorization",
|
||||||
|
In = ParameterLocation.Header,
|
||||||
|
Type = SecuritySchemeType.ApiKey
|
||||||
|
});
|
||||||
|
|
||||||
|
cfg.AddSecurityRequirement(new OpenApiSecurityRequirement
|
||||||
|
{
|
||||||
|
//{
|
||||||
|
// new OpenApiSecurityScheme
|
||||||
|
// {
|
||||||
|
// Reference = new OpenApiReference
|
||||||
|
// {
|
||||||
|
// Type = ReferenceType.SecurityScheme,
|
||||||
|
// Id = "ApiKey"
|
||||||
|
// },
|
||||||
|
// In = ParameterLocation.Header
|
||||||
|
// },
|
||||||
|
// new List<string>()
|
||||||
|
//},
|
||||||
|
{
|
||||||
|
new OpenApiSecurityScheme
|
||||||
|
{
|
||||||
|
Reference = new OpenApiReference
|
||||||
|
{
|
||||||
|
Type = ReferenceType.SecurityScheme,
|
||||||
|
Id = "Bearer"
|
||||||
|
},
|
||||||
|
Scheme = "oauth2",
|
||||||
|
Name = "Bearer",
|
||||||
|
In = ParameterLocation.Header
|
||||||
|
},
|
||||||
|
new List<string>()
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
68
Newsbot.Collector.Database/DatabaseContext.cs
Normal file
68
Newsbot.Collector.Database/DatabaseContext.cs
Normal file
@ -0,0 +1,68 @@
|
|||||||
|
using Microsoft.AspNetCore.Identity;
|
||||||
|
using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.Extensions.Configuration;
|
||||||
|
using Newsbot.Collector.Domain.Consts;
|
||||||
|
using Newsbot.Collector.Domain.Entities;
|
||||||
|
|
||||||
|
namespace Newsbot.Collector.Database;
|
||||||
|
|
||||||
|
public class DatabaseContext : IdentityDbContext
|
||||||
|
{
|
||||||
|
public DbSet<ArticlesEntity> Articles { get; set; } = null!;
|
||||||
|
public DbSet<DiscordNotificationEntity> DiscordNotification { get; set; } = null!;
|
||||||
|
public DbSet<DiscordQueueEntity> DiscordQueue { get; set; } = null!;
|
||||||
|
public DbSet<DiscordWebhookEntity> DiscordWebhooks { get; set; } = null!;
|
||||||
|
public DbSet<IconEntity> Icons { get; set; } = null!;
|
||||||
|
public DbSet<SourceEntity> Sources { get; set; } = null!;
|
||||||
|
public DbSet<AuthorEntity> Authors { get; set; } = null!;
|
||||||
|
|
||||||
|
public DbSet<UserSourceSubscriptionEntity> UserSourceSubscription { get; set; } = null!;
|
||||||
|
|
||||||
|
public DbSet<RefreshTokenEntity> RefreshTokens { get; set; } = null!;
|
||||||
|
|
||||||
|
private string ConnectionString { get; set; } = "";
|
||||||
|
|
||||||
|
//public DatabaseContext(IConfiguration appsettings, string connectionString)
|
||||||
|
//{
|
||||||
|
// var connString = appsettings.GetConnectionString(ConfigConnectionStringConst.Database);
|
||||||
|
// ConnectionString = connString ?? "";
|
||||||
|
//}
|
||||||
|
|
||||||
|
public DatabaseContext(string connectionString)
|
||||||
|
{
|
||||||
|
ConnectionString = connectionString;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void OnConfiguring(DbContextOptionsBuilder options)
|
||||||
|
{
|
||||||
|
if (ConnectionString != "")
|
||||||
|
{
|
||||||
|
options.UseNpgsql(ConnectionString);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//public DatabaseContext(DbContextOptions<DatabaseContext> connectionString)
|
||||||
|
//{
|
||||||
|
// ConnectionString = "";
|
||||||
|
//}
|
||||||
|
|
||||||
|
//public DatabaseContext()
|
||||||
|
//{
|
||||||
|
// ConnectionString = "";
|
||||||
|
//}
|
||||||
|
|
||||||
|
|
||||||
|
public DatabaseContext(DbContextOptions<DatabaseContext> options)
|
||||||
|
: base(options)
|
||||||
|
{
|
||||||
|
//ConnectionString = "";
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public DatabaseContext(DbContextOptions<DatabaseContext> options, string connectionString)
|
||||||
|
: base(options)
|
||||||
|
{
|
||||||
|
//ConnectionString = connectionString;
|
||||||
|
}
|
||||||
|
}
|
16
Newsbot.Collector.Database/DesignTimeContext.cs
Normal file
16
Newsbot.Collector.Database/DesignTimeContext.cs
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.EntityFrameworkCore.Design;
|
||||||
|
using Microsoft.Extensions.Configuration;
|
||||||
|
|
||||||
|
namespace Newsbot.Collector.Database;
|
||||||
|
|
||||||
|
public class DesignTimeContext :IDesignTimeDbContextFactory<DatabaseContext>
|
||||||
|
{
|
||||||
|
public DatabaseContext CreateDbContext(string[] args)
|
||||||
|
{
|
||||||
|
var optionsBuilder = new DbContextOptionsBuilder<DatabaseContext>();
|
||||||
|
// pass your design time connection string here
|
||||||
|
optionsBuilder.UseNpgsql("<connection_string>");
|
||||||
|
return new DatabaseContext(optionsBuilder.Options);
|
||||||
|
}
|
||||||
|
}
|
223
Newsbot.Collector.Database/Migrations/20230619043102_MigrationFromGoose.Designer.cs
generated
Normal file
223
Newsbot.Collector.Database/Migrations/20230619043102_MigrationFromGoose.Designer.cs
generated
Normal file
@ -0,0 +1,223 @@
|
|||||||
|
// <auto-generated />
|
||||||
|
using System;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||||
|
using Newsbot.Collector.Database;
|
||||||
|
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace Newsbot.Collector.Database.Migrations
|
||||||
|
{
|
||||||
|
[DbContext(typeof(DatabaseContext))]
|
||||||
|
[Migration("20230619043102_MigrationFromGoose")]
|
||||||
|
partial class MigrationFromGoose
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||||
|
{
|
||||||
|
#pragma warning disable 612, 618
|
||||||
|
modelBuilder
|
||||||
|
.HasAnnotation("ProductVersion", "7.0.7")
|
||||||
|
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
||||||
|
|
||||||
|
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
||||||
|
|
||||||
|
modelBuilder.Entity("Newsbot.Collector.Domain.Entities.ArticlesEntity", b =>
|
||||||
|
{
|
||||||
|
b.Property<Guid>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<string>("AuthorImage")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("AuthorName")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<bool>("CodeIsCommit")
|
||||||
|
.HasColumnType("boolean");
|
||||||
|
|
||||||
|
b.Property<bool>("CodeIsRelease")
|
||||||
|
.HasColumnType("boolean");
|
||||||
|
|
||||||
|
b.Property<string>("Description")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<DateTime>("PubDate")
|
||||||
|
.HasColumnType("timestamp with time zone");
|
||||||
|
|
||||||
|
b.Property<Guid>("SourceId")
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<string>("Tags")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Thumbnail")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Title")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Url")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Video")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<int>("VideoHeight")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.Property<int>("VideoWidth")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Articles");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Newsbot.Collector.Domain.Entities.DiscordQueueEntity", b =>
|
||||||
|
{
|
||||||
|
b.Property<Guid>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<Guid>("ArticleId")
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("DiscordQueue");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Newsbot.Collector.Domain.Entities.DiscordWebhookEntity", b =>
|
||||||
|
{
|
||||||
|
b.Property<Guid>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<string>("Channel")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<bool>("Enabled")
|
||||||
|
.HasColumnType("boolean");
|
||||||
|
|
||||||
|
b.Property<string>("Server")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Url")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("DiscordWebhooks");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Newsbot.Collector.Domain.Entities.IconEntity", b =>
|
||||||
|
{
|
||||||
|
b.Property<Guid>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<string>("FileName")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Site")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<Guid>("SourceId")
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Icons");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Newsbot.Collector.Domain.Entities.SourceEntity", b =>
|
||||||
|
{
|
||||||
|
b.Property<Guid>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<bool>("Deleted")
|
||||||
|
.HasColumnType("boolean");
|
||||||
|
|
||||||
|
b.Property<bool>("Enabled")
|
||||||
|
.HasColumnType("boolean");
|
||||||
|
|
||||||
|
b.Property<string>("Name")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Site")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Source")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Tags")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Type")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Url")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Value")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("YoutubeId")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Sources");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Newsbot.Collector.Domain.Entities.SubscriptionEntity", b =>
|
||||||
|
{
|
||||||
|
b.Property<Guid>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<bool>("CodeAllowCommits")
|
||||||
|
.HasColumnType("boolean");
|
||||||
|
|
||||||
|
b.Property<bool>("CodeAllowReleases")
|
||||||
|
.HasColumnType("boolean");
|
||||||
|
|
||||||
|
b.Property<Guid>("DiscordWebHookId")
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<Guid>("SourceId")
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Subscriptions");
|
||||||
|
});
|
||||||
|
#pragma warning restore 612, 618
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,140 @@
|
|||||||
|
using System;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
using Microsoft.Extensions.Configuration;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace Newsbot.Collector.Database.Migrations
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
public partial class MigrationFromGoose : Migration
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "Articles",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
Id = table.Column<Guid>(type: "uuid", nullable: false),
|
||||||
|
SourceId = table.Column<Guid>(type: "uuid", nullable: false),
|
||||||
|
Tags = table.Column<string>(type: "text", nullable: false),
|
||||||
|
Title = table.Column<string>(type: "text", nullable: false),
|
||||||
|
Url = table.Column<string>(type: "text", nullable: true),
|
||||||
|
PubDate = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
|
||||||
|
Video = table.Column<string>(type: "text", nullable: false),
|
||||||
|
VideoHeight = table.Column<int>(type: "integer", nullable: false),
|
||||||
|
VideoWidth = table.Column<int>(type: "integer", nullable: false),
|
||||||
|
Thumbnail = table.Column<string>(type: "text", nullable: false),
|
||||||
|
Description = table.Column<string>(type: "text", nullable: false),
|
||||||
|
AuthorName = table.Column<string>(type: "text", nullable: false),
|
||||||
|
AuthorImage = table.Column<string>(type: "text", nullable: true),
|
||||||
|
CodeIsRelease = table.Column<bool>(type: "boolean", nullable: false),
|
||||||
|
CodeIsCommit = table.Column<bool>(type: "boolean", nullable: false)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_Articles", x => x.Id);
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "DiscordQueue",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
Id = table.Column<Guid>(type: "uuid", nullable: false),
|
||||||
|
ArticleId = table.Column<Guid>(type: "uuid", nullable: false)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_DiscordQueue", x => x.Id);
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "DiscordWebhooks",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
Id = table.Column<Guid>(type: "uuid", nullable: false),
|
||||||
|
Url = table.Column<string>(type: "text", nullable: false),
|
||||||
|
Server = table.Column<string>(type: "text", nullable: false),
|
||||||
|
Channel = table.Column<string>(type: "text", nullable: false),
|
||||||
|
Enabled = table.Column<bool>(type: "boolean", nullable: false)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_DiscordWebhooks", x => x.Id);
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "Icons",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
Id = table.Column<Guid>(type: "uuid", nullable: false),
|
||||||
|
FileName = table.Column<string>(type: "text", nullable: false),
|
||||||
|
Site = table.Column<string>(type: "text", nullable: false),
|
||||||
|
SourceId = table.Column<Guid>(type: "uuid", nullable: false)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_Icons", x => x.Id);
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "Sources",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
Id = table.Column<Guid>(type: "uuid", nullable: false),
|
||||||
|
Site = table.Column<string>(type: "text", nullable: false),
|
||||||
|
Name = table.Column<string>(type: "text", nullable: false),
|
||||||
|
Source = table.Column<string>(type: "text", nullable: false),
|
||||||
|
Type = table.Column<string>(type: "text", nullable: false),
|
||||||
|
Value = table.Column<string>(type: "text", nullable: false),
|
||||||
|
Enabled = table.Column<bool>(type: "boolean", nullable: false),
|
||||||
|
Url = table.Column<string>(type: "text", nullable: false),
|
||||||
|
Tags = table.Column<string>(type: "text", nullable: false),
|
||||||
|
Deleted = table.Column<bool>(type: "boolean", nullable: false),
|
||||||
|
YoutubeId = table.Column<string>(type: "text", nullable: false)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_Sources", x => x.Id);
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "Subscriptions",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
Id = table.Column<Guid>(type: "uuid", nullable: false),
|
||||||
|
CodeAllowReleases = table.Column<bool>(type: "boolean", nullable: false),
|
||||||
|
CodeAllowCommits = table.Column<bool>(type: "boolean", nullable: false),
|
||||||
|
SourceId = table.Column<Guid>(type: "uuid", nullable: false),
|
||||||
|
DiscordWebHookId = table.Column<Guid>(type: "uuid", nullable: false)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_Subscriptions", x => x.Id);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "Articles");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "DiscordQueue");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "DiscordWebhooks");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "Icons");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "Sources");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "Subscriptions");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
470
Newsbot.Collector.Database/Migrations/20230629222603_identity.Designer.cs
generated
Normal file
470
Newsbot.Collector.Database/Migrations/20230629222603_identity.Designer.cs
generated
Normal file
@ -0,0 +1,470 @@
|
|||||||
|
// <auto-generated />
|
||||||
|
using System;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||||
|
using Newsbot.Collector.Database;
|
||||||
|
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace Newsbot.Collector.Database.Migrations
|
||||||
|
{
|
||||||
|
[DbContext(typeof(DatabaseContext))]
|
||||||
|
[Migration("20230629222603_identity")]
|
||||||
|
partial class identity
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||||
|
{
|
||||||
|
#pragma warning disable 612, 618
|
||||||
|
modelBuilder
|
||||||
|
.HasAnnotation("ProductVersion", "7.0.8")
|
||||||
|
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
||||||
|
|
||||||
|
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
||||||
|
|
||||||
|
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole", b =>
|
||||||
|
{
|
||||||
|
b.Property<string>("Id")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("ConcurrencyStamp")
|
||||||
|
.IsConcurrencyToken()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Name")
|
||||||
|
.HasMaxLength(256)
|
||||||
|
.HasColumnType("character varying(256)");
|
||||||
|
|
||||||
|
b.Property<string>("NormalizedName")
|
||||||
|
.HasMaxLength(256)
|
||||||
|
.HasColumnType("character varying(256)");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("NormalizedName")
|
||||||
|
.IsUnique()
|
||||||
|
.HasDatabaseName("RoleNameIndex");
|
||||||
|
|
||||||
|
b.ToTable("AspNetRoles", (string)null);
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<string>", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<string>("ClaimType")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("ClaimValue")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("RoleId")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("RoleId");
|
||||||
|
|
||||||
|
b.ToTable("AspNetRoleClaims", (string)null);
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUser", b =>
|
||||||
|
{
|
||||||
|
b.Property<string>("Id")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<int>("AccessFailedCount")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.Property<string>("ConcurrencyStamp")
|
||||||
|
.IsConcurrencyToken()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Email")
|
||||||
|
.HasMaxLength(256)
|
||||||
|
.HasColumnType("character varying(256)");
|
||||||
|
|
||||||
|
b.Property<bool>("EmailConfirmed")
|
||||||
|
.HasColumnType("boolean");
|
||||||
|
|
||||||
|
b.Property<bool>("LockoutEnabled")
|
||||||
|
.HasColumnType("boolean");
|
||||||
|
|
||||||
|
b.Property<DateTimeOffset?>("LockoutEnd")
|
||||||
|
.HasColumnType("timestamp with time zone");
|
||||||
|
|
||||||
|
b.Property<string>("NormalizedEmail")
|
||||||
|
.HasMaxLength(256)
|
||||||
|
.HasColumnType("character varying(256)");
|
||||||
|
|
||||||
|
b.Property<string>("NormalizedUserName")
|
||||||
|
.HasMaxLength(256)
|
||||||
|
.HasColumnType("character varying(256)");
|
||||||
|
|
||||||
|
b.Property<string>("PasswordHash")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("PhoneNumber")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<bool>("PhoneNumberConfirmed")
|
||||||
|
.HasColumnType("boolean");
|
||||||
|
|
||||||
|
b.Property<string>("SecurityStamp")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<bool>("TwoFactorEnabled")
|
||||||
|
.HasColumnType("boolean");
|
||||||
|
|
||||||
|
b.Property<string>("UserName")
|
||||||
|
.HasMaxLength(256)
|
||||||
|
.HasColumnType("character varying(256)");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("NormalizedEmail")
|
||||||
|
.HasDatabaseName("EmailIndex");
|
||||||
|
|
||||||
|
b.HasIndex("NormalizedUserName")
|
||||||
|
.IsUnique()
|
||||||
|
.HasDatabaseName("UserNameIndex");
|
||||||
|
|
||||||
|
b.ToTable("AspNetUsers", (string)null);
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<string>", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<string>("ClaimType")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("ClaimValue")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("UserId")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("UserId");
|
||||||
|
|
||||||
|
b.ToTable("AspNetUserClaims", (string)null);
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<string>", b =>
|
||||||
|
{
|
||||||
|
b.Property<string>("LoginProvider")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("ProviderKey")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("ProviderDisplayName")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("UserId")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.HasKey("LoginProvider", "ProviderKey");
|
||||||
|
|
||||||
|
b.HasIndex("UserId");
|
||||||
|
|
||||||
|
b.ToTable("AspNetUserLogins", (string)null);
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<string>", b =>
|
||||||
|
{
|
||||||
|
b.Property<string>("UserId")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("RoleId")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.HasKey("UserId", "RoleId");
|
||||||
|
|
||||||
|
b.HasIndex("RoleId");
|
||||||
|
|
||||||
|
b.ToTable("AspNetUserRoles", (string)null);
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<string>", b =>
|
||||||
|
{
|
||||||
|
b.Property<string>("UserId")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("LoginProvider")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Name")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Value")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.HasKey("UserId", "LoginProvider", "Name");
|
||||||
|
|
||||||
|
b.ToTable("AspNetUserTokens", (string)null);
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Newsbot.Collector.Domain.Entities.ArticlesEntity", b =>
|
||||||
|
{
|
||||||
|
b.Property<Guid>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<string>("AuthorImage")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("AuthorName")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<bool>("CodeIsCommit")
|
||||||
|
.HasColumnType("boolean");
|
||||||
|
|
||||||
|
b.Property<bool>("CodeIsRelease")
|
||||||
|
.HasColumnType("boolean");
|
||||||
|
|
||||||
|
b.Property<string>("Description")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<DateTime>("PubDate")
|
||||||
|
.HasColumnType("timestamp with time zone");
|
||||||
|
|
||||||
|
b.Property<Guid>("SourceId")
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<string>("Tags")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Thumbnail")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Title")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Url")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Video")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<int>("VideoHeight")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.Property<int>("VideoWidth")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Articles");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Newsbot.Collector.Domain.Entities.DiscordQueueEntity", b =>
|
||||||
|
{
|
||||||
|
b.Property<Guid>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<Guid>("ArticleId")
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("DiscordQueue");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Newsbot.Collector.Domain.Entities.DiscordWebhookEntity", b =>
|
||||||
|
{
|
||||||
|
b.Property<Guid>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<string>("Channel")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<bool>("Enabled")
|
||||||
|
.HasColumnType("boolean");
|
||||||
|
|
||||||
|
b.Property<string>("Server")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Url")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("DiscordWebhooks");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Newsbot.Collector.Domain.Entities.IconEntity", b =>
|
||||||
|
{
|
||||||
|
b.Property<Guid>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<string>("FileName")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Site")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<Guid>("SourceId")
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Icons");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Newsbot.Collector.Domain.Entities.SourceEntity", b =>
|
||||||
|
{
|
||||||
|
b.Property<Guid>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<bool>("Deleted")
|
||||||
|
.HasColumnType("boolean");
|
||||||
|
|
||||||
|
b.Property<bool>("Enabled")
|
||||||
|
.HasColumnType("boolean");
|
||||||
|
|
||||||
|
b.Property<string>("Name")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Site")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Source")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Tags")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Type")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Url")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Value")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("YoutubeId")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Sources");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Newsbot.Collector.Domain.Entities.SubscriptionEntity", b =>
|
||||||
|
{
|
||||||
|
b.Property<Guid>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<bool>("CodeAllowCommits")
|
||||||
|
.HasColumnType("boolean");
|
||||||
|
|
||||||
|
b.Property<bool>("CodeAllowReleases")
|
||||||
|
.HasColumnType("boolean");
|
||||||
|
|
||||||
|
b.Property<Guid>("DiscordWebHookId")
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<Guid>("SourceId")
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Subscriptions");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<string>", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null)
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("RoleId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<string>", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null)
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("UserId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<string>", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null)
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("UserId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<string>", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null)
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("RoleId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null)
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("UserId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<string>", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null)
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("UserId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
});
|
||||||
|
#pragma warning restore 612, 618
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
223
Newsbot.Collector.Database/Migrations/20230629222603_identity.cs
Normal file
223
Newsbot.Collector.Database/Migrations/20230629222603_identity.cs
Normal file
@ -0,0 +1,223 @@
|
|||||||
|
using System;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace Newsbot.Collector.Database.Migrations
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
public partial class identity : Migration
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "AspNetRoles",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
Id = table.Column<string>(type: "text", nullable: false),
|
||||||
|
Name = table.Column<string>(type: "character varying(256)", maxLength: 256, nullable: true),
|
||||||
|
NormalizedName = table.Column<string>(type: "character varying(256)", maxLength: 256, nullable: true),
|
||||||
|
ConcurrencyStamp = table.Column<string>(type: "text", nullable: true)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_AspNetRoles", x => x.Id);
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "AspNetUsers",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
Id = table.Column<string>(type: "text", nullable: false),
|
||||||
|
UserName = table.Column<string>(type: "character varying(256)", maxLength: 256, nullable: true),
|
||||||
|
NormalizedUserName = table.Column<string>(type: "character varying(256)", maxLength: 256, nullable: true),
|
||||||
|
Email = table.Column<string>(type: "character varying(256)", maxLength: 256, nullable: true),
|
||||||
|
NormalizedEmail = table.Column<string>(type: "character varying(256)", maxLength: 256, nullable: true),
|
||||||
|
EmailConfirmed = table.Column<bool>(type: "boolean", nullable: false),
|
||||||
|
PasswordHash = table.Column<string>(type: "text", nullable: true),
|
||||||
|
SecurityStamp = table.Column<string>(type: "text", nullable: true),
|
||||||
|
ConcurrencyStamp = table.Column<string>(type: "text", nullable: true),
|
||||||
|
PhoneNumber = table.Column<string>(type: "text", nullable: true),
|
||||||
|
PhoneNumberConfirmed = table.Column<bool>(type: "boolean", nullable: false),
|
||||||
|
TwoFactorEnabled = table.Column<bool>(type: "boolean", nullable: false),
|
||||||
|
LockoutEnd = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: true),
|
||||||
|
LockoutEnabled = table.Column<bool>(type: "boolean", nullable: false),
|
||||||
|
AccessFailedCount = table.Column<int>(type: "integer", nullable: false)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_AspNetUsers", x => x.Id);
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "AspNetRoleClaims",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
Id = table.Column<int>(type: "integer", nullable: false)
|
||||||
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||||
|
RoleId = table.Column<string>(type: "text", nullable: false),
|
||||||
|
ClaimType = table.Column<string>(type: "text", nullable: true),
|
||||||
|
ClaimValue = table.Column<string>(type: "text", nullable: true)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_AspNetRoleClaims", x => x.Id);
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "FK_AspNetRoleClaims_AspNetRoles_RoleId",
|
||||||
|
column: x => x.RoleId,
|
||||||
|
principalTable: "AspNetRoles",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "AspNetUserClaims",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
Id = table.Column<int>(type: "integer", nullable: false)
|
||||||
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||||
|
UserId = table.Column<string>(type: "text", nullable: false),
|
||||||
|
ClaimType = table.Column<string>(type: "text", nullable: true),
|
||||||
|
ClaimValue = table.Column<string>(type: "text", nullable: true)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_AspNetUserClaims", x => x.Id);
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "FK_AspNetUserClaims_AspNetUsers_UserId",
|
||||||
|
column: x => x.UserId,
|
||||||
|
principalTable: "AspNetUsers",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "AspNetUserLogins",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
LoginProvider = table.Column<string>(type: "text", nullable: false),
|
||||||
|
ProviderKey = table.Column<string>(type: "text", nullable: false),
|
||||||
|
ProviderDisplayName = table.Column<string>(type: "text", nullable: true),
|
||||||
|
UserId = table.Column<string>(type: "text", nullable: false)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_AspNetUserLogins", x => new { x.LoginProvider, x.ProviderKey });
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "FK_AspNetUserLogins_AspNetUsers_UserId",
|
||||||
|
column: x => x.UserId,
|
||||||
|
principalTable: "AspNetUsers",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "AspNetUserRoles",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
UserId = table.Column<string>(type: "text", nullable: false),
|
||||||
|
RoleId = table.Column<string>(type: "text", nullable: false)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_AspNetUserRoles", x => new { x.UserId, x.RoleId });
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "FK_AspNetUserRoles_AspNetRoles_RoleId",
|
||||||
|
column: x => x.RoleId,
|
||||||
|
principalTable: "AspNetRoles",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "FK_AspNetUserRoles_AspNetUsers_UserId",
|
||||||
|
column: x => x.UserId,
|
||||||
|
principalTable: "AspNetUsers",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "AspNetUserTokens",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
UserId = table.Column<string>(type: "text", nullable: false),
|
||||||
|
LoginProvider = table.Column<string>(type: "text", nullable: false),
|
||||||
|
Name = table.Column<string>(type: "text", nullable: false),
|
||||||
|
Value = table.Column<string>(type: "text", nullable: true)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_AspNetUserTokens", x => new { x.UserId, x.LoginProvider, x.Name });
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "FK_AspNetUserTokens_AspNetUsers_UserId",
|
||||||
|
column: x => x.UserId,
|
||||||
|
principalTable: "AspNetUsers",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_AspNetRoleClaims_RoleId",
|
||||||
|
table: "AspNetRoleClaims",
|
||||||
|
column: "RoleId");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "RoleNameIndex",
|
||||||
|
table: "AspNetRoles",
|
||||||
|
column: "NormalizedName",
|
||||||
|
unique: true);
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_AspNetUserClaims_UserId",
|
||||||
|
table: "AspNetUserClaims",
|
||||||
|
column: "UserId");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_AspNetUserLogins_UserId",
|
||||||
|
table: "AspNetUserLogins",
|
||||||
|
column: "UserId");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_AspNetUserRoles_RoleId",
|
||||||
|
table: "AspNetUserRoles",
|
||||||
|
column: "RoleId");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "EmailIndex",
|
||||||
|
table: "AspNetUsers",
|
||||||
|
column: "NormalizedEmail");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "UserNameIndex",
|
||||||
|
table: "AspNetUsers",
|
||||||
|
column: "NormalizedUserName",
|
||||||
|
unique: true);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "AspNetRoleClaims");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "AspNetUserClaims");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "AspNetUserLogins");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "AspNetUserRoles");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "AspNetUserTokens");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "AspNetRoles");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "AspNetUsers");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
501
Newsbot.Collector.Database/Migrations/20230710050618_SourcesRenamed.Designer.cs
generated
Normal file
501
Newsbot.Collector.Database/Migrations/20230710050618_SourcesRenamed.Designer.cs
generated
Normal file
@ -0,0 +1,501 @@
|
|||||||
|
// <auto-generated />
|
||||||
|
using System;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||||
|
using Newsbot.Collector.Database;
|
||||||
|
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace Newsbot.Collector.Database.Migrations
|
||||||
|
{
|
||||||
|
[DbContext(typeof(DatabaseContext))]
|
||||||
|
[Migration("20230710050618_SourcesRenamed")]
|
||||||
|
partial class SourcesRenamed
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||||
|
{
|
||||||
|
#pragma warning disable 612, 618
|
||||||
|
modelBuilder
|
||||||
|
.HasAnnotation("ProductVersion", "7.0.8")
|
||||||
|
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
||||||
|
|
||||||
|
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
||||||
|
|
||||||
|
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole", b =>
|
||||||
|
{
|
||||||
|
b.Property<string>("Id")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("ConcurrencyStamp")
|
||||||
|
.IsConcurrencyToken()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Name")
|
||||||
|
.HasMaxLength(256)
|
||||||
|
.HasColumnType("character varying(256)");
|
||||||
|
|
||||||
|
b.Property<string>("NormalizedName")
|
||||||
|
.HasMaxLength(256)
|
||||||
|
.HasColumnType("character varying(256)");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("NormalizedName")
|
||||||
|
.IsUnique()
|
||||||
|
.HasDatabaseName("RoleNameIndex");
|
||||||
|
|
||||||
|
b.ToTable("AspNetRoles", (string)null);
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<string>", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<string>("ClaimType")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("ClaimValue")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("RoleId")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("RoleId");
|
||||||
|
|
||||||
|
b.ToTable("AspNetRoleClaims", (string)null);
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUser", b =>
|
||||||
|
{
|
||||||
|
b.Property<string>("Id")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<int>("AccessFailedCount")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.Property<string>("ConcurrencyStamp")
|
||||||
|
.IsConcurrencyToken()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Email")
|
||||||
|
.HasMaxLength(256)
|
||||||
|
.HasColumnType("character varying(256)");
|
||||||
|
|
||||||
|
b.Property<bool>("EmailConfirmed")
|
||||||
|
.HasColumnType("boolean");
|
||||||
|
|
||||||
|
b.Property<bool>("LockoutEnabled")
|
||||||
|
.HasColumnType("boolean");
|
||||||
|
|
||||||
|
b.Property<DateTimeOffset?>("LockoutEnd")
|
||||||
|
.HasColumnType("timestamp with time zone");
|
||||||
|
|
||||||
|
b.Property<string>("NormalizedEmail")
|
||||||
|
.HasMaxLength(256)
|
||||||
|
.HasColumnType("character varying(256)");
|
||||||
|
|
||||||
|
b.Property<string>("NormalizedUserName")
|
||||||
|
.HasMaxLength(256)
|
||||||
|
.HasColumnType("character varying(256)");
|
||||||
|
|
||||||
|
b.Property<string>("PasswordHash")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("PhoneNumber")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<bool>("PhoneNumberConfirmed")
|
||||||
|
.HasColumnType("boolean");
|
||||||
|
|
||||||
|
b.Property<string>("SecurityStamp")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<bool>("TwoFactorEnabled")
|
||||||
|
.HasColumnType("boolean");
|
||||||
|
|
||||||
|
b.Property<string>("UserName")
|
||||||
|
.HasMaxLength(256)
|
||||||
|
.HasColumnType("character varying(256)");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("NormalizedEmail")
|
||||||
|
.HasDatabaseName("EmailIndex");
|
||||||
|
|
||||||
|
b.HasIndex("NormalizedUserName")
|
||||||
|
.IsUnique()
|
||||||
|
.HasDatabaseName("UserNameIndex");
|
||||||
|
|
||||||
|
b.ToTable("AspNetUsers", (string)null);
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<string>", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<string>("ClaimType")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("ClaimValue")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("UserId")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("UserId");
|
||||||
|
|
||||||
|
b.ToTable("AspNetUserClaims", (string)null);
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<string>", b =>
|
||||||
|
{
|
||||||
|
b.Property<string>("LoginProvider")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("ProviderKey")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("ProviderDisplayName")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("UserId")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.HasKey("LoginProvider", "ProviderKey");
|
||||||
|
|
||||||
|
b.HasIndex("UserId");
|
||||||
|
|
||||||
|
b.ToTable("AspNetUserLogins", (string)null);
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<string>", b =>
|
||||||
|
{
|
||||||
|
b.Property<string>("UserId")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("RoleId")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.HasKey("UserId", "RoleId");
|
||||||
|
|
||||||
|
b.HasIndex("RoleId");
|
||||||
|
|
||||||
|
b.ToTable("AspNetUserRoles", (string)null);
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<string>", b =>
|
||||||
|
{
|
||||||
|
b.Property<string>("UserId")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("LoginProvider")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Name")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Value")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.HasKey("UserId", "LoginProvider", "Name");
|
||||||
|
|
||||||
|
b.ToTable("AspNetUserTokens", (string)null);
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Newsbot.Collector.Domain.Entities.ArticlesEntity", b =>
|
||||||
|
{
|
||||||
|
b.Property<Guid>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<string>("AuthorImage")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("AuthorName")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<bool>("CodeIsCommit")
|
||||||
|
.HasColumnType("boolean");
|
||||||
|
|
||||||
|
b.Property<bool>("CodeIsRelease")
|
||||||
|
.HasColumnType("boolean");
|
||||||
|
|
||||||
|
b.Property<string>("Description")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<DateTime>("PubDate")
|
||||||
|
.HasColumnType("timestamp with time zone");
|
||||||
|
|
||||||
|
b.Property<Guid>("SourceId")
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<string>("Tags")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Thumbnail")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Title")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Url")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Video")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<int>("VideoHeight")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.Property<int>("VideoWidth")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Articles");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Newsbot.Collector.Domain.Entities.DiscordNotificationEntity", b =>
|
||||||
|
{
|
||||||
|
b.Property<Guid>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<bool>("CodeAllowCommits")
|
||||||
|
.HasColumnType("boolean");
|
||||||
|
|
||||||
|
b.Property<bool>("CodeAllowReleases")
|
||||||
|
.HasColumnType("boolean");
|
||||||
|
|
||||||
|
b.Property<Guid>("DiscordWebHookId")
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<Guid>("SourceId")
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("DiscordNotification");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Newsbot.Collector.Domain.Entities.DiscordQueueEntity", b =>
|
||||||
|
{
|
||||||
|
b.Property<Guid>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<Guid>("ArticleId")
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("DiscordQueue");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Newsbot.Collector.Domain.Entities.DiscordWebhookEntity", b =>
|
||||||
|
{
|
||||||
|
b.Property<Guid>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<string>("Channel")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<bool>("Enabled")
|
||||||
|
.HasColumnType("boolean");
|
||||||
|
|
||||||
|
b.Property<string>("Server")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Url")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("DiscordWebhooks");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Newsbot.Collector.Domain.Entities.IconEntity", b =>
|
||||||
|
{
|
||||||
|
b.Property<Guid>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<string>("FileName")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Site")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<Guid>("SourceId")
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Icons");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Newsbot.Collector.Domain.Entities.SourceEntity", b =>
|
||||||
|
{
|
||||||
|
b.Property<Guid>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<bool>("Deleted")
|
||||||
|
.HasColumnType("boolean");
|
||||||
|
|
||||||
|
b.Property<bool>("Enabled")
|
||||||
|
.HasColumnType("boolean");
|
||||||
|
|
||||||
|
b.Property<string>("Name")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Site")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Source")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Tags")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Type")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Url")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Value")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("YoutubeId")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Sources");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Newsbot.Collector.Domain.Entities.UserSourceSubscriptionEntity", b =>
|
||||||
|
{
|
||||||
|
b.Property<Guid>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<DateTimeOffset>("DateAdded")
|
||||||
|
.HasColumnType("timestamp with time zone");
|
||||||
|
|
||||||
|
b.Property<Guid>("SourceId")
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<string>("UserId")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("UserId");
|
||||||
|
|
||||||
|
b.ToTable("UserSourceSubscription");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<string>", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null)
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("RoleId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<string>", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null)
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("UserId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<string>", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null)
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("UserId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<string>", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null)
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("RoleId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null)
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("UserId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<string>", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null)
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("UserId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Newsbot.Collector.Domain.Entities.UserSourceSubscriptionEntity", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", "User")
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("UserId");
|
||||||
|
|
||||||
|
b.Navigation("User");
|
||||||
|
});
|
||||||
|
#pragma warning restore 612, 618
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,82 @@
|
|||||||
|
using System;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace Newsbot.Collector.Database.Migrations
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
public partial class SourcesRenamed : Migration
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "Subscriptions");
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "DiscordNotification",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
Id = table.Column<Guid>(type: "uuid", nullable: false),
|
||||||
|
CodeAllowReleases = table.Column<bool>(type: "boolean", nullable: false),
|
||||||
|
CodeAllowCommits = table.Column<bool>(type: "boolean", nullable: false),
|
||||||
|
SourceId = table.Column<Guid>(type: "uuid", nullable: false),
|
||||||
|
DiscordWebHookId = table.Column<Guid>(type: "uuid", nullable: false)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_DiscordNotification", x => x.Id);
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "UserSourceSubscription",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
Id = table.Column<Guid>(type: "uuid", nullable: false),
|
||||||
|
SourceId = table.Column<Guid>(type: "uuid", nullable: false),
|
||||||
|
DateAdded = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false),
|
||||||
|
UserId = table.Column<string>(type: "text", nullable: true)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_UserSourceSubscription", x => x.Id);
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "FK_UserSourceSubscription_AspNetUsers_UserId",
|
||||||
|
column: x => x.UserId,
|
||||||
|
principalTable: "AspNetUsers",
|
||||||
|
principalColumn: "Id");
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_UserSourceSubscription_UserId",
|
||||||
|
table: "UserSourceSubscription",
|
||||||
|
column: "UserId");
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "DiscordNotification");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "UserSourceSubscription");
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "Subscriptions",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
Id = table.Column<Guid>(type: "uuid", nullable: false),
|
||||||
|
CodeAllowCommits = table.Column<bool>(type: "boolean", nullable: false),
|
||||||
|
CodeAllowReleases = table.Column<bool>(type: "boolean", nullable: false),
|
||||||
|
DiscordWebHookId = table.Column<Guid>(type: "uuid", nullable: false),
|
||||||
|
SourceId = table.Column<Guid>(type: "uuid", nullable: false)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_Subscriptions", x => x.Id);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
504
Newsbot.Collector.Database/Migrations/20230710050913_DiscordNotificationOwnerAdded.Designer.cs
generated
Normal file
504
Newsbot.Collector.Database/Migrations/20230710050913_DiscordNotificationOwnerAdded.Designer.cs
generated
Normal file
@ -0,0 +1,504 @@
|
|||||||
|
// <auto-generated />
|
||||||
|
using System;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||||
|
using Newsbot.Collector.Database;
|
||||||
|
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace Newsbot.Collector.Database.Migrations
|
||||||
|
{
|
||||||
|
[DbContext(typeof(DatabaseContext))]
|
||||||
|
[Migration("20230710050913_DiscordNotificationOwnerAdded")]
|
||||||
|
partial class DiscordNotificationOwnerAdded
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||||
|
{
|
||||||
|
#pragma warning disable 612, 618
|
||||||
|
modelBuilder
|
||||||
|
.HasAnnotation("ProductVersion", "7.0.8")
|
||||||
|
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
||||||
|
|
||||||
|
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
||||||
|
|
||||||
|
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole", b =>
|
||||||
|
{
|
||||||
|
b.Property<string>("Id")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("ConcurrencyStamp")
|
||||||
|
.IsConcurrencyToken()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Name")
|
||||||
|
.HasMaxLength(256)
|
||||||
|
.HasColumnType("character varying(256)");
|
||||||
|
|
||||||
|
b.Property<string>("NormalizedName")
|
||||||
|
.HasMaxLength(256)
|
||||||
|
.HasColumnType("character varying(256)");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("NormalizedName")
|
||||||
|
.IsUnique()
|
||||||
|
.HasDatabaseName("RoleNameIndex");
|
||||||
|
|
||||||
|
b.ToTable("AspNetRoles", (string)null);
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<string>", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<string>("ClaimType")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("ClaimValue")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("RoleId")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("RoleId");
|
||||||
|
|
||||||
|
b.ToTable("AspNetRoleClaims", (string)null);
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUser", b =>
|
||||||
|
{
|
||||||
|
b.Property<string>("Id")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<int>("AccessFailedCount")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.Property<string>("ConcurrencyStamp")
|
||||||
|
.IsConcurrencyToken()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Email")
|
||||||
|
.HasMaxLength(256)
|
||||||
|
.HasColumnType("character varying(256)");
|
||||||
|
|
||||||
|
b.Property<bool>("EmailConfirmed")
|
||||||
|
.HasColumnType("boolean");
|
||||||
|
|
||||||
|
b.Property<bool>("LockoutEnabled")
|
||||||
|
.HasColumnType("boolean");
|
||||||
|
|
||||||
|
b.Property<DateTimeOffset?>("LockoutEnd")
|
||||||
|
.HasColumnType("timestamp with time zone");
|
||||||
|
|
||||||
|
b.Property<string>("NormalizedEmail")
|
||||||
|
.HasMaxLength(256)
|
||||||
|
.HasColumnType("character varying(256)");
|
||||||
|
|
||||||
|
b.Property<string>("NormalizedUserName")
|
||||||
|
.HasMaxLength(256)
|
||||||
|
.HasColumnType("character varying(256)");
|
||||||
|
|
||||||
|
b.Property<string>("PasswordHash")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("PhoneNumber")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<bool>("PhoneNumberConfirmed")
|
||||||
|
.HasColumnType("boolean");
|
||||||
|
|
||||||
|
b.Property<string>("SecurityStamp")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<bool>("TwoFactorEnabled")
|
||||||
|
.HasColumnType("boolean");
|
||||||
|
|
||||||
|
b.Property<string>("UserName")
|
||||||
|
.HasMaxLength(256)
|
||||||
|
.HasColumnType("character varying(256)");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("NormalizedEmail")
|
||||||
|
.HasDatabaseName("EmailIndex");
|
||||||
|
|
||||||
|
b.HasIndex("NormalizedUserName")
|
||||||
|
.IsUnique()
|
||||||
|
.HasDatabaseName("UserNameIndex");
|
||||||
|
|
||||||
|
b.ToTable("AspNetUsers", (string)null);
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<string>", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<string>("ClaimType")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("ClaimValue")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("UserId")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("UserId");
|
||||||
|
|
||||||
|
b.ToTable("AspNetUserClaims", (string)null);
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<string>", b =>
|
||||||
|
{
|
||||||
|
b.Property<string>("LoginProvider")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("ProviderKey")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("ProviderDisplayName")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("UserId")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.HasKey("LoginProvider", "ProviderKey");
|
||||||
|
|
||||||
|
b.HasIndex("UserId");
|
||||||
|
|
||||||
|
b.ToTable("AspNetUserLogins", (string)null);
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<string>", b =>
|
||||||
|
{
|
||||||
|
b.Property<string>("UserId")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("RoleId")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.HasKey("UserId", "RoleId");
|
||||||
|
|
||||||
|
b.HasIndex("RoleId");
|
||||||
|
|
||||||
|
b.ToTable("AspNetUserRoles", (string)null);
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<string>", b =>
|
||||||
|
{
|
||||||
|
b.Property<string>("UserId")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("LoginProvider")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Name")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Value")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.HasKey("UserId", "LoginProvider", "Name");
|
||||||
|
|
||||||
|
b.ToTable("AspNetUserTokens", (string)null);
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Newsbot.Collector.Domain.Entities.ArticlesEntity", b =>
|
||||||
|
{
|
||||||
|
b.Property<Guid>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<string>("AuthorImage")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("AuthorName")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<bool>("CodeIsCommit")
|
||||||
|
.HasColumnType("boolean");
|
||||||
|
|
||||||
|
b.Property<bool>("CodeIsRelease")
|
||||||
|
.HasColumnType("boolean");
|
||||||
|
|
||||||
|
b.Property<string>("Description")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<DateTime>("PubDate")
|
||||||
|
.HasColumnType("timestamp with time zone");
|
||||||
|
|
||||||
|
b.Property<Guid>("SourceId")
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<string>("Tags")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Thumbnail")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Title")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Url")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Video")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<int>("VideoHeight")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.Property<int>("VideoWidth")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Articles");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Newsbot.Collector.Domain.Entities.DiscordNotificationEntity", b =>
|
||||||
|
{
|
||||||
|
b.Property<Guid>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<bool>("CodeAllowCommits")
|
||||||
|
.HasColumnType("boolean");
|
||||||
|
|
||||||
|
b.Property<bool>("CodeAllowReleases")
|
||||||
|
.HasColumnType("boolean");
|
||||||
|
|
||||||
|
b.Property<Guid>("DiscordWebHookId")
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<Guid>("SourceId")
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<string>("UserId")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("DiscordNotification");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Newsbot.Collector.Domain.Entities.DiscordQueueEntity", b =>
|
||||||
|
{
|
||||||
|
b.Property<Guid>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<Guid>("ArticleId")
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("DiscordQueue");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Newsbot.Collector.Domain.Entities.DiscordWebhookEntity", b =>
|
||||||
|
{
|
||||||
|
b.Property<Guid>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<string>("Channel")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<bool>("Enabled")
|
||||||
|
.HasColumnType("boolean");
|
||||||
|
|
||||||
|
b.Property<string>("Server")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Url")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("DiscordWebhooks");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Newsbot.Collector.Domain.Entities.IconEntity", b =>
|
||||||
|
{
|
||||||
|
b.Property<Guid>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<string>("FileName")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Site")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<Guid>("SourceId")
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Icons");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Newsbot.Collector.Domain.Entities.SourceEntity", b =>
|
||||||
|
{
|
||||||
|
b.Property<Guid>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<bool>("Deleted")
|
||||||
|
.HasColumnType("boolean");
|
||||||
|
|
||||||
|
b.Property<bool>("Enabled")
|
||||||
|
.HasColumnType("boolean");
|
||||||
|
|
||||||
|
b.Property<string>("Name")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Site")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Source")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Tags")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Type")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Url")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Value")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("YoutubeId")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Sources");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Newsbot.Collector.Domain.Entities.UserSourceSubscriptionEntity", b =>
|
||||||
|
{
|
||||||
|
b.Property<Guid>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<DateTimeOffset>("DateAdded")
|
||||||
|
.HasColumnType("timestamp with time zone");
|
||||||
|
|
||||||
|
b.Property<Guid>("SourceId")
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<string>("UserId")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("UserId");
|
||||||
|
|
||||||
|
b.ToTable("UserSourceSubscription");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<string>", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null)
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("RoleId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<string>", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null)
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("UserId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<string>", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null)
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("UserId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<string>", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null)
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("RoleId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null)
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("UserId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<string>", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null)
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("UserId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Newsbot.Collector.Domain.Entities.UserSourceSubscriptionEntity", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", "User")
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("UserId");
|
||||||
|
|
||||||
|
b.Navigation("User");
|
||||||
|
});
|
||||||
|
#pragma warning restore 612, 618
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,28 @@
|
|||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace Newsbot.Collector.Database.Migrations
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
public partial class DiscordNotificationOwnerAdded : Migration
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.AddColumn<string>(
|
||||||
|
name: "UserId",
|
||||||
|
table: "DiscordNotification",
|
||||||
|
type: "text",
|
||||||
|
nullable: true);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "UserId",
|
||||||
|
table: "DiscordNotification");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
543
Newsbot.Collector.Database/Migrations/20230711033558_add_jwt_token_refresh_table.Designer.cs
generated
Normal file
543
Newsbot.Collector.Database/Migrations/20230711033558_add_jwt_token_refresh_table.Designer.cs
generated
Normal file
@ -0,0 +1,543 @@
|
|||||||
|
// <auto-generated />
|
||||||
|
using System;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||||
|
using Newsbot.Collector.Database;
|
||||||
|
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace Newsbot.Collector.Database.Migrations
|
||||||
|
{
|
||||||
|
[DbContext(typeof(DatabaseContext))]
|
||||||
|
[Migration("20230711033558_add_jwt_token_refresh_table")]
|
||||||
|
partial class add_jwt_token_refresh_table
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||||
|
{
|
||||||
|
#pragma warning disable 612, 618
|
||||||
|
modelBuilder
|
||||||
|
.HasAnnotation("ProductVersion", "7.0.8")
|
||||||
|
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
||||||
|
|
||||||
|
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
||||||
|
|
||||||
|
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole", b =>
|
||||||
|
{
|
||||||
|
b.Property<string>("Id")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("ConcurrencyStamp")
|
||||||
|
.IsConcurrencyToken()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Name")
|
||||||
|
.HasMaxLength(256)
|
||||||
|
.HasColumnType("character varying(256)");
|
||||||
|
|
||||||
|
b.Property<string>("NormalizedName")
|
||||||
|
.HasMaxLength(256)
|
||||||
|
.HasColumnType("character varying(256)");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("NormalizedName")
|
||||||
|
.IsUnique()
|
||||||
|
.HasDatabaseName("RoleNameIndex");
|
||||||
|
|
||||||
|
b.ToTable("AspNetRoles", (string)null);
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<string>", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<string>("ClaimType")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("ClaimValue")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("RoleId")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("RoleId");
|
||||||
|
|
||||||
|
b.ToTable("AspNetRoleClaims", (string)null);
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUser", b =>
|
||||||
|
{
|
||||||
|
b.Property<string>("Id")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<int>("AccessFailedCount")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.Property<string>("ConcurrencyStamp")
|
||||||
|
.IsConcurrencyToken()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Email")
|
||||||
|
.HasMaxLength(256)
|
||||||
|
.HasColumnType("character varying(256)");
|
||||||
|
|
||||||
|
b.Property<bool>("EmailConfirmed")
|
||||||
|
.HasColumnType("boolean");
|
||||||
|
|
||||||
|
b.Property<bool>("LockoutEnabled")
|
||||||
|
.HasColumnType("boolean");
|
||||||
|
|
||||||
|
b.Property<DateTimeOffset?>("LockoutEnd")
|
||||||
|
.HasColumnType("timestamp with time zone");
|
||||||
|
|
||||||
|
b.Property<string>("NormalizedEmail")
|
||||||
|
.HasMaxLength(256)
|
||||||
|
.HasColumnType("character varying(256)");
|
||||||
|
|
||||||
|
b.Property<string>("NormalizedUserName")
|
||||||
|
.HasMaxLength(256)
|
||||||
|
.HasColumnType("character varying(256)");
|
||||||
|
|
||||||
|
b.Property<string>("PasswordHash")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("PhoneNumber")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<bool>("PhoneNumberConfirmed")
|
||||||
|
.HasColumnType("boolean");
|
||||||
|
|
||||||
|
b.Property<string>("SecurityStamp")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<bool>("TwoFactorEnabled")
|
||||||
|
.HasColumnType("boolean");
|
||||||
|
|
||||||
|
b.Property<string>("UserName")
|
||||||
|
.HasMaxLength(256)
|
||||||
|
.HasColumnType("character varying(256)");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("NormalizedEmail")
|
||||||
|
.HasDatabaseName("EmailIndex");
|
||||||
|
|
||||||
|
b.HasIndex("NormalizedUserName")
|
||||||
|
.IsUnique()
|
||||||
|
.HasDatabaseName("UserNameIndex");
|
||||||
|
|
||||||
|
b.ToTable("AspNetUsers", (string)null);
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<string>", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<string>("ClaimType")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("ClaimValue")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("UserId")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("UserId");
|
||||||
|
|
||||||
|
b.ToTable("AspNetUserClaims", (string)null);
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<string>", b =>
|
||||||
|
{
|
||||||
|
b.Property<string>("LoginProvider")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("ProviderKey")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("ProviderDisplayName")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("UserId")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.HasKey("LoginProvider", "ProviderKey");
|
||||||
|
|
||||||
|
b.HasIndex("UserId");
|
||||||
|
|
||||||
|
b.ToTable("AspNetUserLogins", (string)null);
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<string>", b =>
|
||||||
|
{
|
||||||
|
b.Property<string>("UserId")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("RoleId")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.HasKey("UserId", "RoleId");
|
||||||
|
|
||||||
|
b.HasIndex("RoleId");
|
||||||
|
|
||||||
|
b.ToTable("AspNetUserRoles", (string)null);
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<string>", b =>
|
||||||
|
{
|
||||||
|
b.Property<string>("UserId")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("LoginProvider")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Name")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Value")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.HasKey("UserId", "LoginProvider", "Name");
|
||||||
|
|
||||||
|
b.ToTable("AspNetUserTokens", (string)null);
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Newsbot.Collector.Domain.Entities.ArticlesEntity", b =>
|
||||||
|
{
|
||||||
|
b.Property<Guid>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<string>("AuthorImage")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("AuthorName")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<bool>("CodeIsCommit")
|
||||||
|
.HasColumnType("boolean");
|
||||||
|
|
||||||
|
b.Property<bool>("CodeIsRelease")
|
||||||
|
.HasColumnType("boolean");
|
||||||
|
|
||||||
|
b.Property<string>("Description")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<DateTime>("PubDate")
|
||||||
|
.HasColumnType("timestamp with time zone");
|
||||||
|
|
||||||
|
b.Property<Guid>("SourceId")
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<string>("Tags")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Thumbnail")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Title")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Url")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Video")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<int>("VideoHeight")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.Property<int>("VideoWidth")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Articles");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Newsbot.Collector.Domain.Entities.DiscordNotificationEntity", b =>
|
||||||
|
{
|
||||||
|
b.Property<Guid>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<bool>("CodeAllowCommits")
|
||||||
|
.HasColumnType("boolean");
|
||||||
|
|
||||||
|
b.Property<bool>("CodeAllowReleases")
|
||||||
|
.HasColumnType("boolean");
|
||||||
|
|
||||||
|
b.Property<Guid>("DiscordWebHookId")
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<Guid>("SourceId")
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<string>("UserId")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("DiscordNotification");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Newsbot.Collector.Domain.Entities.DiscordQueueEntity", b =>
|
||||||
|
{
|
||||||
|
b.Property<Guid>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<Guid>("ArticleId")
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("DiscordQueue");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Newsbot.Collector.Domain.Entities.DiscordWebhookEntity", b =>
|
||||||
|
{
|
||||||
|
b.Property<Guid>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<string>("Channel")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<bool>("Enabled")
|
||||||
|
.HasColumnType("boolean");
|
||||||
|
|
||||||
|
b.Property<string>("Server")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Url")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("DiscordWebhooks");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Newsbot.Collector.Domain.Entities.IconEntity", b =>
|
||||||
|
{
|
||||||
|
b.Property<Guid>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<string>("FileName")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Site")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<Guid>("SourceId")
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Icons");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Newsbot.Collector.Domain.Entities.RefreshTokenEntity", b =>
|
||||||
|
{
|
||||||
|
b.Property<string>("Token")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<DateTime>("CreatedDate")
|
||||||
|
.HasColumnType("timestamp with time zone");
|
||||||
|
|
||||||
|
b.Property<DateTime>("ExpiryDate")
|
||||||
|
.HasColumnType("timestamp with time zone");
|
||||||
|
|
||||||
|
b.Property<bool>("Invalidated")
|
||||||
|
.HasColumnType("boolean");
|
||||||
|
|
||||||
|
b.Property<string>("JwtId")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<bool>("Used")
|
||||||
|
.HasColumnType("boolean");
|
||||||
|
|
||||||
|
b.Property<string>("UserId")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.HasKey("Token");
|
||||||
|
|
||||||
|
b.HasIndex("UserId");
|
||||||
|
|
||||||
|
b.ToTable("RefreshTokens");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Newsbot.Collector.Domain.Entities.SourceEntity", b =>
|
||||||
|
{
|
||||||
|
b.Property<Guid>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<bool>("Deleted")
|
||||||
|
.HasColumnType("boolean");
|
||||||
|
|
||||||
|
b.Property<bool>("Enabled")
|
||||||
|
.HasColumnType("boolean");
|
||||||
|
|
||||||
|
b.Property<string>("Name")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Site")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Source")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Tags")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Type")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Url")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Value")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("YoutubeId")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Sources");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Newsbot.Collector.Domain.Entities.UserSourceSubscriptionEntity", b =>
|
||||||
|
{
|
||||||
|
b.Property<Guid>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<DateTimeOffset>("DateAdded")
|
||||||
|
.HasColumnType("timestamp with time zone");
|
||||||
|
|
||||||
|
b.Property<Guid>("SourceId")
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<string>("UserId")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("UserId");
|
||||||
|
|
||||||
|
b.ToTable("UserSourceSubscription");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<string>", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null)
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("RoleId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<string>", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null)
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("UserId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<string>", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null)
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("UserId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<string>", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null)
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("RoleId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null)
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("UserId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<string>", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null)
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("UserId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Newsbot.Collector.Domain.Entities.RefreshTokenEntity", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", "User")
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("UserId");
|
||||||
|
|
||||||
|
b.Navigation("User");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Newsbot.Collector.Domain.Entities.UserSourceSubscriptionEntity", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", "User")
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("UserId");
|
||||||
|
|
||||||
|
b.Navigation("User");
|
||||||
|
});
|
||||||
|
#pragma warning restore 612, 618
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,49 @@
|
|||||||
|
using System;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace Newsbot.Collector.Database.Migrations
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
public partial class add_jwt_token_refresh_table : Migration
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "RefreshTokens",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
Token = table.Column<string>(type: "text", nullable: false),
|
||||||
|
JwtId = table.Column<string>(type: "text", nullable: true),
|
||||||
|
CreatedDate = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
|
||||||
|
ExpiryDate = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
|
||||||
|
Used = table.Column<bool>(type: "boolean", nullable: false),
|
||||||
|
Invalidated = table.Column<bool>(type: "boolean", nullable: false),
|
||||||
|
UserId = table.Column<string>(type: "text", nullable: true)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_RefreshTokens", x => x.Token);
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "FK_RefreshTokens_AspNetUsers_UserId",
|
||||||
|
column: x => x.UserId,
|
||||||
|
principalTable: "AspNetUsers",
|
||||||
|
principalColumn: "Id");
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_RefreshTokens_UserId",
|
||||||
|
table: "RefreshTokens",
|
||||||
|
column: "UserId");
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "RefreshTokens");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
579
Newsbot.Collector.Database/Migrations/20230729170139_Adding Author Table.Designer.cs
generated
Normal file
579
Newsbot.Collector.Database/Migrations/20230729170139_Adding Author Table.Designer.cs
generated
Normal file
@ -0,0 +1,579 @@
|
|||||||
|
// <auto-generated />
|
||||||
|
using System;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||||
|
using Newsbot.Collector.Database;
|
||||||
|
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace Newsbot.Collector.Database.Migrations
|
||||||
|
{
|
||||||
|
[DbContext(typeof(DatabaseContext))]
|
||||||
|
[Migration("20230729170139_Adding Author Table")]
|
||||||
|
partial class AddingAuthorTable
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||||
|
{
|
||||||
|
#pragma warning disable 612, 618
|
||||||
|
modelBuilder
|
||||||
|
.HasAnnotation("ProductVersion", "7.0.8")
|
||||||
|
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
||||||
|
|
||||||
|
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
||||||
|
|
||||||
|
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole", b =>
|
||||||
|
{
|
||||||
|
b.Property<string>("Id")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("ConcurrencyStamp")
|
||||||
|
.IsConcurrencyToken()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Name")
|
||||||
|
.HasMaxLength(256)
|
||||||
|
.HasColumnType("character varying(256)");
|
||||||
|
|
||||||
|
b.Property<string>("NormalizedName")
|
||||||
|
.HasMaxLength(256)
|
||||||
|
.HasColumnType("character varying(256)");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("NormalizedName")
|
||||||
|
.IsUnique()
|
||||||
|
.HasDatabaseName("RoleNameIndex");
|
||||||
|
|
||||||
|
b.ToTable("AspNetRoles", (string)null);
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<string>", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<string>("ClaimType")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("ClaimValue")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("RoleId")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("RoleId");
|
||||||
|
|
||||||
|
b.ToTable("AspNetRoleClaims", (string)null);
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUser", b =>
|
||||||
|
{
|
||||||
|
b.Property<string>("Id")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<int>("AccessFailedCount")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.Property<string>("ConcurrencyStamp")
|
||||||
|
.IsConcurrencyToken()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Email")
|
||||||
|
.HasMaxLength(256)
|
||||||
|
.HasColumnType("character varying(256)");
|
||||||
|
|
||||||
|
b.Property<bool>("EmailConfirmed")
|
||||||
|
.HasColumnType("boolean");
|
||||||
|
|
||||||
|
b.Property<bool>("LockoutEnabled")
|
||||||
|
.HasColumnType("boolean");
|
||||||
|
|
||||||
|
b.Property<DateTimeOffset?>("LockoutEnd")
|
||||||
|
.HasColumnType("timestamp with time zone");
|
||||||
|
|
||||||
|
b.Property<string>("NormalizedEmail")
|
||||||
|
.HasMaxLength(256)
|
||||||
|
.HasColumnType("character varying(256)");
|
||||||
|
|
||||||
|
b.Property<string>("NormalizedUserName")
|
||||||
|
.HasMaxLength(256)
|
||||||
|
.HasColumnType("character varying(256)");
|
||||||
|
|
||||||
|
b.Property<string>("PasswordHash")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("PhoneNumber")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<bool>("PhoneNumberConfirmed")
|
||||||
|
.HasColumnType("boolean");
|
||||||
|
|
||||||
|
b.Property<string>("SecurityStamp")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<bool>("TwoFactorEnabled")
|
||||||
|
.HasColumnType("boolean");
|
||||||
|
|
||||||
|
b.Property<string>("UserName")
|
||||||
|
.HasMaxLength(256)
|
||||||
|
.HasColumnType("character varying(256)");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("NormalizedEmail")
|
||||||
|
.HasDatabaseName("EmailIndex");
|
||||||
|
|
||||||
|
b.HasIndex("NormalizedUserName")
|
||||||
|
.IsUnique()
|
||||||
|
.HasDatabaseName("UserNameIndex");
|
||||||
|
|
||||||
|
b.ToTable("AspNetUsers", (string)null);
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<string>", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<string>("ClaimType")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("ClaimValue")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("UserId")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("UserId");
|
||||||
|
|
||||||
|
b.ToTable("AspNetUserClaims", (string)null);
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<string>", b =>
|
||||||
|
{
|
||||||
|
b.Property<string>("LoginProvider")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("ProviderKey")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("ProviderDisplayName")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("UserId")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.HasKey("LoginProvider", "ProviderKey");
|
||||||
|
|
||||||
|
b.HasIndex("UserId");
|
||||||
|
|
||||||
|
b.ToTable("AspNetUserLogins", (string)null);
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<string>", b =>
|
||||||
|
{
|
||||||
|
b.Property<string>("UserId")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("RoleId")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.HasKey("UserId", "RoleId");
|
||||||
|
|
||||||
|
b.HasIndex("RoleId");
|
||||||
|
|
||||||
|
b.ToTable("AspNetUserRoles", (string)null);
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<string>", b =>
|
||||||
|
{
|
||||||
|
b.Property<string>("UserId")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("LoginProvider")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Name")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Value")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.HasKey("UserId", "LoginProvider", "Name");
|
||||||
|
|
||||||
|
b.ToTable("AspNetUserTokens", (string)null);
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Newsbot.Collector.Domain.Entities.ArticlesEntity", b =>
|
||||||
|
{
|
||||||
|
b.Property<Guid>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<string>("AuthorImage")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("AuthorName")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<bool>("CodeIsCommit")
|
||||||
|
.HasColumnType("boolean");
|
||||||
|
|
||||||
|
b.Property<bool>("CodeIsRelease")
|
||||||
|
.HasColumnType("boolean");
|
||||||
|
|
||||||
|
b.Property<string>("Description")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<DateTime>("PubDate")
|
||||||
|
.HasColumnType("timestamp with time zone");
|
||||||
|
|
||||||
|
b.Property<Guid>("SourceId")
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<string>("Tags")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Thumbnail")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Title")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Url")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Video")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<int>("VideoHeight")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.Property<int>("VideoWidth")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Articles");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Newsbot.Collector.Domain.Entities.AuthorEntity", b =>
|
||||||
|
{
|
||||||
|
b.Property<Guid>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<string>("Image")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Name")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<Guid>("SourceId")
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Authors");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Newsbot.Collector.Domain.Entities.DiscordNotificationEntity", b =>
|
||||||
|
{
|
||||||
|
b.Property<Guid>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<bool>("CodeAllowCommits")
|
||||||
|
.HasColumnType("boolean");
|
||||||
|
|
||||||
|
b.Property<bool>("CodeAllowReleases")
|
||||||
|
.HasColumnType("boolean");
|
||||||
|
|
||||||
|
b.Property<Guid>("DiscordWebHookId")
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<Guid>("SourceId")
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<string>("UserId")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("DiscordNotification");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Newsbot.Collector.Domain.Entities.DiscordQueueEntity", b =>
|
||||||
|
{
|
||||||
|
b.Property<Guid>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<Guid>("ArticleId")
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("DiscordQueue");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Newsbot.Collector.Domain.Entities.DiscordWebhookEntity", b =>
|
||||||
|
{
|
||||||
|
b.Property<Guid>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<string>("Channel")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<bool>("Enabled")
|
||||||
|
.HasColumnType("boolean");
|
||||||
|
|
||||||
|
b.Property<string>("Server")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Url")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("UserId")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("UserId");
|
||||||
|
|
||||||
|
b.ToTable("DiscordWebhooks");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Newsbot.Collector.Domain.Entities.IconEntity", b =>
|
||||||
|
{
|
||||||
|
b.Property<Guid>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<string>("FileName")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Site")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<Guid>("SourceId")
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Icons");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Newsbot.Collector.Domain.Entities.RefreshTokenEntity", b =>
|
||||||
|
{
|
||||||
|
b.Property<string>("Token")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<DateTime>("CreatedDate")
|
||||||
|
.HasColumnType("timestamp with time zone");
|
||||||
|
|
||||||
|
b.Property<DateTime>("ExpiryDate")
|
||||||
|
.HasColumnType("timestamp with time zone");
|
||||||
|
|
||||||
|
b.Property<bool>("Invalidated")
|
||||||
|
.HasColumnType("boolean");
|
||||||
|
|
||||||
|
b.Property<string>("JwtId")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<bool>("Used")
|
||||||
|
.HasColumnType("boolean");
|
||||||
|
|
||||||
|
b.Property<string>("UserId")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.HasKey("Token");
|
||||||
|
|
||||||
|
b.HasIndex("UserId");
|
||||||
|
|
||||||
|
b.ToTable("RefreshTokens");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Newsbot.Collector.Domain.Entities.SourceEntity", b =>
|
||||||
|
{
|
||||||
|
b.Property<Guid>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<bool>("Deleted")
|
||||||
|
.HasColumnType("boolean");
|
||||||
|
|
||||||
|
b.Property<bool>("Enabled")
|
||||||
|
.HasColumnType("boolean");
|
||||||
|
|
||||||
|
b.Property<string>("Name")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Site")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Source")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Tags")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Type")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Url")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Value")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("YoutubeId")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Sources");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Newsbot.Collector.Domain.Entities.UserSourceSubscriptionEntity", b =>
|
||||||
|
{
|
||||||
|
b.Property<Guid>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<DateTimeOffset>("DateAdded")
|
||||||
|
.HasColumnType("timestamp with time zone");
|
||||||
|
|
||||||
|
b.Property<Guid>("SourceId")
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<string>("UserId")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("UserId");
|
||||||
|
|
||||||
|
b.ToTable("UserSourceSubscription");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<string>", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null)
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("RoleId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<string>", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null)
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("UserId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<string>", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null)
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("UserId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<string>", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null)
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("RoleId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null)
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("UserId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<string>", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null)
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("UserId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Newsbot.Collector.Domain.Entities.DiscordWebhookEntity", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", "User")
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("UserId");
|
||||||
|
|
||||||
|
b.Navigation("User");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Newsbot.Collector.Domain.Entities.RefreshTokenEntity", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", "User")
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("UserId");
|
||||||
|
|
||||||
|
b.Navigation("User");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Newsbot.Collector.Domain.Entities.UserSourceSubscriptionEntity", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", "User")
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("UserId");
|
||||||
|
|
||||||
|
b.Navigation("User");
|
||||||
|
});
|
||||||
|
#pragma warning restore 612, 618
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,66 @@
|
|||||||
|
using System;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace Newsbot.Collector.Database.Migrations
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
public partial class AddingAuthorTable : Migration
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.AddColumn<string>(
|
||||||
|
name: "UserId",
|
||||||
|
table: "DiscordWebhooks",
|
||||||
|
type: "text",
|
||||||
|
nullable: true);
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "Authors",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
Id = table.Column<Guid>(type: "uuid", nullable: false),
|
||||||
|
SourceId = table.Column<Guid>(type: "uuid", nullable: false),
|
||||||
|
Name = table.Column<string>(type: "text", nullable: false),
|
||||||
|
Image = table.Column<string>(type: "text", nullable: false)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_Authors", x => x.Id);
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_DiscordWebhooks_UserId",
|
||||||
|
table: "DiscordWebhooks",
|
||||||
|
column: "UserId");
|
||||||
|
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_DiscordWebhooks_AspNetUsers_UserId",
|
||||||
|
table: "DiscordWebhooks",
|
||||||
|
column: "UserId",
|
||||||
|
principalTable: "AspNetUsers",
|
||||||
|
principalColumn: "Id");
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropForeignKey(
|
||||||
|
name: "FK_DiscordWebhooks_AspNetUsers_UserId",
|
||||||
|
table: "DiscordWebhooks");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "Authors");
|
||||||
|
|
||||||
|
migrationBuilder.DropIndex(
|
||||||
|
name: "IX_DiscordWebhooks_UserId",
|
||||||
|
table: "DiscordWebhooks");
|
||||||
|
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "UserId",
|
||||||
|
table: "DiscordWebhooks");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
575
Newsbot.Collector.Database/Migrations/20230805060324_add author table.Designer.cs
generated
Normal file
575
Newsbot.Collector.Database/Migrations/20230805060324_add author table.Designer.cs
generated
Normal file
@ -0,0 +1,575 @@
|
|||||||
|
// <auto-generated />
|
||||||
|
using System;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||||
|
using Newsbot.Collector.Database;
|
||||||
|
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace Newsbot.Collector.Database.Migrations
|
||||||
|
{
|
||||||
|
[DbContext(typeof(DatabaseContext))]
|
||||||
|
[Migration("20230805060324_add author table")]
|
||||||
|
partial class addauthortable
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||||
|
{
|
||||||
|
#pragma warning disable 612, 618
|
||||||
|
modelBuilder
|
||||||
|
.HasAnnotation("ProductVersion", "7.0.8")
|
||||||
|
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
||||||
|
|
||||||
|
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
||||||
|
|
||||||
|
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole", b =>
|
||||||
|
{
|
||||||
|
b.Property<string>("Id")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("ConcurrencyStamp")
|
||||||
|
.IsConcurrencyToken()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Name")
|
||||||
|
.HasMaxLength(256)
|
||||||
|
.HasColumnType("character varying(256)");
|
||||||
|
|
||||||
|
b.Property<string>("NormalizedName")
|
||||||
|
.HasMaxLength(256)
|
||||||
|
.HasColumnType("character varying(256)");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("NormalizedName")
|
||||||
|
.IsUnique()
|
||||||
|
.HasDatabaseName("RoleNameIndex");
|
||||||
|
|
||||||
|
b.ToTable("AspNetRoles", (string)null);
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<string>", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<string>("ClaimType")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("ClaimValue")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("RoleId")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("RoleId");
|
||||||
|
|
||||||
|
b.ToTable("AspNetRoleClaims", (string)null);
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUser", b =>
|
||||||
|
{
|
||||||
|
b.Property<string>("Id")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<int>("AccessFailedCount")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.Property<string>("ConcurrencyStamp")
|
||||||
|
.IsConcurrencyToken()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Email")
|
||||||
|
.HasMaxLength(256)
|
||||||
|
.HasColumnType("character varying(256)");
|
||||||
|
|
||||||
|
b.Property<bool>("EmailConfirmed")
|
||||||
|
.HasColumnType("boolean");
|
||||||
|
|
||||||
|
b.Property<bool>("LockoutEnabled")
|
||||||
|
.HasColumnType("boolean");
|
||||||
|
|
||||||
|
b.Property<DateTimeOffset?>("LockoutEnd")
|
||||||
|
.HasColumnType("timestamp with time zone");
|
||||||
|
|
||||||
|
b.Property<string>("NormalizedEmail")
|
||||||
|
.HasMaxLength(256)
|
||||||
|
.HasColumnType("character varying(256)");
|
||||||
|
|
||||||
|
b.Property<string>("NormalizedUserName")
|
||||||
|
.HasMaxLength(256)
|
||||||
|
.HasColumnType("character varying(256)");
|
||||||
|
|
||||||
|
b.Property<string>("PasswordHash")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("PhoneNumber")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<bool>("PhoneNumberConfirmed")
|
||||||
|
.HasColumnType("boolean");
|
||||||
|
|
||||||
|
b.Property<string>("SecurityStamp")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<bool>("TwoFactorEnabled")
|
||||||
|
.HasColumnType("boolean");
|
||||||
|
|
||||||
|
b.Property<string>("UserName")
|
||||||
|
.HasMaxLength(256)
|
||||||
|
.HasColumnType("character varying(256)");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("NormalizedEmail")
|
||||||
|
.HasDatabaseName("EmailIndex");
|
||||||
|
|
||||||
|
b.HasIndex("NormalizedUserName")
|
||||||
|
.IsUnique()
|
||||||
|
.HasDatabaseName("UserNameIndex");
|
||||||
|
|
||||||
|
b.ToTable("AspNetUsers", (string)null);
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<string>", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<string>("ClaimType")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("ClaimValue")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("UserId")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("UserId");
|
||||||
|
|
||||||
|
b.ToTable("AspNetUserClaims", (string)null);
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<string>", b =>
|
||||||
|
{
|
||||||
|
b.Property<string>("LoginProvider")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("ProviderKey")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("ProviderDisplayName")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("UserId")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.HasKey("LoginProvider", "ProviderKey");
|
||||||
|
|
||||||
|
b.HasIndex("UserId");
|
||||||
|
|
||||||
|
b.ToTable("AspNetUserLogins", (string)null);
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<string>", b =>
|
||||||
|
{
|
||||||
|
b.Property<string>("UserId")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("RoleId")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.HasKey("UserId", "RoleId");
|
||||||
|
|
||||||
|
b.HasIndex("RoleId");
|
||||||
|
|
||||||
|
b.ToTable("AspNetUserRoles", (string)null);
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<string>", b =>
|
||||||
|
{
|
||||||
|
b.Property<string>("UserId")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("LoginProvider")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Name")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Value")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.HasKey("UserId", "LoginProvider", "Name");
|
||||||
|
|
||||||
|
b.ToTable("AspNetUserTokens", (string)null);
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Newsbot.Collector.Domain.Entities.ArticlesEntity", b =>
|
||||||
|
{
|
||||||
|
b.Property<Guid>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<Guid>("AuthorId")
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<bool>("CodeIsCommit")
|
||||||
|
.HasColumnType("boolean");
|
||||||
|
|
||||||
|
b.Property<bool>("CodeIsRelease")
|
||||||
|
.HasColumnType("boolean");
|
||||||
|
|
||||||
|
b.Property<string>("Description")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<DateTime>("PubDate")
|
||||||
|
.HasColumnType("timestamp with time zone");
|
||||||
|
|
||||||
|
b.Property<Guid>("SourceId")
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<string>("Tags")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Thumbnail")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Title")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Url")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Video")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<int>("VideoHeight")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.Property<int>("VideoWidth")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Articles");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Newsbot.Collector.Domain.Entities.AuthorEntity", b =>
|
||||||
|
{
|
||||||
|
b.Property<Guid>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<string>("Image")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Name")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<Guid>("SourceId")
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Authors");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Newsbot.Collector.Domain.Entities.DiscordNotificationEntity", b =>
|
||||||
|
{
|
||||||
|
b.Property<Guid>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<bool>("CodeAllowCommits")
|
||||||
|
.HasColumnType("boolean");
|
||||||
|
|
||||||
|
b.Property<bool>("CodeAllowReleases")
|
||||||
|
.HasColumnType("boolean");
|
||||||
|
|
||||||
|
b.Property<Guid>("DiscordWebHookId")
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<Guid>("SourceId")
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<string>("UserId")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("DiscordNotification");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Newsbot.Collector.Domain.Entities.DiscordQueueEntity", b =>
|
||||||
|
{
|
||||||
|
b.Property<Guid>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<Guid>("ArticleId")
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("DiscordQueue");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Newsbot.Collector.Domain.Entities.DiscordWebhookEntity", b =>
|
||||||
|
{
|
||||||
|
b.Property<Guid>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<string>("Channel")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<bool>("Enabled")
|
||||||
|
.HasColumnType("boolean");
|
||||||
|
|
||||||
|
b.Property<string>("Server")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Url")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("UserId")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("UserId");
|
||||||
|
|
||||||
|
b.ToTable("DiscordWebhooks");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Newsbot.Collector.Domain.Entities.IconEntity", b =>
|
||||||
|
{
|
||||||
|
b.Property<Guid>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<string>("FileName")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Site")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<Guid>("SourceId")
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Icons");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Newsbot.Collector.Domain.Entities.RefreshTokenEntity", b =>
|
||||||
|
{
|
||||||
|
b.Property<string>("Token")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<DateTime>("CreatedDate")
|
||||||
|
.HasColumnType("timestamp with time zone");
|
||||||
|
|
||||||
|
b.Property<DateTime>("ExpiryDate")
|
||||||
|
.HasColumnType("timestamp with time zone");
|
||||||
|
|
||||||
|
b.Property<bool>("Invalidated")
|
||||||
|
.HasColumnType("boolean");
|
||||||
|
|
||||||
|
b.Property<string>("JwtId")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<bool>("Used")
|
||||||
|
.HasColumnType("boolean");
|
||||||
|
|
||||||
|
b.Property<string>("UserId")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.HasKey("Token");
|
||||||
|
|
||||||
|
b.HasIndex("UserId");
|
||||||
|
|
||||||
|
b.ToTable("RefreshTokens");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Newsbot.Collector.Domain.Entities.SourceEntity", b =>
|
||||||
|
{
|
||||||
|
b.Property<Guid>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<bool>("Deleted")
|
||||||
|
.HasColumnType("boolean");
|
||||||
|
|
||||||
|
b.Property<bool>("Enabled")
|
||||||
|
.HasColumnType("boolean");
|
||||||
|
|
||||||
|
b.Property<string>("Name")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Site")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Source")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Tags")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Type")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Url")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Value")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("YoutubeId")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Sources");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Newsbot.Collector.Domain.Entities.UserSourceSubscriptionEntity", b =>
|
||||||
|
{
|
||||||
|
b.Property<Guid>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<DateTimeOffset>("DateAdded")
|
||||||
|
.HasColumnType("timestamp with time zone");
|
||||||
|
|
||||||
|
b.Property<Guid>("SourceId")
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<string>("UserId")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("UserId");
|
||||||
|
|
||||||
|
b.ToTable("UserSourceSubscription");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<string>", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null)
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("RoleId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<string>", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null)
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("UserId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<string>", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null)
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("UserId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<string>", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null)
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("RoleId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null)
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("UserId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<string>", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null)
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("UserId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Newsbot.Collector.Domain.Entities.DiscordWebhookEntity", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", "User")
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("UserId");
|
||||||
|
|
||||||
|
b.Navigation("User");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Newsbot.Collector.Domain.Entities.RefreshTokenEntity", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", "User")
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("UserId");
|
||||||
|
|
||||||
|
b.Navigation("User");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Newsbot.Collector.Domain.Entities.UserSourceSubscriptionEntity", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", "User")
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("UserId");
|
||||||
|
|
||||||
|
b.Navigation("User");
|
||||||
|
});
|
||||||
|
#pragma warning restore 612, 618
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,51 @@
|
|||||||
|
using System;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace Newsbot.Collector.Database.Migrations
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
public partial class addauthortable : Migration
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "AuthorImage",
|
||||||
|
table: "Articles");
|
||||||
|
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "AuthorName",
|
||||||
|
table: "Articles");
|
||||||
|
|
||||||
|
migrationBuilder.AddColumn<Guid>(
|
||||||
|
name: "AuthorId",
|
||||||
|
table: "Articles",
|
||||||
|
type: "uuid",
|
||||||
|
nullable: false,
|
||||||
|
defaultValue: new Guid("00000000-0000-0000-0000-000000000000"));
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "AuthorId",
|
||||||
|
table: "Articles");
|
||||||
|
|
||||||
|
migrationBuilder.AddColumn<string>(
|
||||||
|
name: "AuthorImage",
|
||||||
|
table: "Articles",
|
||||||
|
type: "text",
|
||||||
|
nullable: true);
|
||||||
|
|
||||||
|
migrationBuilder.AddColumn<string>(
|
||||||
|
name: "AuthorName",
|
||||||
|
table: "Articles",
|
||||||
|
type: "text",
|
||||||
|
nullable: false,
|
||||||
|
defaultValue: "");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,572 @@
|
|||||||
|
// <auto-generated />
|
||||||
|
using System;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||||
|
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||||
|
using Newsbot.Collector.Database;
|
||||||
|
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace Newsbot.Collector.Database.Migrations
|
||||||
|
{
|
||||||
|
[DbContext(typeof(DatabaseContext))]
|
||||||
|
partial class DatabaseContextModelSnapshot : ModelSnapshot
|
||||||
|
{
|
||||||
|
protected override void BuildModel(ModelBuilder modelBuilder)
|
||||||
|
{
|
||||||
|
#pragma warning disable 612, 618
|
||||||
|
modelBuilder
|
||||||
|
.HasAnnotation("ProductVersion", "7.0.8")
|
||||||
|
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
||||||
|
|
||||||
|
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
||||||
|
|
||||||
|
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole", b =>
|
||||||
|
{
|
||||||
|
b.Property<string>("Id")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("ConcurrencyStamp")
|
||||||
|
.IsConcurrencyToken()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Name")
|
||||||
|
.HasMaxLength(256)
|
||||||
|
.HasColumnType("character varying(256)");
|
||||||
|
|
||||||
|
b.Property<string>("NormalizedName")
|
||||||
|
.HasMaxLength(256)
|
||||||
|
.HasColumnType("character varying(256)");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("NormalizedName")
|
||||||
|
.IsUnique()
|
||||||
|
.HasDatabaseName("RoleNameIndex");
|
||||||
|
|
||||||
|
b.ToTable("AspNetRoles", (string)null);
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<string>", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<string>("ClaimType")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("ClaimValue")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("RoleId")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("RoleId");
|
||||||
|
|
||||||
|
b.ToTable("AspNetRoleClaims", (string)null);
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUser", b =>
|
||||||
|
{
|
||||||
|
b.Property<string>("Id")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<int>("AccessFailedCount")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.Property<string>("ConcurrencyStamp")
|
||||||
|
.IsConcurrencyToken()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Email")
|
||||||
|
.HasMaxLength(256)
|
||||||
|
.HasColumnType("character varying(256)");
|
||||||
|
|
||||||
|
b.Property<bool>("EmailConfirmed")
|
||||||
|
.HasColumnType("boolean");
|
||||||
|
|
||||||
|
b.Property<bool>("LockoutEnabled")
|
||||||
|
.HasColumnType("boolean");
|
||||||
|
|
||||||
|
b.Property<DateTimeOffset?>("LockoutEnd")
|
||||||
|
.HasColumnType("timestamp with time zone");
|
||||||
|
|
||||||
|
b.Property<string>("NormalizedEmail")
|
||||||
|
.HasMaxLength(256)
|
||||||
|
.HasColumnType("character varying(256)");
|
||||||
|
|
||||||
|
b.Property<string>("NormalizedUserName")
|
||||||
|
.HasMaxLength(256)
|
||||||
|
.HasColumnType("character varying(256)");
|
||||||
|
|
||||||
|
b.Property<string>("PasswordHash")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("PhoneNumber")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<bool>("PhoneNumberConfirmed")
|
||||||
|
.HasColumnType("boolean");
|
||||||
|
|
||||||
|
b.Property<string>("SecurityStamp")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<bool>("TwoFactorEnabled")
|
||||||
|
.HasColumnType("boolean");
|
||||||
|
|
||||||
|
b.Property<string>("UserName")
|
||||||
|
.HasMaxLength(256)
|
||||||
|
.HasColumnType("character varying(256)");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("NormalizedEmail")
|
||||||
|
.HasDatabaseName("EmailIndex");
|
||||||
|
|
||||||
|
b.HasIndex("NormalizedUserName")
|
||||||
|
.IsUnique()
|
||||||
|
.HasDatabaseName("UserNameIndex");
|
||||||
|
|
||||||
|
b.ToTable("AspNetUsers", (string)null);
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<string>", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<string>("ClaimType")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("ClaimValue")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("UserId")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("UserId");
|
||||||
|
|
||||||
|
b.ToTable("AspNetUserClaims", (string)null);
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<string>", b =>
|
||||||
|
{
|
||||||
|
b.Property<string>("LoginProvider")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("ProviderKey")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("ProviderDisplayName")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("UserId")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.HasKey("LoginProvider", "ProviderKey");
|
||||||
|
|
||||||
|
b.HasIndex("UserId");
|
||||||
|
|
||||||
|
b.ToTable("AspNetUserLogins", (string)null);
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<string>", b =>
|
||||||
|
{
|
||||||
|
b.Property<string>("UserId")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("RoleId")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.HasKey("UserId", "RoleId");
|
||||||
|
|
||||||
|
b.HasIndex("RoleId");
|
||||||
|
|
||||||
|
b.ToTable("AspNetUserRoles", (string)null);
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<string>", b =>
|
||||||
|
{
|
||||||
|
b.Property<string>("UserId")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("LoginProvider")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Name")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Value")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.HasKey("UserId", "LoginProvider", "Name");
|
||||||
|
|
||||||
|
b.ToTable("AspNetUserTokens", (string)null);
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Newsbot.Collector.Domain.Entities.ArticlesEntity", b =>
|
||||||
|
{
|
||||||
|
b.Property<Guid>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<Guid>("AuthorId")
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<bool>("CodeIsCommit")
|
||||||
|
.HasColumnType("boolean");
|
||||||
|
|
||||||
|
b.Property<bool>("CodeIsRelease")
|
||||||
|
.HasColumnType("boolean");
|
||||||
|
|
||||||
|
b.Property<string>("Description")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<DateTime>("PubDate")
|
||||||
|
.HasColumnType("timestamp with time zone");
|
||||||
|
|
||||||
|
b.Property<Guid>("SourceId")
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<string>("Tags")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Thumbnail")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Title")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Url")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Video")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<int>("VideoHeight")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.Property<int>("VideoWidth")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Articles");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Newsbot.Collector.Domain.Entities.AuthorEntity", b =>
|
||||||
|
{
|
||||||
|
b.Property<Guid>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<string>("Image")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Name")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<Guid>("SourceId")
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Authors");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Newsbot.Collector.Domain.Entities.DiscordNotificationEntity", b =>
|
||||||
|
{
|
||||||
|
b.Property<Guid>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<bool>("CodeAllowCommits")
|
||||||
|
.HasColumnType("boolean");
|
||||||
|
|
||||||
|
b.Property<bool>("CodeAllowReleases")
|
||||||
|
.HasColumnType("boolean");
|
||||||
|
|
||||||
|
b.Property<Guid>("DiscordWebHookId")
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<Guid>("SourceId")
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<string>("UserId")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("DiscordNotification");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Newsbot.Collector.Domain.Entities.DiscordQueueEntity", b =>
|
||||||
|
{
|
||||||
|
b.Property<Guid>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<Guid>("ArticleId")
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("DiscordQueue");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Newsbot.Collector.Domain.Entities.DiscordWebhookEntity", b =>
|
||||||
|
{
|
||||||
|
b.Property<Guid>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<string>("Channel")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<bool>("Enabled")
|
||||||
|
.HasColumnType("boolean");
|
||||||
|
|
||||||
|
b.Property<string>("Server")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Url")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("UserId")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("UserId");
|
||||||
|
|
||||||
|
b.ToTable("DiscordWebhooks");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Newsbot.Collector.Domain.Entities.IconEntity", b =>
|
||||||
|
{
|
||||||
|
b.Property<Guid>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<string>("FileName")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Site")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<Guid>("SourceId")
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Icons");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Newsbot.Collector.Domain.Entities.RefreshTokenEntity", b =>
|
||||||
|
{
|
||||||
|
b.Property<string>("Token")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<DateTime>("CreatedDate")
|
||||||
|
.HasColumnType("timestamp with time zone");
|
||||||
|
|
||||||
|
b.Property<DateTime>("ExpiryDate")
|
||||||
|
.HasColumnType("timestamp with time zone");
|
||||||
|
|
||||||
|
b.Property<bool>("Invalidated")
|
||||||
|
.HasColumnType("boolean");
|
||||||
|
|
||||||
|
b.Property<string>("JwtId")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<bool>("Used")
|
||||||
|
.HasColumnType("boolean");
|
||||||
|
|
||||||
|
b.Property<string>("UserId")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.HasKey("Token");
|
||||||
|
|
||||||
|
b.HasIndex("UserId");
|
||||||
|
|
||||||
|
b.ToTable("RefreshTokens");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Newsbot.Collector.Domain.Entities.SourceEntity", b =>
|
||||||
|
{
|
||||||
|
b.Property<Guid>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<bool>("Deleted")
|
||||||
|
.HasColumnType("boolean");
|
||||||
|
|
||||||
|
b.Property<bool>("Enabled")
|
||||||
|
.HasColumnType("boolean");
|
||||||
|
|
||||||
|
b.Property<string>("Name")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Site")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Source")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Tags")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Type")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Url")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Value")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("YoutubeId")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Sources");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Newsbot.Collector.Domain.Entities.UserSourceSubscriptionEntity", b =>
|
||||||
|
{
|
||||||
|
b.Property<Guid>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<DateTimeOffset>("DateAdded")
|
||||||
|
.HasColumnType("timestamp with time zone");
|
||||||
|
|
||||||
|
b.Property<Guid>("SourceId")
|
||||||
|
.HasColumnType("uuid");
|
||||||
|
|
||||||
|
b.Property<string>("UserId")
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("UserId");
|
||||||
|
|
||||||
|
b.ToTable("UserSourceSubscription");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<string>", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null)
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("RoleId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<string>", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null)
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("UserId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<string>", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null)
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("UserId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<string>", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null)
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("RoleId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null)
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("UserId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<string>", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null)
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("UserId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Newsbot.Collector.Domain.Entities.DiscordWebhookEntity", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", "User")
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("UserId");
|
||||||
|
|
||||||
|
b.Navigation("User");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Newsbot.Collector.Domain.Entities.RefreshTokenEntity", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", "User")
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("UserId");
|
||||||
|
|
||||||
|
b.Navigation("User");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Newsbot.Collector.Domain.Entities.UserSourceSubscriptionEntity", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", "User")
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("UserId");
|
||||||
|
|
||||||
|
b.Navigation("User");
|
||||||
|
});
|
||||||
|
#pragma warning restore 612, 618
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -6,14 +6,24 @@
|
|||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="dapper" Version="2.0.123" />
|
<PackageReference Include="dapper" Version="2.0.123" />
|
||||||
|
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="7.0.8" />
|
||||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.8" />
|
||||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.8">
|
||||||
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
|
<PrivateAssets>all</PrivateAssets>
|
||||||
|
</PackageReference>
|
||||||
<PackageReference Include="Microsoft.Extensions.Configuration" Version="7.0.0" />
|
<PackageReference Include="Microsoft.Extensions.Configuration" Version="7.0.0" />
|
||||||
<PackageReference Include="Npgsql" Version="7.0.2" />
|
<PackageReference Include="Npgsql" Version="7.0.4" />
|
||||||
|
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="7.0.4" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<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,6 +1,8 @@
|
|||||||
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.Entities;
|
||||||
using Newsbot.Collector.Domain.Interfaces;
|
using Newsbot.Collector.Domain.Interfaces;
|
||||||
using Newsbot.Collector.Domain.Models;
|
using Newsbot.Collector.Domain.Models;
|
||||||
using Npgsql;
|
using Npgsql;
|
||||||
@ -9,68 +11,78 @@ namespace Newsbot.Collector.Database.Repositories;
|
|||||||
|
|
||||||
public class ArticlesTable : IArticlesRepository
|
public class ArticlesTable : IArticlesRepository
|
||||||
{
|
{
|
||||||
private readonly string _connectionString;
|
//private readonly string _connectionString;
|
||||||
|
|
||||||
|
private DatabaseContext _context;
|
||||||
|
|
||||||
public ArticlesTable(string connectionString)
|
public ArticlesTable(string connectionString)
|
||||||
{
|
{
|
||||||
_connectionString = connectionString;
|
//_connectionString = connectionString;
|
||||||
|
_context = new DatabaseContext(connectionString);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ArticlesTable(IConfiguration configuration)
|
public ArticlesTable(DatabaseContext context)
|
||||||
{
|
{
|
||||||
var conn = configuration.GetConnectionString("database");
|
_context = context;
|
||||||
if (conn is null) conn = "";
|
|
||||||
|
|
||||||
_connectionString = conn;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<ArticlesModel> List(int page = 0, int count = 25)
|
//public ArticlesTable(IConfiguration configuration)
|
||||||
|
//{
|
||||||
|
// var conn = configuration.GetConnectionString("database");
|
||||||
|
// if (conn is null) conn = "";
|
||||||
|
//
|
||||||
|
// _context = new DatabaseContext(conn);
|
||||||
|
//}
|
||||||
|
|
||||||
|
public List<ArticlesEntity> List(int page = 0, int count = 25)
|
||||||
{
|
{
|
||||||
using var conn = OpenConnection(_connectionString);
|
//using var context = new DatabaseContext(_connectionString);
|
||||||
var res = conn.Query<ArticlesModel>(@"select * from articles
|
|
||||||
Order By PubDate Desc
|
var query = _context.Articles
|
||||||
Offset @Page
|
.Skip(page * count)
|
||||||
Fetch Next @Count Rows Only", new
|
.OrderBy(d => d.PubDate)
|
||||||
{
|
.Take(25);
|
||||||
Page = page * count,
|
Console.WriteLine(query.ToQueryString());
|
||||||
Count = count
|
return query.ToList();
|
||||||
})
|
}
|
||||||
.ToList();
|
|
||||||
|
public ArticlesEntity GetById(Guid id)
|
||||||
|
{
|
||||||
|
//using var context = new DatabaseContext(_connectionString);
|
||||||
|
var query = _context.Articles
|
||||||
|
.FirstOrDefault(d => d.Id.Equals(id));
|
||||||
|
query ??= new ArticlesEntity();
|
||||||
|
return query;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ArticlesEntity GetByUrl(string url)
|
||||||
|
{
|
||||||
|
//using var context = new DatabaseContext(_connectionString);
|
||||||
|
var res = _context.Articles.FirstOrDefault(d => d.Url!.Equals(url));
|
||||||
|
res ??= new ArticlesEntity();
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ArticlesModel GetById(Guid ID)
|
public List<ArticlesEntity> ListBySourceId(Guid id, int page, int count)
|
||||||
{
|
{
|
||||||
using var conn = OpenConnection(_connectionString);
|
//using var context = new DatabaseContext(_connectionString);
|
||||||
var res = conn.Query<ArticlesModel>("select * from articles where ID = @ID", new { ID });
|
var res = _context.Articles
|
||||||
if (res.Count() == 0) return new ArticlesModel();
|
.Skip(page * count)
|
||||||
return res.First();
|
.Where(d => d.SourceId.Equals(id));
|
||||||
|
return res.ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
public ArticlesModel GetByUrl(string url)
|
public ArticlesEntity New(ArticlesEntity model)
|
||||||
{
|
{
|
||||||
using var conn = OpenConnection(_connectionString);
|
//using var context = new DatabaseContext(_connectionString);
|
||||||
var res = conn.Query<ArticlesModel>("select * from articles where Url = @Url Limit 1", new { Url = url });
|
model.Id = new Guid();
|
||||||
if (res.Count() == 0) return new ArticlesModel();
|
var query = _context.Articles.Add(model);
|
||||||
return res.First();
|
_context.SaveChanges();
|
||||||
|
return model;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<ArticlesModel> ListBySourceId(Guid id, int page, int count)
|
/*
|
||||||
{
|
public ArticlesModel NewDapper(ArticlesModel model)
|
||||||
using var conn = OpenConnection(_connectionString);
|
|
||||||
var query = @"Select * from articles
|
|
||||||
where sourceid = @sourceid
|
|
||||||
Offset @page
|
|
||||||
Fetch next @count rows only";
|
|
||||||
return conn.Query<ArticlesModel>(query, new
|
|
||||||
{
|
|
||||||
sourceid = id,
|
|
||||||
page = page * count,
|
|
||||||
count
|
|
||||||
}).ToList();
|
|
||||||
}
|
|
||||||
|
|
||||||
public ArticlesModel New(ArticlesModel model)
|
|
||||||
{
|
{
|
||||||
model.ID = Guid.NewGuid();
|
model.ID = Guid.NewGuid();
|
||||||
|
|
||||||
@ -97,21 +109,27 @@ public class ArticlesTable : IArticlesRepository
|
|||||||
});
|
});
|
||||||
return model;
|
return model;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
public void DeleteAllBySourceId(Guid sourceId)
|
public void DeleteAllBySourceId(Guid sourceId)
|
||||||
{
|
{
|
||||||
using var conn = OpenConnection(_connectionString);
|
//using var context = new DatabaseContext(_connectionString);
|
||||||
var res = conn.Execute("Delete from articles where sourceid = '@id'", new
|
var res = _context.Articles
|
||||||
|
.Where(d => d.SourceId.Equals(sourceId))
|
||||||
|
.ToList();
|
||||||
|
|
||||||
|
foreach (var item in res)
|
||||||
{
|
{
|
||||||
sourceId
|
_context.Articles.Remove(item);
|
||||||
});
|
}
|
||||||
if (res == 0) throw new Exception($"No records where deleted that linked to SourceId = '{sourceId}'");
|
|
||||||
|
_context.SaveChanges();
|
||||||
}
|
}
|
||||||
|
|
||||||
private IDbConnection OpenConnection(string connectionString)
|
//private IDbConnection OpenConnection(string connectionString)
|
||||||
{
|
//{
|
||||||
var conn = new NpgsqlConnection(_connectionString);
|
// //var conn = new NpgsqlConnection(_connectionString);
|
||||||
conn.Open();
|
// //conn.Open();
|
||||||
return conn;
|
// //return conn;
|
||||||
}
|
//}
|
||||||
}
|
}
|
67
Newsbot.Collector.Database/Repositories/AuthorsTable.cs
Normal file
67
Newsbot.Collector.Database/Repositories/AuthorsTable.cs
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Newsbot.Collector.Domain.Entities;
|
||||||
|
using Newsbot.Collector.Domain.Interfaces;
|
||||||
|
|
||||||
|
namespace Newsbot.Collector.Database.Repositories;
|
||||||
|
|
||||||
|
public class AuthorsTable : IAuthorTable
|
||||||
|
{
|
||||||
|
private readonly DatabaseContext _context;
|
||||||
|
|
||||||
|
public AuthorsTable(string connectionString)
|
||||||
|
{
|
||||||
|
//_connectionString = connectionString;
|
||||||
|
_context = new DatabaseContext(connectionString);
|
||||||
|
}
|
||||||
|
|
||||||
|
public AuthorsTable(DatabaseContext context)
|
||||||
|
{
|
||||||
|
_context = context;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<AuthorEntity> NewAsync(AuthorEntity entity)
|
||||||
|
{
|
||||||
|
entity.Id = Guid.NewGuid();
|
||||||
|
_context.Authors.Add(entity);
|
||||||
|
await _context.SaveChangesAsync();
|
||||||
|
return entity;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<AuthorEntity> CreateIfMissingAsync(AuthorEntity entity)
|
||||||
|
{
|
||||||
|
var res = await GetBySourceIdAndNameAsync(entity.SourceId, entity.Name);
|
||||||
|
if (res is null)
|
||||||
|
{
|
||||||
|
entity.Id = Guid.NewGuid();
|
||||||
|
_context.Authors.Add(entity);
|
||||||
|
await _context.SaveChangesAsync();
|
||||||
|
return entity;
|
||||||
|
}
|
||||||
|
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<List<AuthorEntity>> ListBySourceIdAsync(Guid sourceId)
|
||||||
|
{
|
||||||
|
return await _context.Authors
|
||||||
|
.Where(s => s.SourceId.Equals(sourceId)).ToListAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<int> TotalPostsAsync(Guid id)
|
||||||
|
{
|
||||||
|
return await _context.Authors.CountAsync(x => x.Id.Equals(id));
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<AuthorEntity?> GetBySourceIdAndNameAsync(Guid sourceId, string name)
|
||||||
|
{
|
||||||
|
return await _context.Authors
|
||||||
|
.Where(s => s.SourceId.Equals(sourceId))
|
||||||
|
.FirstOrDefaultAsync(n => n.Name.Equals(name));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<AuthorEntity?> GetById(Guid id)
|
||||||
|
{
|
||||||
|
return await _context.Authors.FirstOrDefaultAsync(q => q.Id.Equals(id));
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,97 @@
|
|||||||
|
using Newsbot.Collector.Domain.Entities;
|
||||||
|
using Newsbot.Collector.Domain.Interfaces;
|
||||||
|
|
||||||
|
namespace Newsbot.Collector.Database.Repositories;
|
||||||
|
|
||||||
|
public class DiscordNotificationTable : IDiscordNotificationRepository
|
||||||
|
{
|
||||||
|
//private readonly string _connectionString;
|
||||||
|
private DatabaseContext _context;
|
||||||
|
|
||||||
|
public DiscordNotificationTable(string connectionString)
|
||||||
|
{
|
||||||
|
//_connectionString = connectionString;
|
||||||
|
_context = new DatabaseContext(connectionString);
|
||||||
|
}
|
||||||
|
|
||||||
|
public DiscordNotificationTable(DatabaseContext context)
|
||||||
|
{
|
||||||
|
_context = context;
|
||||||
|
}
|
||||||
|
|
||||||
|
public DiscordNotificationEntity New(DiscordNotificationEntity model)
|
||||||
|
{
|
||||||
|
model.Id = new Guid();
|
||||||
|
|
||||||
|
_context.DiscordNotification.Add(model);
|
||||||
|
_context.SaveChanges();
|
||||||
|
|
||||||
|
return model;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<DiscordNotificationEntity> List(string userId, int page = 0, int count = 25)
|
||||||
|
{
|
||||||
|
return _context.DiscordNotification
|
||||||
|
.Where(x => x.UserId != null && x.UserId.Equals(userId))
|
||||||
|
.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)
|
||||||
|
{
|
||||||
|
return _context.DiscordNotification
|
||||||
|
.Where(f => f.SourceId.Equals(id))
|
||||||
|
.Skip(page * count)
|
||||||
|
.ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<DiscordNotificationEntity> ListByWebhook(string userId, Guid id, int page = 0, int count = 25)
|
||||||
|
{
|
||||||
|
return _context.DiscordNotification
|
||||||
|
.Where(f => f.DiscordWebHookId.Equals(id))
|
||||||
|
.Where(f => f.UserId != null && f.UserId.Equals(userId))
|
||||||
|
.Skip(page * count)
|
||||||
|
.ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
public DiscordNotificationEntity GetById(string userId, Guid id)
|
||||||
|
{
|
||||||
|
var res = _context.DiscordNotification
|
||||||
|
.Where(f => f.UserId != null && f.UserId.Equals(userId))
|
||||||
|
.FirstOrDefault(f => f.Id.Equals(id));
|
||||||
|
return res ??= new DiscordNotificationEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
public DiscordNotificationEntity GetByWebhookAndSource(string userId, Guid webhookId, Guid sourceId)
|
||||||
|
{
|
||||||
|
var res = _context.DiscordNotification
|
||||||
|
.Where(f => f.UserId != null && f.UserId.Equals(userId))
|
||||||
|
.Where(f => f.DiscordWebHookId.Equals(webhookId))
|
||||||
|
.FirstOrDefault(f => f.SourceId.Equals(sourceId));
|
||||||
|
return res ??= new DiscordNotificationEntity();
|
||||||
|
}
|
||||||
|
|
||||||
|
public int Delete(string userId, Guid id)
|
||||||
|
{
|
||||||
|
var res = _context.DiscordNotification
|
||||||
|
.Where(f => f.UserId != null && f.UserId.Equals(userId))
|
||||||
|
.FirstOrDefault(f => f.Id.Equals(id));
|
||||||
|
if (res is null)
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
_context.DiscordNotification.Remove(res);
|
||||||
|
return _context.SaveChanges();
|
||||||
|
}
|
||||||
|
}
|
@ -1,5 +1,6 @@
|
|||||||
using System.Data;
|
using System.Data;
|
||||||
using Dapper;
|
using Dapper;
|
||||||
|
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 Npgsql;
|
using Npgsql;
|
||||||
@ -8,47 +9,49 @@ namespace Newsbot.Collector.Database.Repositories;
|
|||||||
|
|
||||||
public class DiscordQueueTable : IDiscordQueueRepository
|
public class DiscordQueueTable : IDiscordQueueRepository
|
||||||
{
|
{
|
||||||
private string _connectionString;
|
//private string _connectionString;
|
||||||
|
private DatabaseContext _context;
|
||||||
|
|
||||||
public DiscordQueueTable(string connectionString)
|
public DiscordQueueTable(string connectionString)
|
||||||
{
|
{
|
||||||
_connectionString = connectionString;
|
//_connectionString = connectionString;
|
||||||
|
_context = new DatabaseContext(connectionString);
|
||||||
}
|
}
|
||||||
|
|
||||||
private IDbConnection OpenConnection(string connectionString)
|
public DiscordQueueTable(DatabaseContext context)
|
||||||
{
|
{
|
||||||
var conn = new NpgsqlConnection(_connectionString);
|
_context = context;
|
||||||
conn.Open();
|
|
||||||
return conn;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void New(DiscordQueueModel model)
|
//private IDbConnection OpenConnection(string connectionString)
|
||||||
|
//{
|
||||||
|
// var conn = new NpgsqlConnection(_connectionString);
|
||||||
|
// conn.Open();
|
||||||
|
// return conn;
|
||||||
|
//}
|
||||||
|
|
||||||
|
public void New(DiscordQueueEntity model)
|
||||||
{
|
{
|
||||||
using var conn = OpenConnection(_connectionString);
|
model.Id = new Guid();
|
||||||
var query = "Insert into DiscordQueue(ID, ArticleId) Values (@id, @articleid);";
|
|
||||||
conn.Execute(query, new
|
//using var context = new DatabaseContext(_connectionString);
|
||||||
{
|
var res = _context.DiscordQueue.Add(model);
|
||||||
id = Guid.NewGuid(),
|
_context.SaveChanges();
|
||||||
articleid = model.ArticleID
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Delete(Guid id)
|
public void Delete(Guid id)
|
||||||
{
|
{
|
||||||
using var conn = OpenConnection(_connectionString);
|
//using var context = new DatabaseContext(_connectionString);
|
||||||
var query = "Delete From DiscordQueue Where ID = @id;";
|
var res = _context.DiscordQueue.FirstOrDefault(d => d.Id.Equals(id));
|
||||||
conn.Execute(query, new
|
res ??= new DiscordQueueEntity();
|
||||||
{
|
_context.DiscordQueue.Remove(res);
|
||||||
id = id
|
_context.SaveChanges();
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<DiscordQueueModel> List(int limit = 25)
|
public List<DiscordQueueEntity> List(int limit = 25)
|
||||||
{
|
{
|
||||||
using var conn = OpenConnection(_connectionString);
|
//using var context = new DatabaseContext(_connectionString);
|
||||||
var query = "Select * from DiscordQueue LIMIT @limit;";
|
var res = _context.DiscordQueue.Take(limit).ToList();
|
||||||
return conn.Query<DiscordQueueModel>(query, new {
|
return res;
|
||||||
limit = limit
|
|
||||||
}).ToList();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,130 +1,154 @@
|
|||||||
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.Models;
|
using Newsbot.Collector.Domain.Entities;
|
||||||
using Npgsql;
|
using Npgsql;
|
||||||
|
|
||||||
namespace Newsbot.Collector.Database.Repositories;
|
namespace Newsbot.Collector.Database.Repositories;
|
||||||
|
|
||||||
public class DiscordWebhooksTable : IDiscordWebHooksRepository
|
public class DiscordWebhooksTable : IDiscordWebHooksRepository
|
||||||
{
|
{
|
||||||
private readonly string _connectionString;
|
//private readonly string _connectionString;
|
||||||
|
private DatabaseContext _context;
|
||||||
|
|
||||||
public DiscordWebhooksTable(string connectionString)
|
public DiscordWebhooksTable(string connectionString)
|
||||||
{
|
{
|
||||||
_connectionString = connectionString;
|
//_connectionString = connectionString;
|
||||||
|
_context = new DatabaseContext(connectionString);
|
||||||
}
|
}
|
||||||
|
|
||||||
public DiscordWebhooksTable(IConfiguration configuration)
|
public DiscordWebhooksTable(DatabaseContext context)
|
||||||
{
|
{
|
||||||
var connstr = configuration.GetConnectionString("database") ?? "";
|
_context = context;
|
||||||
_connectionString = connstr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public DiscordWebHookModel New(DiscordWebHookModel model)
|
public DiscordWebhookEntity New(DiscordWebhookEntity model)
|
||||||
{
|
{
|
||||||
var uid = Guid.NewGuid();
|
model.Id = new Guid();
|
||||||
using var conn = OpenConnection(_connectionString);
|
|
||||||
var query =
|
//using var context = new DatabaseContext(_connectionString);
|
||||||
"Insert Into DiscordWebHooks (ID, Url, Server, Channel, Enabled) Values (@id, @url, @server, @channel, @enabled);";
|
_context.DiscordWebhooks.Add(model);
|
||||||
conn.Execute(query, new
|
_context.SaveChanges();
|
||||||
{
|
|
||||||
id = uid,
|
|
||||||
url = model.Url,
|
|
||||||
server = model.Server,
|
|
||||||
channel = model.Channel,
|
|
||||||
enabled = model.Enabled
|
|
||||||
});
|
|
||||||
model.ID = uid;
|
|
||||||
return model;
|
return model;
|
||||||
}
|
}
|
||||||
|
|
||||||
public DiscordWebHookModel GetByID(Guid id)
|
public DiscordWebhookEntity GetById(string userId, Guid id)
|
||||||
{
|
{
|
||||||
using var conn = OpenConnection(_connectionString);
|
//using var context = new DatabaseContext(_connectionString);
|
||||||
var query = "Select * from DiscordWebHooks Where ID = @id LIMIT 1;";
|
var res = _context.DiscordWebhooks
|
||||||
return conn.Query<DiscordWebHookModel>(query, new
|
.Where(i => i.UserId != null && i.UserId.Equals(userId))
|
||||||
{
|
.FirstOrDefault(d => d.Id.Equals(id));
|
||||||
id
|
res ??= new DiscordWebhookEntity();
|
||||||
}).First();
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
public DiscordWebHookModel GetByUrl(string url)
|
public DiscordWebhookEntity GetById(Guid id)
|
||||||
{
|
{
|
||||||
using var conn = OpenConnection(_connectionString);
|
var res = _context.DiscordWebhooks
|
||||||
var query = "Select * From DiscordWebHooks Where url = @url;";
|
.FirstOrDefault(d => d.Id.Equals(id));
|
||||||
|
res ??= new DiscordWebhookEntity();
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
public DiscordWebhookEntity GetByUrl(string url)
|
||||||
|
{
|
||||||
|
//using var context = new DatabaseContext(_connectionString);
|
||||||
|
var res = _context.DiscordWebhooks.FirstOrDefault(d => d.Url.Equals(url));
|
||||||
|
res ??= new DiscordWebhookEntity();
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<DiscordWebhookEntity> List(int page, int count = 25)
|
||||||
|
{
|
||||||
|
//using var context = new DatabaseContext(_connectionString);
|
||||||
|
var res = _context.DiscordWebhooks
|
||||||
|
.Skip(page * count)
|
||||||
|
.Take(count)
|
||||||
|
.ToList();
|
||||||
|
res ??= new List<DiscordWebhookEntity>();
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
//using var context = new DatabaseContext(_connectionString);
|
||||||
|
var res = _context.DiscordWebhooks
|
||||||
|
.Where(d => d.Server.Equals(server))
|
||||||
|
.Take(limit)
|
||||||
|
.ToList();
|
||||||
|
res ??= new List<DiscordWebhookEntity>();
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<DiscordWebhookEntity> ListByServerAndChannel(string userId, string server, string channel, int limit = 25)
|
||||||
|
{
|
||||||
|
//using var context = new DatabaseContext(_connectionString);
|
||||||
|
var res = _context.DiscordWebhooks
|
||||||
|
.Where(i => i.UserId != null && i.UserId.Equals(userId))
|
||||||
|
.Where(s => s.Server.Equals(server))
|
||||||
|
.Where(c => c.Channel.Equals(channel))
|
||||||
|
.Take(limit)
|
||||||
|
.ToList();
|
||||||
|
res ??= new List<DiscordWebhookEntity>();
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int Disable(string userId, Guid id)
|
||||||
|
{
|
||||||
|
var res = GetById(userId, id);
|
||||||
|
//using var context = new DatabaseContext(_connectionString);
|
||||||
|
|
||||||
|
res.Enabled = true;
|
||||||
|
|
||||||
|
_context.DiscordWebhooks.Update(res);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var res = conn.QueryFirst<DiscordWebHookModel>(query, new
|
_context.SaveChanges();
|
||||||
{
|
return 1;
|
||||||
url
|
|
||||||
});
|
|
||||||
return res;
|
|
||||||
}
|
}
|
||||||
catch
|
catch(Exception ex)
|
||||||
{
|
{
|
||||||
return new DiscordWebHookModel();
|
Console.WriteLine($"Failed to update DiscordWebhook ID = {id}. {ex.Message}");
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<DiscordWebHookModel> List(int page, int count = 25)
|
public int Enable(string userId, Guid id)
|
||||||
{
|
{
|
||||||
using var conn = OpenConnection(_connectionString);
|
var res = GetById(userId, id);
|
||||||
var query = @"Select * From DiscordWebHooks
|
//using var context = new DatabaseContext(_connectionString);
|
||||||
Offset @offset Fetch Next @count Rows Only;";
|
|
||||||
return conn.Query<DiscordWebHookModel>(query, new
|
res.Enabled = false;
|
||||||
|
|
||||||
|
_context.DiscordWebhooks.Update(res);
|
||||||
|
try
|
||||||
{
|
{
|
||||||
offset = page * count, count
|
_context.SaveChanges();
|
||||||
}).ToList();
|
return 1;
|
||||||
|
}
|
||||||
|
catch(Exception ex)
|
||||||
|
{
|
||||||
|
Console.WriteLine($"Failed to update DiscordWebhook ID = {id}. {ex.Message}");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<DiscordWebHookModel> ListByServer(string server, int limit = 25)
|
//private IDbConnection OpenConnection(string connectionString)
|
||||||
{
|
//{
|
||||||
using var conn = OpenConnection(_connectionString);
|
// var conn = new NpgsqlConnection(_connectionString);
|
||||||
var query = "Select * From DiscordWebHooks Where Server = @id Limit @limit;";
|
// conn.Open();
|
||||||
return conn.Query<DiscordWebHookModel>(query, new
|
// return conn;
|
||||||
{
|
//}
|
||||||
server, limit
|
|
||||||
}).ToList();
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<DiscordWebHookModel> ListByServerAndChannel(string server, string channel, int limit = 25)
|
|
||||||
{
|
|
||||||
using var conn = OpenConnection(_connectionString);
|
|
||||||
var query = "SELECT * FROM DiscordWebHooks WHERE Server = @server and Channel = @channel Limit @limit;";
|
|
||||||
return conn.Query<DiscordWebHookModel>(query, new
|
|
||||||
{
|
|
||||||
server,
|
|
||||||
channel,
|
|
||||||
limit
|
|
||||||
}).ToList();
|
|
||||||
}
|
|
||||||
|
|
||||||
public int Disable(Guid id)
|
|
||||||
{
|
|
||||||
using var conn = OpenConnection(_connectionString);
|
|
||||||
var query = "Update discordwebhooks Set Enabled = FALSE where ID = @id;";
|
|
||||||
return conn.Execute(query, new
|
|
||||||
{
|
|
||||||
id
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
public int Enable(Guid id)
|
|
||||||
{
|
|
||||||
using var conn = OpenConnection(_connectionString);
|
|
||||||
var query = "Update discordwebhooks Set Enabled = TRUE where ID = @id;";
|
|
||||||
return conn.Execute(query, new
|
|
||||||
{
|
|
||||||
id
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
private IDbConnection OpenConnection(string connectionString)
|
|
||||||
{
|
|
||||||
var conn = new NpgsqlConnection(_connectionString);
|
|
||||||
conn.Open();
|
|
||||||
return conn;
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -1,6 +1,7 @@
|
|||||||
using System.Data;
|
using System.Data;
|
||||||
using Dapper;
|
using Dapper;
|
||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Configuration;
|
||||||
|
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 Npgsql;
|
using Npgsql;
|
||||||
@ -9,57 +10,49 @@ namespace Newsbot.Collector.Database.Repositories;
|
|||||||
|
|
||||||
public class IconsTable : IIconsRepository
|
public class IconsTable : IIconsRepository
|
||||||
{
|
{
|
||||||
private readonly string _connectionString;
|
//private readonly string _connectionString;
|
||||||
|
private DatabaseContext _context;
|
||||||
|
|
||||||
public IconsTable(string connectionString)
|
public IconsTable(string connectionString)
|
||||||
{
|
{
|
||||||
_connectionString = connectionString;
|
//_connectionString = connectionString;
|
||||||
|
_context = new DatabaseContext(connectionString);
|
||||||
}
|
}
|
||||||
|
|
||||||
public IconsTable(IConfiguration configuration)
|
public IconsTable(DatabaseContext context)
|
||||||
{
|
{
|
||||||
var connstr = configuration.GetConnectionString("database");
|
_context = context;
|
||||||
if (connstr is null) connstr = "";
|
|
||||||
_connectionString = connstr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void New(IconModel model)
|
public void New(IconEntity model)
|
||||||
{
|
{
|
||||||
|
//using var context = new DatabaseContext(_connectionString);
|
||||||
model.Id = Guid.NewGuid();
|
model.Id = Guid.NewGuid();
|
||||||
|
|
||||||
using var conn = OpenConnection(_connectionString);
|
_context.Icons.Add(model);
|
||||||
var q = @"Insert Into icons (id, filename, site, sourceid) values (@Id,@FileName, @Site, @SourceId)";
|
_context.SaveChanges();
|
||||||
conn.Execute(q, model);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public IconModel GetById(Guid id)
|
public IconEntity GetById(Guid id)
|
||||||
{
|
{
|
||||||
using var conn = OpenConnection(_connectionString);
|
//using var context = new DatabaseContext(_connectionString);
|
||||||
var query = "Select * From icons where ID = @id Limit 1;";
|
var res = _context.Icons.FirstOrDefault(f => f.Id.Equals(id));
|
||||||
var res = conn.Query<IconModel>(query, new
|
res ??= new IconEntity();
|
||||||
{
|
return res;
|
||||||
id
|
|
||||||
});
|
|
||||||
if (!res.Any()) return new IconModel();
|
|
||||||
return res.First();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public IconModel GetBySourceId(Guid id)
|
public IconEntity GetBySourceId(Guid id)
|
||||||
{
|
{
|
||||||
using var conn = OpenConnection(_connectionString);
|
//using var context = new DatabaseContext(_connectionString);
|
||||||
var query = "Select * From icons where sourceid = @id Limit 1;";
|
var res = _context.Icons.FirstOrDefault(f => f.SourceId.Equals(id));
|
||||||
var res = conn.Query<IconModel>(query, new
|
res ??= new IconEntity();
|
||||||
{
|
return res;
|
||||||
id
|
|
||||||
});
|
|
||||||
if (!res.Any()) return new IconModel();
|
|
||||||
return res.First();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private IDbConnection OpenConnection(string connectionString)
|
//private IDbConnection OpenConnection(string connectionString)
|
||||||
{
|
//{
|
||||||
var conn = new NpgsqlConnection(_connectionString);
|
// var conn = new NpgsqlConnection(_connectionString);
|
||||||
conn.Open();
|
// conn.Open();
|
||||||
return conn;
|
// return conn;
|
||||||
}
|
//}
|
||||||
}
|
}
|
42
Newsbot.Collector.Database/Repositories/RefreshTokenTable.cs
Normal file
42
Newsbot.Collector.Database/Repositories/RefreshTokenTable.cs
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
using Newsbot.Collector.Domain.Entities;
|
||||||
|
using Newsbot.Collector.Domain.Interfaces;
|
||||||
|
|
||||||
|
namespace Newsbot.Collector.Database.Repositories;
|
||||||
|
|
||||||
|
public class RefreshTokenTable : IRefreshTokenRepository
|
||||||
|
{
|
||||||
|
private readonly DatabaseContext _context;
|
||||||
|
|
||||||
|
public RefreshTokenTable(string connectionString)
|
||||||
|
{
|
||||||
|
_context = new DatabaseContext(connectionString);
|
||||||
|
}
|
||||||
|
|
||||||
|
public RefreshTokenTable(DatabaseContext context)
|
||||||
|
{
|
||||||
|
_context = context;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Add(RefreshTokenEntity entity)
|
||||||
|
{
|
||||||
|
_context.RefreshTokens.Add(entity);
|
||||||
|
_context.SaveChanges();
|
||||||
|
}
|
||||||
|
|
||||||
|
public RefreshTokenEntity? Get(string token)
|
||||||
|
{
|
||||||
|
return _context.RefreshTokens.SingleOrDefault(x => x.Token == token);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void UpdateTokenIsUsed(string token)
|
||||||
|
{
|
||||||
|
var entity = Get(token);
|
||||||
|
if (entity is null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
entity.Used = true;
|
||||||
|
_context.RefreshTokens.Update(entity);
|
||||||
|
_context.SaveChanges();
|
||||||
|
}
|
||||||
|
}
|
@ -1,185 +1,186 @@
|
|||||||
using System.Data;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Dapper;
|
using Newsbot.Collector.Domain.Entities;
|
||||||
using Microsoft.Extensions.Configuration;
|
|
||||||
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;
|
||||||
|
|
||||||
public class SourcesTable : ISourcesRepository
|
public class SourcesTable : ISourcesRepository
|
||||||
{
|
{
|
||||||
private readonly string _connectionString;
|
//private readonly string _connectionString;
|
||||||
|
private readonly DatabaseContext _context;
|
||||||
|
|
||||||
public SourcesTable(string connectionString)
|
public SourcesTable(string connectionString)
|
||||||
{
|
{
|
||||||
_connectionString = connectionString;
|
//_connectionString = connectionString;
|
||||||
|
_context = new DatabaseContext(connectionString);
|
||||||
}
|
}
|
||||||
|
|
||||||
public SourcesTable(IConfiguration configuration)
|
public SourcesTable(DatabaseContext context)
|
||||||
{
|
{
|
||||||
var connstr = configuration.GetConnectionString("database");
|
_context = context;
|
||||||
if (connstr is null) connstr = "";
|
|
||||||
_connectionString = connstr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public SourceModel New(SourceModel model)
|
public SourceEntity New(SourceEntity model)
|
||||||
{
|
{
|
||||||
model.ID = Guid.NewGuid();
|
model.Id = Guid.NewGuid();
|
||||||
using var conn = OpenConnection(_connectionString);
|
//using var context = new DatabaseContext(_connectionString);
|
||||||
var query =
|
_context.Sources.Add(model);
|
||||||
"Insert Into Sources (ID, Site, Name, Source, Type, Value, Enabled, Url, Tags, YoutubeId) Values (@id ,@site,@name,@source,@type,@value,@enabled,@url,@tags,@youtubeid);";
|
try
|
||||||
conn.Execute(query, new
|
|
||||||
{
|
{
|
||||||
id = model.ID,
|
_context.SaveChanges();
|
||||||
model.Site,
|
}
|
||||||
model.Name,
|
catch (Exception ex)
|
||||||
model.Source,
|
{
|
||||||
model.Type,
|
Console.WriteLine($"Failed to save source to db. {model.ToString()} {ex.Message} ");
|
||||||
model.Value,
|
}
|
||||||
model.Enabled,
|
|
||||||
model.Url,
|
|
||||||
model.Tags,
|
|
||||||
model.YoutubeId
|
|
||||||
});
|
|
||||||
return model;
|
return model;
|
||||||
}
|
}
|
||||||
|
|
||||||
public SourceModel GetByID(Guid ID)
|
public SourceEntity GetById(Guid id)
|
||||||
{
|
{
|
||||||
using var conn = OpenConnection(_connectionString);
|
//using var context = new DatabaseContext(_connectionString);
|
||||||
var query = "Select * From Sources where ID = @id Limit 1;";
|
var res = _context.Sources.FirstOrDefault(f => f.Id.Equals(id));
|
||||||
var res = conn.Query<SourceModel>(query, new
|
res ??= new SourceEntity();
|
||||||
{
|
return res;
|
||||||
id = ID
|
|
||||||
});
|
|
||||||
if (res.Count() == 0) return new SourceModel();
|
|
||||||
return res.First();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public SourceModel GetByID(string ID)
|
public SourceEntity GetById(string id)
|
||||||
{
|
{
|
||||||
var uid = Guid.Parse(ID);
|
var uid = Guid.Parse(id);
|
||||||
return GetByID(uid);
|
return GetById(uid);
|
||||||
}
|
}
|
||||||
|
|
||||||
public SourceModel GetByName(string Name)
|
public SourceEntity GetByName(string name)
|
||||||
{
|
{
|
||||||
using var conn = OpenConnection(_connectionString);
|
//using var context = new DatabaseContext(_connectionString);
|
||||||
var query = "Select * from Sources where name = @name Limit 1;";
|
var res = _context.Sources.FirstOrDefault(f => f.Name.Equals(name));
|
||||||
var res = conn.Query<SourceModel>(query, new
|
res ??= new SourceEntity();
|
||||||
{
|
return res;
|
||||||
name = Name
|
|
||||||
});
|
|
||||||
|
|
||||||
if (res.Count() == 0) return new SourceModel();
|
|
||||||
return res.First();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public SourceModel GetByNameAndType(string name, string type)
|
public SourceEntity GetByNameAndType(string name, string type)
|
||||||
{
|
{
|
||||||
using var conn = OpenConnection(_connectionString);
|
//using var context = new DatabaseContext(_connectionString);
|
||||||
var query = "Select * from Sources WHERE name = @name and type = @type;";
|
var res = _context.Sources
|
||||||
var res = conn.Query<SourceModel>(query, new
|
.Where(f => f.Name.Equals(name))
|
||||||
{
|
.FirstOrDefault(f => f.Type.Equals(type));
|
||||||
name, type
|
res ??= new SourceEntity();
|
||||||
});
|
return res;
|
||||||
|
|
||||||
if (res.Count() == 0) return new SourceModel();
|
|
||||||
return res.First();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public SourceModel GetByUrl(string url)
|
public SourceEntity GetByUrl(string url)
|
||||||
{
|
{
|
||||||
using var conn = OpenConnection(_connectionString);
|
//using var context = new DatabaseContext(_connectionString);
|
||||||
var query = "Select * from Sources WHERE url = @url;";
|
var res = _context.Sources
|
||||||
var res = conn.Query<SourceModel>(query, new
|
.FirstOrDefault(f => f.Url.Equals(url));
|
||||||
{
|
res ??= new SourceEntity();
|
||||||
url
|
return res;
|
||||||
});
|
|
||||||
|
|
||||||
if (res.ToList().Count == 0) return new SourceModel();
|
|
||||||
|
|
||||||
return res.First();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<SourceModel> List(int page = 0, int count = 25)
|
public List<SourceEntity> List(int page = 0, int count = 100)
|
||||||
{
|
{
|
||||||
using var conn = OpenConnection(_connectionString);
|
//using var context = new DatabaseContext(_connectionString);
|
||||||
var query = @"Select * From Sources
|
var res = _context.Sources
|
||||||
Offset @page
|
.Skip(page * count)
|
||||||
Fetch Next @count Rows Only;";
|
.Take(count)
|
||||||
return conn.Query<SourceModel>(query, new
|
.ToList();
|
||||||
{
|
return res;
|
||||||
page = page * count, count
|
|
||||||
}).ToList();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<SourceModel> ListBySource(string source, int limit = 25)
|
public List<SourceEntity> ListBySource(string source, int page = 0, int limit = 25)
|
||||||
{
|
{
|
||||||
using var conn = OpenConnection(_connectionString);
|
//using var context = new DatabaseContext(_connectionString);
|
||||||
var query = "Select * From Sources where Source = @source Limit @limit;";
|
var res = _context.Sources
|
||||||
return conn.Query<SourceModel>(query, new
|
.Where(f => f.Source.Equals(source))
|
||||||
{
|
.Skip(page * limit)
|
||||||
source, limit
|
.Take(limit)
|
||||||
}).ToList();
|
.ToList();
|
||||||
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<SourceModel> ListByType(string type, int limit = 25)
|
public List<SourceEntity> ListByType(string type,int page = 0, int limit = 25)
|
||||||
{
|
{
|
||||||
using var conn = OpenConnection(_connectionString);
|
//using var context = new DatabaseContext(_connectionString);
|
||||||
var query = "Select * From Sources where Type = @type Limit @limit;";
|
var res = _context.Sources
|
||||||
return conn.Query<SourceModel>(query, new
|
.Where(f => f.Type.Equals(type))
|
||||||
{
|
.Skip(page * limit)
|
||||||
type, limit
|
.Take(limit)
|
||||||
}).ToList();
|
.ToList();
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<int> TotalByTypeAsync(string type)
|
||||||
|
{
|
||||||
|
var res = await _context.Sources
|
||||||
|
.Where(f => f.Type == type )
|
||||||
|
.CountAsync();
|
||||||
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int Disable(Guid id)
|
public int Disable(Guid id)
|
||||||
{
|
{
|
||||||
using var conn = OpenConnection(_connectionString);
|
//using var context = new DatabaseContext(_connectionString);
|
||||||
var query = "Update Sources Set Enabled = FALSE where ID = @id;";
|
var res = GetById(id);
|
||||||
return conn.Execute(query, new
|
res.Enabled = false;
|
||||||
|
_context.Sources.Update(res);
|
||||||
|
try
|
||||||
{
|
{
|
||||||
id
|
_context.SaveChanges();
|
||||||
});
|
return 1;
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public int Enable(Guid id)
|
public int Enable(Guid id)
|
||||||
{
|
{
|
||||||
using var conn = OpenConnection(_connectionString);
|
//using var context = new DatabaseContext(_connectionString);
|
||||||
var query = "Update Sources Set Enabled = TRUE where ID = @id;";
|
var res = GetById(id);
|
||||||
return conn.Execute(query, new
|
res.Enabled = true;
|
||||||
|
_context.Sources.Update(res);
|
||||||
|
try
|
||||||
{
|
{
|
||||||
id
|
_context.SaveChanges();
|
||||||
});
|
return 1;
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Delete(Guid id)
|
public void Delete(Guid id)
|
||||||
{
|
{
|
||||||
using var conn = OpenConnection(_connectionString);
|
//using var context = new DatabaseContext(_connectionString);
|
||||||
var query = "Delete From sources where id = @id;";
|
var res = GetById(id);
|
||||||
var res = conn.Execute(query, new
|
_context.Sources.Remove(res);
|
||||||
{
|
_context.SaveChanges();
|
||||||
id
|
|
||||||
});
|
|
||||||
if (res == 0) throw new Exception("Nothing was deleted");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int UpdateYoutubeId(Guid id, string youtubeId)
|
public int UpdateYoutubeId(Guid id, string youtubeId)
|
||||||
{
|
{
|
||||||
using var conn = OpenConnection(_connectionString);
|
//using var context = new DatabaseContext(_connectionString);
|
||||||
var query = "Update Sources Set youtubeid = @youtubeId where ID = @id;";
|
var res = GetById(id);
|
||||||
return conn.Execute(query, new
|
res.YoutubeId = youtubeId;
|
||||||
|
_context.Sources.Update(res);
|
||||||
|
try
|
||||||
{
|
{
|
||||||
id, youtubeId
|
_context.SaveChanges();
|
||||||
});
|
return 1;
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private IDbConnection OpenConnection(string connectionString)
|
//private IDbConnection OpenConnection(string connectionString)
|
||||||
{
|
//{
|
||||||
var conn = new NpgsqlConnection(_connectionString);
|
// var conn = new NpgsqlConnection(_connectionString);
|
||||||
conn.Open();
|
// conn.Open();
|
||||||
return conn;
|
// return conn;
|
||||||
}
|
//}
|
||||||
}
|
}
|
@ -1,132 +0,0 @@
|
|||||||
using System.Data;
|
|
||||||
using Dapper;
|
|
||||||
using Microsoft.Extensions.Configuration;
|
|
||||||
using Newsbot.Collector.Domain.Interfaces;
|
|
||||||
using Newsbot.Collector.Domain.Models;
|
|
||||||
using Npgsql;
|
|
||||||
|
|
||||||
namespace Newsbot.Collector.Database.Repositories;
|
|
||||||
|
|
||||||
public class SubscriptionsTable : ISubscriptionRepository
|
|
||||||
{
|
|
||||||
private readonly string _connectionString;
|
|
||||||
|
|
||||||
public SubscriptionsTable(string connectionString)
|
|
||||||
{
|
|
||||||
_connectionString = connectionString;
|
|
||||||
}
|
|
||||||
|
|
||||||
public SubscriptionsTable(IConfiguration configuration)
|
|
||||||
{
|
|
||||||
var connstr = configuration.GetConnectionString("database");
|
|
||||||
if (connstr is null) connstr = "";
|
|
||||||
_connectionString = connstr;
|
|
||||||
}
|
|
||||||
|
|
||||||
public SubscriptionModel New(SubscriptionModel model)
|
|
||||||
{
|
|
||||||
model.Id = Guid.NewGuid();
|
|
||||||
using var conn = OpenConnection(_connectionString);
|
|
||||||
var query =
|
|
||||||
"Insert Into subscriptions (ID, DiscordWebHookId, SourceId, codeAllowCommits, codeAllowReleases) Values (@id, @webhookId, @sourceId, @codeAllowCommits, @codeAllowReleases);";
|
|
||||||
try
|
|
||||||
{
|
|
||||||
conn.Execute(query, new
|
|
||||||
{
|
|
||||||
id = model.Id,
|
|
||||||
webhookId = model.DiscordWebHookId,
|
|
||||||
sourceId = model.SourceId,
|
|
||||||
codeAllowCommits = model.CodeAllowCommits,
|
|
||||||
codeAllowReleases = model.CodeAllowReleases
|
|
||||||
});
|
|
||||||
return model;
|
|
||||||
}
|
|
||||||
catch
|
|
||||||
{
|
|
||||||
return new SubscriptionModel();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<SubscriptionModel> List(int page = 0, int count = 25)
|
|
||||||
{
|
|
||||||
using var conn = OpenConnection(_connectionString);
|
|
||||||
var query = @"Select * From subscriptions
|
|
||||||
Offset @page Fetch Next @count Rows Only;";
|
|
||||||
return conn.Query<SubscriptionModel>(query, new
|
|
||||||
{
|
|
||||||
page = page * count, count
|
|
||||||
}).ToList();
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<SubscriptionModel> ListBySourceID(Guid id, int page = 0, int count = 25)
|
|
||||||
{
|
|
||||||
using var conn = OpenConnection(_connectionString);
|
|
||||||
var query = @"Select * From subscriptions
|
|
||||||
Where sourceid = @sourceid
|
|
||||||
Offset @page Fetch Next @count Rows Only";
|
|
||||||
return conn.Query<SubscriptionModel>(query, new
|
|
||||||
{
|
|
||||||
page = page * count,
|
|
||||||
count,
|
|
||||||
sourceid = id
|
|
||||||
}).ToList();
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<SubscriptionModel> ListByWebhook(Guid id, int page = 0, int count = 25)
|
|
||||||
{
|
|
||||||
using var conn = OpenConnection(_connectionString);
|
|
||||||
var query = @"Select * From subscriptions
|
|
||||||
Where discordwebhookid = @webhookid
|
|
||||||
Offset @page Fetch Next @count Rows Only";
|
|
||||||
return conn.Query<SubscriptionModel>(query, new
|
|
||||||
{
|
|
||||||
page = page * count,
|
|
||||||
count,
|
|
||||||
webhookid = id
|
|
||||||
}).ToList();
|
|
||||||
}
|
|
||||||
|
|
||||||
public SubscriptionModel GetById(Guid id)
|
|
||||||
{
|
|
||||||
using var conn = OpenConnection(_connectionString);
|
|
||||||
var query = @"Select * From subscriptions Where id = @id;";
|
|
||||||
var res = conn.Query<SubscriptionModel>(query, new
|
|
||||||
{
|
|
||||||
id
|
|
||||||
});
|
|
||||||
if (res.Count() == 0) return new SubscriptionModel();
|
|
||||||
return res.First();
|
|
||||||
}
|
|
||||||
|
|
||||||
public SubscriptionModel GetByWebhookAndSource(Guid webhookId, Guid sourceId)
|
|
||||||
{
|
|
||||||
using var conn = OpenConnection(_connectionString);
|
|
||||||
var query = @"Select * From subscriptions
|
|
||||||
Where discordwebhookid = @webhookid
|
|
||||||
and sourceid = @sourceid;";
|
|
||||||
var res = conn.Query<SubscriptionModel>(query, new
|
|
||||||
{
|
|
||||||
webhookid = webhookId,
|
|
||||||
sourceid = sourceId
|
|
||||||
});
|
|
||||||
if (res.Count() == 0) return new SubscriptionModel();
|
|
||||||
return res.First();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Delete(Guid id)
|
|
||||||
{
|
|
||||||
using var conn = OpenConnection(_connectionString);
|
|
||||||
var query = "Delete From subscriptions Where id = @id;";
|
|
||||||
conn.Execute(query, new
|
|
||||||
{
|
|
||||||
id
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
private IDbConnection OpenConnection(string connectionString)
|
|
||||||
{
|
|
||||||
var conn = new NpgsqlConnection(_connectionString);
|
|
||||||
conn.Open();
|
|
||||||
return conn;
|
|
||||||
}
|
|
||||||
}
|
|
@ -0,0 +1,27 @@
|
|||||||
|
using Newsbot.Collector.Domain.Entities;
|
||||||
|
using Newsbot.Collector.Domain.Interfaces;
|
||||||
|
|
||||||
|
namespace Newsbot.Collector.Database.Repositories;
|
||||||
|
|
||||||
|
public class UserSourceSubscriptionTable : IUserSourceSubscription
|
||||||
|
{
|
||||||
|
private DatabaseContext _context;
|
||||||
|
|
||||||
|
public UserSourceSubscriptionTable(string connectionString)
|
||||||
|
{
|
||||||
|
_context = new DatabaseContext(connectionString);
|
||||||
|
}
|
||||||
|
|
||||||
|
public UserSourceSubscriptionTable(DatabaseContext context)
|
||||||
|
{
|
||||||
|
_context = context;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<UserSourceSubscriptionEntity> ListUserSubscriptions(Guid userId)
|
||||||
|
{
|
||||||
|
var results =_context.UserSourceSubscription
|
||||||
|
.Where(i => i.UserId != null && i.UserId.Equals(userId)).ToList();
|
||||||
|
return results;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
13
Newsbot.Collector.Domain/Consts/Authorization.cs
Normal file
13
Newsbot.Collector.Domain/Consts/Authorization.cs
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
namespace Newsbot.Collector.Api.Domain.Consts;
|
||||||
|
|
||||||
|
public static class Authorization
|
||||||
|
{
|
||||||
|
public const string AdministratorPolicy = "Administrator";
|
||||||
|
public const string AdministratorsRole = AdministratorPolicy;
|
||||||
|
public const string AdministratorClaim = "administrator";
|
||||||
|
|
||||||
|
|
||||||
|
public const string UserPolicy = "User";
|
||||||
|
public const string UsersRole = UserPolicy;
|
||||||
|
public const string UserClaim = "user";
|
||||||
|
}
|
@ -1,10 +0,0 @@
|
|||||||
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";
|
|
||||||
}
|
|
@ -2,6 +2,9 @@ namespace Newsbot.Collector.Domain.Consts;
|
|||||||
|
|
||||||
public class ConfigConst
|
public class ConfigConst
|
||||||
{
|
{
|
||||||
|
public const string RunDatabaseMigrationsOnStartup = "RunDatabaseMigrationsOnStartup";
|
||||||
|
public const string ApiKeys = "ApiKeys";
|
||||||
|
|
||||||
public const string LoggingDefault = "Logging:LogLevel:Default";
|
public const string LoggingDefault = "Logging:LogLevel:Default";
|
||||||
|
|
||||||
public const string SectionConnectionStrings = "ConnectionStrings";
|
public const string SectionConnectionStrings = "ConnectionStrings";
|
||||||
|
@ -1,11 +0,0 @@
|
|||||||
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";
|
|
||||||
}
|
|
@ -1,10 +0,0 @@
|
|||||||
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,10 +1,11 @@
|
|||||||
|
using Newsbot.Collector.Domain.Entities;
|
||||||
using Newsbot.Collector.Domain.Models;
|
using Newsbot.Collector.Domain.Models;
|
||||||
|
|
||||||
namespace Newsbot.Collector.Domain.Dto;
|
namespace Newsbot.Collector.Domain.Dto;
|
||||||
|
|
||||||
public class ArticleDetailsDto
|
public class ArticleDetailsDto
|
||||||
{
|
{
|
||||||
public Guid ID { get; set; }
|
public Guid Id { get; set; }
|
||||||
public string[]? Tags { get; set; }
|
public string[]? Tags { get; set; }
|
||||||
public string? Title { get; set; }
|
public string? Title { get; set; }
|
||||||
public string? Url { get; set; }
|
public string? Url { get; set; }
|
||||||
@ -18,24 +19,24 @@ public class ArticleDetailsDto
|
|||||||
public string? AuthorImage { get; set; }
|
public string? AuthorImage { get; set; }
|
||||||
|
|
||||||
public SourceDto? Source { get; set; }
|
public SourceDto? Source { get; set; }
|
||||||
|
public AuthorEntity? Author { get; set; }
|
||||||
|
|
||||||
public static ArticleDetailsDto Convert(ArticlesModel article, SourceModel source)
|
public static ArticleDetailsDto Convert(ArticlesEntity article, SourceEntity source, AuthorEntity? author)
|
||||||
{
|
{
|
||||||
return new ArticleDetailsDto
|
return new ArticleDetailsDto
|
||||||
{
|
{
|
||||||
ID = article.ID,
|
Id = article.Id,
|
||||||
Tags = article.Tags.Split(','),
|
Tags = article.Tags.Split(','),
|
||||||
Title = article.Title,
|
Title = article.Title,
|
||||||
Url = article.URL,
|
Url = article.Url,
|
||||||
PubDate = article.PubDate,
|
PubDate = article.PubDate,
|
||||||
Video = article.Video,
|
Video = article.Video,
|
||||||
VideoHeight = article.VideoHeight,
|
VideoHeight = article.VideoHeight,
|
||||||
VideoWidth = article.VideoWidth,
|
VideoWidth = article.VideoWidth,
|
||||||
Thumbnail = article.Thumbnail,
|
Thumbnail = article.Thumbnail,
|
||||||
Description = article.Description,
|
Description = article.Description,
|
||||||
AuthorName = article.AuthorName,
|
Source = SourceDto.Convert(source),
|
||||||
AuthorImage = article.AuthorImage,
|
|
||||||
Source = SourceDto.Convert(source)
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
using Newsbot.Collector.Domain.Entities;
|
||||||
using Newsbot.Collector.Domain.Models;
|
using Newsbot.Collector.Domain.Models;
|
||||||
|
|
||||||
namespace Newsbot.Collector.Domain.Dto;
|
namespace Newsbot.Collector.Domain.Dto;
|
||||||
@ -6,6 +7,7 @@ public class ArticleDto
|
|||||||
{
|
{
|
||||||
public Guid ID { get; set; }
|
public Guid ID { get; set; }
|
||||||
public Guid SourceID { get; set; }
|
public Guid SourceID { get; set; }
|
||||||
|
public Guid AuthorId { get; set; }
|
||||||
public string[]? Tags { get; set; }
|
public string[]? Tags { get; set; }
|
||||||
public string? Title { get; set; }
|
public string? Title { get; set; }
|
||||||
public string? Url { get; set; }
|
public string? Url { get; set; }
|
||||||
@ -15,9 +17,7 @@ public class ArticleDto
|
|||||||
public int VideoWidth { get; set; }
|
public int VideoWidth { get; set; }
|
||||||
public string? Thumbnail { get; set; }
|
public string? Thumbnail { get; set; }
|
||||||
public string? Description { get; set; }
|
public string? Description { get; set; }
|
||||||
public string? AuthorName { get; set; }
|
public static ArticleDto Convert(ArticlesModel article)
|
||||||
public string? AuthorImage { get; set; }
|
|
||||||
public static ArticleDto Convert(ArticlesModel article)
|
|
||||||
{
|
{
|
||||||
return new ArticleDto
|
return new ArticleDto
|
||||||
{
|
{
|
||||||
@ -32,8 +32,25 @@ public class ArticleDto
|
|||||||
VideoWidth = article.VideoWidth,
|
VideoWidth = article.VideoWidth,
|
||||||
Thumbnail = article.Thumbnail,
|
Thumbnail = article.Thumbnail,
|
||||||
Description = article.Description,
|
Description = article.Description,
|
||||||
AuthorName = article.AuthorName,
|
};
|
||||||
AuthorImage = article.AuthorImage,
|
}
|
||||||
|
|
||||||
|
public static ArticleDto Convert(ArticlesEntity article)
|
||||||
|
{
|
||||||
|
return new ArticleDto
|
||||||
|
{
|
||||||
|
ID = article.Id,
|
||||||
|
SourceID = article.SourceId,
|
||||||
|
AuthorId = article.AuthorId,
|
||||||
|
Tags = article.Tags.Split(','),
|
||||||
|
Title = article.Title,
|
||||||
|
Url = article.Url,
|
||||||
|
PubDate = article.PubDate,
|
||||||
|
Video = article.Video,
|
||||||
|
VideoHeight = article.VideoHeight,
|
||||||
|
VideoWidth = article.VideoWidth,
|
||||||
|
Thumbnail = article.Thumbnail,
|
||||||
|
Description = article.Description
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
9
Newsbot.Collector.Domain/Dto/AuthorDto.cs
Normal file
9
Newsbot.Collector.Domain/Dto/AuthorDto.cs
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
namespace Newsbot.Collector.Domain.Dto;
|
||||||
|
|
||||||
|
public class AuthorDto
|
||||||
|
{
|
||||||
|
public Guid Id { get; set; }
|
||||||
|
public Guid SourceId { get; set; }
|
||||||
|
public string? Name { get; set; }
|
||||||
|
public string? Image { get; set; }
|
||||||
|
}
|
@ -0,0 +1,26 @@
|
|||||||
|
using Newsbot.Collector.Domain.Entities;
|
||||||
|
using Newsbot.Collector.Domain.Models;
|
||||||
|
|
||||||
|
namespace Newsbot.Collector.Domain.Dto;
|
||||||
|
|
||||||
|
public class DiscordNotificationDetailsDto
|
||||||
|
{
|
||||||
|
public Guid Id { get; set; }
|
||||||
|
public bool CodeAllowReleases { get; set; }
|
||||||
|
public bool CodeAllowCommits { get; set; }
|
||||||
|
public SourceDto? Source { get; set; }
|
||||||
|
public DiscordWebHookDto? DiscordWebHook { get; set; }
|
||||||
|
|
||||||
|
public static DiscordNotificationDetailsDto Convert(DiscordNotificationEntity discordNotification, SourceEntity source,
|
||||||
|
DiscordWebhookEntity discord)
|
||||||
|
{
|
||||||
|
return new DiscordNotificationDetailsDto
|
||||||
|
{
|
||||||
|
Id = discordNotification.Id,
|
||||||
|
CodeAllowCommits = discordNotification.CodeAllowCommits,
|
||||||
|
CodeAllowReleases = discordNotification.CodeAllowReleases,
|
||||||
|
Source = SourceDto.Convert(source),
|
||||||
|
DiscordWebHook = DiscordWebHookDto.Convert(discord)
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
@ -1,8 +1,9 @@
|
|||||||
|
using Newsbot.Collector.Domain.Entities;
|
||||||
using Newsbot.Collector.Domain.Models;
|
using Newsbot.Collector.Domain.Models;
|
||||||
|
|
||||||
namespace Newsbot.Collector.Domain.Dto;
|
namespace Newsbot.Collector.Domain.Dto;
|
||||||
|
|
||||||
public class SubscriptionDto
|
public class DiscordNotificationDto
|
||||||
{
|
{
|
||||||
public Guid Id { get; set; }
|
public Guid Id { get; set; }
|
||||||
public Guid SourceId { get; set; }
|
public Guid SourceId { get; set; }
|
||||||
@ -10,9 +11,9 @@ public class SubscriptionDto
|
|||||||
public bool CodeAllowReleases { get; set; }
|
public bool CodeAllowReleases { get; set; }
|
||||||
public bool CodeAllowCommits { get; set; }
|
public bool CodeAllowCommits { get; set; }
|
||||||
|
|
||||||
public static SubscriptionDto Convert(SubscriptionModel model)
|
public static DiscordNotificationDto Convert(DiscordNotificationEntity model)
|
||||||
{
|
{
|
||||||
return new SubscriptionDto
|
return new DiscordNotificationDto
|
||||||
{
|
{
|
||||||
Id = model.Id,
|
Id = model.Id,
|
||||||
SourceId = model.SourceId,
|
SourceId = model.SourceId,
|
@ -1,4 +1,4 @@
|
|||||||
using Newsbot.Collector.Domain.Models;
|
using Newsbot.Collector.Domain.Entities;
|
||||||
|
|
||||||
namespace Newsbot.Collector.Domain.Dto;
|
namespace Newsbot.Collector.Domain.Dto;
|
||||||
|
|
||||||
@ -10,11 +10,11 @@ public class DiscordWebHookDto
|
|||||||
public string? Channel { get; set; }
|
public string? Channel { get; set; }
|
||||||
public bool Enabled { get; set; }
|
public bool Enabled { get; set; }
|
||||||
|
|
||||||
public static DiscordWebHookDto Convert(DiscordWebHookModel model)
|
public static DiscordWebHookDto Convert(DiscordWebhookEntity model)
|
||||||
{
|
{
|
||||||
return new DiscordWebHookDto
|
return new DiscordWebHookDto
|
||||||
{
|
{
|
||||||
ID = model.ID,
|
ID = model.Id,
|
||||||
Url = model.Url,
|
Url = model.Url,
|
||||||
Server = model.Server,
|
Server = model.Server,
|
||||||
Channel = model.Channel,
|
Channel = model.Channel,
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
using System.Net.NetworkInformation;
|
using System.Net.NetworkInformation;
|
||||||
|
using Newsbot.Collector.Domain.Entities;
|
||||||
using Newsbot.Collector.Domain.Models;
|
using Newsbot.Collector.Domain.Models;
|
||||||
|
|
||||||
namespace Newsbot.Collector.Domain.Dto;
|
namespace Newsbot.Collector.Domain.Dto;
|
||||||
@ -16,10 +17,10 @@ public class SourceDto
|
|||||||
public string[]? Tags { get; set; }
|
public string[]? Tags { get; set; }
|
||||||
public bool Deleted { get; set; }
|
public bool Deleted { get; set; }
|
||||||
|
|
||||||
public static SourceDto Convert(SourceModel model) {
|
public static SourceDto Convert(SourceEntity model) {
|
||||||
return new SourceDto
|
return new SourceDto
|
||||||
{
|
{
|
||||||
ID = model.ID,
|
ID = model.Id,
|
||||||
Site = model.Site,
|
Site = model.Site,
|
||||||
Name = model.Name,
|
Name = model.Name,
|
||||||
Source = model.Source,
|
Source = model.Source,
|
||||||
|
@ -1,25 +0,0 @@
|
|||||||
using Newsbot.Collector.Domain.Models;
|
|
||||||
|
|
||||||
namespace Newsbot.Collector.Domain.Dto;
|
|
||||||
|
|
||||||
public class SubscriptionDetailsDto
|
|
||||||
{
|
|
||||||
public Guid Id { get; set; }
|
|
||||||
public bool CodeAllowReleases { get; set; }
|
|
||||||
public bool CodeAllowCommits { get; set; }
|
|
||||||
public SourceDto? Source { get; set; }
|
|
||||||
public DiscordWebHookDto? DiscordWebHook { get; set; }
|
|
||||||
|
|
||||||
public static SubscriptionDetailsDto Convert(SubscriptionModel subscription, SourceModel source,
|
|
||||||
DiscordWebHookModel discord)
|
|
||||||
{
|
|
||||||
return new SubscriptionDetailsDto
|
|
||||||
{
|
|
||||||
Id = subscription.Id,
|
|
||||||
CodeAllowCommits = subscription.CodeAllowCommits,
|
|
||||||
CodeAllowReleases = subscription.CodeAllowReleases,
|
|
||||||
Source = SourceDto.Convert(source),
|
|
||||||
DiscordWebHook = DiscordWebHookDto.Convert(discord)
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
7
Newsbot.Collector.Domain/Dto/UserNewDto.cs
Normal file
7
Newsbot.Collector.Domain/Dto/UserNewDto.cs
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
namespace Newsbot.Collector.Domain.Dto;
|
||||||
|
|
||||||
|
public class UserNewDto
|
||||||
|
{
|
||||||
|
public string? Username { get; set; }
|
||||||
|
public string? Password { get; set; }
|
||||||
|
}
|
19
Newsbot.Collector.Domain/Entities/ArticlesEntity.cs
Normal file
19
Newsbot.Collector.Domain/Entities/ArticlesEntity.cs
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
namespace Newsbot.Collector.Domain.Entities;
|
||||||
|
|
||||||
|
public class ArticlesEntity
|
||||||
|
{
|
||||||
|
public Guid Id { get; set; }
|
||||||
|
public Guid SourceId { get; set; }
|
||||||
|
public Guid AuthorId { get; set; }
|
||||||
|
public string Tags { get; set; } = "";
|
||||||
|
public string Title { get; set; } = "";
|
||||||
|
public string? Url { get; set; }
|
||||||
|
public DateTime PubDate { get; set; } = DateTime.Now;
|
||||||
|
public string Video { get; set; } = "";
|
||||||
|
public int VideoHeight { get; set; } = 0;
|
||||||
|
public int VideoWidth { get; set; } = 0;
|
||||||
|
public string Thumbnail { get; set; } = "";
|
||||||
|
public string Description { get; set; } = "";
|
||||||
|
public bool CodeIsRelease { get; set; }
|
||||||
|
public bool CodeIsCommit { get; set; }
|
||||||
|
}
|
9
Newsbot.Collector.Domain/Entities/AuthorEntity.cs
Normal file
9
Newsbot.Collector.Domain/Entities/AuthorEntity.cs
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
namespace Newsbot.Collector.Domain.Entities;
|
||||||
|
|
||||||
|
public class AuthorEntity
|
||||||
|
{
|
||||||
|
public Guid Id { get; set; }
|
||||||
|
public Guid SourceId { get; set; }
|
||||||
|
public string Name { get; set; } = "";
|
||||||
|
public string Image { get; set; } = "";
|
||||||
|
}
|
@ -0,0 +1,18 @@
|
|||||||
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
using Microsoft.AspNetCore.Identity;
|
||||||
|
|
||||||
|
namespace Newsbot.Collector.Domain.Entities;
|
||||||
|
|
||||||
|
public class DiscordNotificationEntity
|
||||||
|
{
|
||||||
|
public Guid Id { get; set; }
|
||||||
|
public bool CodeAllowReleases { get; set; }
|
||||||
|
public bool CodeAllowCommits { get; set; }
|
||||||
|
|
||||||
|
public Guid SourceId { get; set; }
|
||||||
|
public Guid DiscordWebHookId { get; set; }
|
||||||
|
|
||||||
|
public string? UserId { get; set; }
|
||||||
|
//[ForeignKey(nameof(UserId))]
|
||||||
|
//public IdentityUser User { get; set; }
|
||||||
|
}
|
7
Newsbot.Collector.Domain/Entities/DiscordQueueEntity.cs
Normal file
7
Newsbot.Collector.Domain/Entities/DiscordQueueEntity.cs
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
namespace Newsbot.Collector.Domain.Entities;
|
||||||
|
|
||||||
|
public class DiscordQueueEntity
|
||||||
|
{
|
||||||
|
public Guid Id { get; set; }
|
||||||
|
public Guid ArticleId { get; set; }
|
||||||
|
}
|
17
Newsbot.Collector.Domain/Entities/DiscordWebhookEntity.cs
Normal file
17
Newsbot.Collector.Domain/Entities/DiscordWebhookEntity.cs
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
using Microsoft.AspNetCore.Identity;
|
||||||
|
|
||||||
|
namespace Newsbot.Collector.Domain.Entities;
|
||||||
|
|
||||||
|
public class DiscordWebhookEntity
|
||||||
|
{
|
||||||
|
public Guid Id { get; set; }
|
||||||
|
public string Url { get; set; } = "";
|
||||||
|
public string Server { get; set; } = "";
|
||||||
|
public string Channel { get; set; } = "";
|
||||||
|
public bool Enabled { get; set; }
|
||||||
|
|
||||||
|
public string? UserId { get; set; }
|
||||||
|
[ForeignKey(nameof(UserId))]
|
||||||
|
public IdentityUser? User { get; set; }
|
||||||
|
}
|
10
Newsbot.Collector.Domain/Entities/IconEntity.cs
Normal file
10
Newsbot.Collector.Domain/Entities/IconEntity.cs
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
namespace Newsbot.Collector.Domain.Entities;
|
||||||
|
|
||||||
|
public class IconEntity
|
||||||
|
{
|
||||||
|
public Guid Id { get; set; }
|
||||||
|
public string FileName { get; set; } = "";
|
||||||
|
public string Site { get; set; } = "";
|
||||||
|
|
||||||
|
public Guid SourceId { get; set; }
|
||||||
|
}
|
21
Newsbot.Collector.Domain/Entities/RefreshTokenEntity.cs
Normal file
21
Newsbot.Collector.Domain/Entities/RefreshTokenEntity.cs
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
using Microsoft.AspNetCore.Identity;
|
||||||
|
|
||||||
|
namespace Newsbot.Collector.Domain.Entities;
|
||||||
|
|
||||||
|
public class RefreshTokenEntity
|
||||||
|
{
|
||||||
|
|
||||||
|
[Key]
|
||||||
|
public string? Token { get; set; }
|
||||||
|
public string? JwtId { get; set; }
|
||||||
|
public DateTime CreatedDate { get; set; }
|
||||||
|
public DateTime ExpiryDate { get; set; }
|
||||||
|
public bool Used { get; set; }
|
||||||
|
public bool Invalidated { get; set; }
|
||||||
|
|
||||||
|
public string? UserId { get; set; }
|
||||||
|
[ForeignKey(nameof(UserId))]
|
||||||
|
public IdentityUser? User { get; set; }
|
||||||
|
}
|
18
Newsbot.Collector.Domain/Entities/SourceEntity.cs
Normal file
18
Newsbot.Collector.Domain/Entities/SourceEntity.cs
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
namespace Newsbot.Collector.Domain.Entities;
|
||||||
|
|
||||||
|
public class SourceEntity
|
||||||
|
{
|
||||||
|
public Guid Id { get; set; }
|
||||||
|
public string Site { get; set; } = "";
|
||||||
|
public string Name { get; set; } = "";
|
||||||
|
|
||||||
|
// Source use to define the worker to query with but moving to Type as it was not used really.
|
||||||
|
public string Source { get; set; } = "";
|
||||||
|
public string Type { get; set; } = "";
|
||||||
|
public string Value { get; set; } = "";
|
||||||
|
public bool Enabled { get; set; }
|
||||||
|
public string Url { get; set; } = "";
|
||||||
|
public string Tags { get; set; } = "";
|
||||||
|
public bool Deleted { get; set; }
|
||||||
|
public string YoutubeId { get; set; } = "";
|
||||||
|
}
|
@ -0,0 +1,20 @@
|
|||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
using Microsoft.AspNetCore.Identity;
|
||||||
|
|
||||||
|
namespace Newsbot.Collector.Domain.Entities;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// This defines the sources a user will want to see as a feed.
|
||||||
|
/// </summary>
|
||||||
|
public class UserSourceSubscriptionEntity
|
||||||
|
{
|
||||||
|
[Key]
|
||||||
|
public Guid Id { get; set; }
|
||||||
|
public Guid SourceId { get; set; }
|
||||||
|
public DateTimeOffset DateAdded { get; set; }
|
||||||
|
|
||||||
|
public string? UserId { get; set; }
|
||||||
|
[ForeignKey(nameof(UserId))]
|
||||||
|
public IdentityUser? User { get; set; }
|
||||||
|
}
|
@ -1,13 +1,14 @@
|
|||||||
|
using Newsbot.Collector.Domain.Entities;
|
||||||
using Newsbot.Collector.Domain.Models;
|
using Newsbot.Collector.Domain.Models;
|
||||||
|
|
||||||
namespace Newsbot.Collector.Domain.Interfaces;
|
namespace Newsbot.Collector.Domain.Interfaces;
|
||||||
|
|
||||||
public interface IArticlesRepository : ITableRepository
|
public interface IArticlesRepository : ITableRepository
|
||||||
{
|
{
|
||||||
List<ArticlesModel> List(int page, int count);
|
List<ArticlesEntity> List(int page, int count = 25);
|
||||||
List<ArticlesModel> ListBySourceId(Guid id, int page = 0, int count = 25);
|
List<ArticlesEntity> ListBySourceId(Guid id, int page = 0, int count = 25);
|
||||||
ArticlesModel GetById(Guid ID);
|
ArticlesEntity GetById(Guid id);
|
||||||
ArticlesModel GetByUrl(string url);
|
ArticlesEntity GetByUrl(string url);
|
||||||
ArticlesModel New(ArticlesModel model);
|
ArticlesEntity New(ArticlesEntity model);
|
||||||
void DeleteAllBySourceId(Guid sourceId);
|
void DeleteAllBySourceId(Guid sourceId);
|
||||||
}
|
}
|
14
Newsbot.Collector.Domain/Interfaces/IAuthorTable.cs
Normal file
14
Newsbot.Collector.Domain/Interfaces/IAuthorTable.cs
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
using Newsbot.Collector.Domain.Entities;
|
||||||
|
|
||||||
|
namespace Newsbot.Collector.Domain.Interfaces;
|
||||||
|
|
||||||
|
public interface IAuthorTable
|
||||||
|
{
|
||||||
|
Task<AuthorEntity> NewAsync(AuthorEntity entity);
|
||||||
|
|
||||||
|
Task<AuthorEntity> CreateIfMissingAsync(AuthorEntity entity);
|
||||||
|
Task<List<AuthorEntity>> ListBySourceIdAsync(Guid sourceId);
|
||||||
|
Task<int> TotalPostsAsync(Guid id);
|
||||||
|
Task<AuthorEntity?> GetBySourceIdAndNameAsync(Guid sourceId, string name);
|
||||||
|
Task<AuthorEntity?> GetById(Guid id);
|
||||||
|
}
|
@ -1,9 +0,0 @@
|
|||||||
using Newsbot.Collector.Domain.Models;
|
|
||||||
|
|
||||||
namespace Newsbot.Collector.Domain.Interfaces;
|
|
||||||
|
|
||||||
///
|
|
||||||
public interface ICollector : IHangfireJob
|
|
||||||
{
|
|
||||||
List<ArticlesModel> Collect();
|
|
||||||
}
|
|
@ -2,7 +2,7 @@ using Newsbot.Collector.Domain.Models;
|
|||||||
|
|
||||||
namespace Newsbot.Collector.Domain.Interfaces;
|
namespace Newsbot.Collector.Domain.Interfaces;
|
||||||
|
|
||||||
public interface IDiscordNotificatioClient
|
public interface IDiscordClient
|
||||||
{
|
{
|
||||||
void SendMessage(DiscordMessage payload);
|
void SendMessage(DiscordMessage payload);
|
||||||
}
|
}
|
@ -0,0 +1,28 @@
|
|||||||
|
using Newsbot.Collector.Domain.Entities;
|
||||||
|
using Newsbot.Collector.Domain.Models;
|
||||||
|
|
||||||
|
namespace Newsbot.Collector.Domain.Interfaces;
|
||||||
|
|
||||||
|
public interface IDiscordNotificationRepository
|
||||||
|
{
|
||||||
|
DiscordNotificationEntity New(DiscordNotificationEntity model);
|
||||||
|
|
||||||
|
List<DiscordNotificationEntity> List(string userId, 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> ListByWebhook(string userId, Guid id, int page = 0, int count = 25);
|
||||||
|
|
||||||
|
DiscordNotificationEntity GetById(string userId, Guid id);
|
||||||
|
DiscordNotificationEntity GetByWebhookAndSource(string userId, Guid webhookId, Guid sourceId);
|
||||||
|
|
||||||
|
int Delete(string userId, Guid id);
|
||||||
|
}
|
@ -1,10 +1,10 @@
|
|||||||
using Newsbot.Collector.Domain.Models;
|
using Newsbot.Collector.Domain.Entities;
|
||||||
|
|
||||||
namespace Newsbot.Collector.Domain.Interfaces;
|
namespace Newsbot.Collector.Domain.Interfaces;
|
||||||
|
|
||||||
public interface IDiscordQueueRepository
|
public interface IDiscordQueueRepository
|
||||||
{
|
{
|
||||||
void New(DiscordQueueModel model);
|
void New(DiscordQueueEntity model);
|
||||||
void Delete(Guid id);
|
void Delete(Guid id);
|
||||||
List<DiscordQueueModel> List(int limit);
|
List<DiscordQueueEntity> List(int limit);
|
||||||
}
|
}
|
@ -1,19 +1,21 @@
|
|||||||
using Microsoft.VisualBasic;
|
using Newsbot.Collector.Domain.Entities;
|
||||||
using Newsbot.Collector.Domain.Models;
|
|
||||||
|
|
||||||
namespace Newsbot.Collector.Domain.Interfaces;
|
namespace Newsbot.Collector.Domain.Interfaces;
|
||||||
|
|
||||||
public interface IDiscordWebHooksRepository
|
public interface IDiscordWebHooksRepository
|
||||||
{
|
{
|
||||||
DiscordWebHookModel New(DiscordWebHookModel model);
|
DiscordWebhookEntity New(DiscordWebhookEntity model);
|
||||||
|
|
||||||
DiscordWebHookModel GetByID(Guid id);
|
DiscordWebhookEntity GetById(string userId, Guid id);
|
||||||
DiscordWebHookModel GetByUrl(string url);
|
DiscordWebhookEntity GetById(Guid id);
|
||||||
|
|
||||||
|
DiscordWebhookEntity GetByUrl(string url);
|
||||||
|
|
||||||
List<DiscordWebHookModel> List(int page, int count = 25);
|
List<DiscordWebhookEntity> List(int page, int count = 25);
|
||||||
List<DiscordWebHookModel> ListByServer(string server, int limit);
|
List<DiscordWebhookEntity> ListByUserId(string userId, int page);
|
||||||
List<DiscordWebHookModel> ListByServerAndChannel(string server, string channel, int limit);
|
List<DiscordWebhookEntity> ListByServer(string server, int limit);
|
||||||
|
List<DiscordWebhookEntity> ListByServerAndChannel(string userId, string server, string channel, int limit);
|
||||||
|
|
||||||
int Disable(Guid id);
|
int Disable(string userId, Guid id);
|
||||||
int Enable(Guid id);
|
int Enable(string userId, Guid id);
|
||||||
}
|
}
|
@ -1,11 +1,11 @@
|
|||||||
using Newsbot.Collector.Domain.Models;
|
using Newsbot.Collector.Domain.Entities;
|
||||||
|
|
||||||
namespace Newsbot.Collector.Domain.Interfaces;
|
namespace Newsbot.Collector.Domain.Interfaces;
|
||||||
|
|
||||||
public interface IIconsRepository
|
public interface IIconsRepository
|
||||||
{
|
{
|
||||||
public void New(IconModel model);
|
public void New(IconEntity model);
|
||||||
|
|
||||||
public IconModel GetById(Guid id);
|
public IconEntity GetById(Guid id);
|
||||||
public IconModel GetBySourceId(Guid id);
|
public IconEntity GetBySourceId(Guid id);
|
||||||
}
|
}
|
@ -0,0 +1,10 @@
|
|||||||
|
using Newsbot.Collector.Domain.Entities;
|
||||||
|
|
||||||
|
namespace Newsbot.Collector.Domain.Interfaces;
|
||||||
|
|
||||||
|
public interface IRefreshTokenRepository
|
||||||
|
{
|
||||||
|
void Add(RefreshTokenEntity entity);
|
||||||
|
public RefreshTokenEntity? Get(string token);
|
||||||
|
void UpdateTokenIsUsed(string token);
|
||||||
|
}
|
@ -1,18 +1,20 @@
|
|||||||
|
using Newsbot.Collector.Domain.Entities;
|
||||||
using Newsbot.Collector.Domain.Models;
|
using Newsbot.Collector.Domain.Models;
|
||||||
|
|
||||||
namespace Newsbot.Collector.Domain.Interfaces;
|
namespace Newsbot.Collector.Domain.Interfaces;
|
||||||
|
|
||||||
public interface ISourcesRepository
|
public interface ISourcesRepository
|
||||||
{
|
{
|
||||||
public SourceModel New(SourceModel model);
|
public SourceEntity New(SourceEntity model);
|
||||||
public SourceModel GetByID(Guid ID);
|
public SourceEntity GetById(Guid id);
|
||||||
public SourceModel GetByID(string ID);
|
public SourceEntity GetById(string id);
|
||||||
public SourceModel GetByName(string name);
|
public SourceEntity GetByName(string name);
|
||||||
public SourceModel GetByNameAndType(string name, string type);
|
public SourceEntity GetByNameAndType(string name, string type);
|
||||||
SourceModel GetByUrl(string url);
|
SourceEntity GetByUrl(string url);
|
||||||
public List<SourceModel> List(int page, int count);
|
public List<SourceEntity> List(int page, int count);
|
||||||
public List<SourceModel> ListBySource(string source, int limit);
|
public List<SourceEntity> ListBySource(string source,int page, int limit);
|
||||||
public List<SourceModel> ListByType(string type, int limit = 25);
|
public List<SourceEntity> ListByType(string type,int page, int limit = 25);
|
||||||
|
public Task<int> TotalByTypeAsync(string type);
|
||||||
public int Disable(Guid id);
|
public int Disable(Guid id);
|
||||||
public int Enable(Guid id);
|
public int Enable(Guid id);
|
||||||
public void Delete(Guid id);
|
public void Delete(Guid id);
|
||||||
|
@ -1,17 +0,0 @@
|
|||||||
using Newsbot.Collector.Domain.Models;
|
|
||||||
|
|
||||||
namespace Newsbot.Collector.Domain.Interfaces;
|
|
||||||
|
|
||||||
public interface ISubscriptionRepository
|
|
||||||
{
|
|
||||||
SubscriptionModel New(SubscriptionModel model);
|
|
||||||
|
|
||||||
List<SubscriptionModel> List(int page = 0, int count = 25);
|
|
||||||
List<SubscriptionModel> ListBySourceID(Guid id, int page = 0, int count = 25);
|
|
||||||
List<SubscriptionModel> ListByWebhook(Guid id, int page = 0, int count = 25);
|
|
||||||
|
|
||||||
SubscriptionModel GetById(Guid id);
|
|
||||||
SubscriptionModel GetByWebhookAndSource(Guid webhookId, Guid sourceId);
|
|
||||||
|
|
||||||
void Delete(Guid id);
|
|
||||||
}
|
|
@ -0,0 +1,8 @@
|
|||||||
|
using Newsbot.Collector.Domain.Entities;
|
||||||
|
|
||||||
|
namespace Newsbot.Collector.Domain.Interfaces;
|
||||||
|
|
||||||
|
public interface IUserSourceSubscription
|
||||||
|
{
|
||||||
|
List<UserSourceSubscriptionEntity> ListUserSubscriptions(Guid userId);
|
||||||
|
}
|
@ -1,13 +1,24 @@
|
|||||||
|
using Newsbot.Collector.Domain.Models.Config;
|
||||||
|
|
||||||
namespace Newsbot.Collector.Domain.Models;
|
namespace Newsbot.Collector.Domain.Models;
|
||||||
|
|
||||||
public class ConfigModel
|
public class ConfigModel
|
||||||
{
|
{
|
||||||
public string? ServerAddress { get; set; }
|
public ConnectionStrings? ConnectionStrings { get; set; }
|
||||||
public string? SqlConnectionString { get; set; }
|
public RedditConfig? Reddit { get; set; }
|
||||||
public RedditConfigModel? Reddit { get; set; }
|
public YoutubeConfig? Youtube { 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 RedditConfigModel
|
public class RedditConfig
|
||||||
{
|
{
|
||||||
public bool IsEnabled { get; set; }
|
public bool IsEnabled { get; set; }
|
||||||
public bool PullHot { get; set; }
|
public bool PullHot { get; set; }
|
||||||
@ -17,5 +28,29 @@ public class RedditConfigModel
|
|||||||
|
|
||||||
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; }
|
||||||
|
}
|
||||||
|
@ -1,9 +0,0 @@
|
|||||||
namespace Newsbot.Collector.Domain.Models.Config;
|
|
||||||
|
|
||||||
public class ConfigSectionRedditModel
|
|
||||||
{
|
|
||||||
public bool IsEnabled { get; set; }
|
|
||||||
public bool PullHot { get; set; }
|
|
||||||
public bool PullNsfw { get; set; }
|
|
||||||
public bool PullTop { get; set; }
|
|
||||||
}
|
|
6
Newsbot.Collector.Domain/Models/Config/JwtSettings.cs
Normal file
6
Newsbot.Collector.Domain/Models/Config/JwtSettings.cs
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
namespace Newsbot.Collector.Domain.Models.Config;
|
||||||
|
|
||||||
|
public class JwtSettings
|
||||||
|
{
|
||||||
|
public string? Secret { get; set; }
|
||||||
|
}
|
@ -1,4 +1,4 @@
|
|||||||
namespace Newsbot.Collector.Domain.Models.Config;
|
namespace Newsbot.Collector.Domain.Models.Config.Sources;
|
||||||
|
|
||||||
public class ConfigSectionRssModel
|
public class ConfigSectionRssModel
|
||||||
{
|
{
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user