💄 Optimized web articles
This commit is contained in:
@ -1,13 +1,15 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using DysonNetwork.Sphere.Permission;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace DysonNetwork.Sphere.Connection.WebReader;
|
||||
|
||||
[Authorize]
|
||||
[ApiController]
|
||||
[Route("feeds")]
|
||||
public class WebFeedController(WebFeedService webFeedService) : ControllerBase
|
||||
public class WebFeedController(WebFeedService webFeedService, AppDatabase database) : ControllerBase
|
||||
{
|
||||
public class CreateWebFeedRequest
|
||||
{
|
||||
@ -30,4 +32,31 @@ public class WebFeedController(WebFeedService webFeedService) : ControllerBase
|
||||
var feed = await webFeedService.CreateWebFeedAsync(request, User);
|
||||
return Ok(feed);
|
||||
}
|
||||
|
||||
[HttpPost("scrape/{feedId}")]
|
||||
[RequiredPermission("maintenance", "web-feeds")]
|
||||
public async Task<ActionResult> ScrapeFeed(Guid feedId)
|
||||
{
|
||||
var feed = await database.Set<WebFeed>().FindAsync(feedId);
|
||||
if (feed == null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
await webFeedService.ScrapeFeedAsync(feed);
|
||||
return Ok();
|
||||
}
|
||||
|
||||
[HttpPost("scrape-all")]
|
||||
[RequiredPermission("maintenance", "web-feeds")]
|
||||
public async Task<ActionResult> ScrapeAllFeeds()
|
||||
{
|
||||
var feeds = await database.Set<WebFeed>().ToListAsync();
|
||||
foreach (var feed in feeds)
|
||||
{
|
||||
await webFeedService.ScrapeFeedAsync(feed);
|
||||
}
|
||||
|
||||
return Ok();
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user