refacto API prefix + nav.back

This commit is contained in:
Paul Schneider 2026-08-20 20:50:52 +01:00
commit 6825f74308
Signed by: notazof
GPG key ID: 1DD5D838E5343B06
78 changed files with 770 additions and 222 deletions

View file

@ -1,15 +1,16 @@
using System.Linq;
using System.Security.Claims;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using Yavsc.Models;
using Yavsc.Models.Access;
using Yavsc.Server.Helpers;
using static Yavsc.Constants;
namespace Yavsc.Blogs.Controllers
{
[Produces("application/json")]
[Route("api/blogacl")]
[Route(APIPrefix+"/blogacl")]
public class BlogAclApiController : Controller
{
private readonly ApplicationDbContext _context;
@ -24,7 +25,7 @@ namespace Yavsc.Blogs.Controllers
/// Blog posts (and therefore their ACLs) are private to their
/// author — the API never exposes another user's ACL.
/// </summary>
// GET: api/blogacl
// GET: api/v1/blogacl
[HttpGet]
public IEnumerable<CircleAuthorizationToBlogPost> GetBlogACL()
{

View file

@ -3,7 +3,7 @@ using Microsoft.AspNetCore.Mvc;
using Yavsc.Blogspot;
using Yavsc.Server.Exceptions;
using Yavsc.Server.Helpers;
using static Yavsc.Blogs.Constants;
using static Yavsc.Constants;
namespace Yavsc.Blogs.Controllers
{

View file

@ -1,12 +1,8 @@
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using Yavsc.Models;
using Yavsc.Models.Blog;
using static Yavsc.Blogs.Constants;
using static Yavsc.Constants;
namespace Yavsc.Blogs.Controllers
{
[Produces("application/json")]

View file

@ -4,7 +4,7 @@ using Microsoft.EntityFrameworkCore;
using Yavsc.Models;
using Yavsc.Models.Relationship;
using Yavsc.Server.Helpers;
using static Yavsc.Blogs.Constants;
using static Yavsc.Constants;
namespace Yavsc.Blogs.Controllers
{

View file

@ -5,7 +5,7 @@ using Microsoft.EntityFrameworkCore;
using Yavsc.Models;
using Yavsc.Models.Blog;
using Yavsc.Server.Helpers;
using static Yavsc.Blogs.Constants;
using static Yavsc.Constants;
namespace Yavsc.Blogs.Controllers
{

View file

@ -2,7 +2,7 @@
using System.Security.Claims;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using static Yavsc.Blogs.Constants;
using static Yavsc.Constants;
namespace Yavsc.Blogs.Controllers
{
@ -21,7 +21,7 @@ namespace Yavsc.Blogs.Controllers
private readonly ILogger _logger;
public FileSystemApiController(ApplicationDbContext context,
IAuthorizationService authorizationService,
IAuthorizationService authorizationService,
ILoggerFactory loggerFactory)
{
@ -38,7 +38,7 @@ namespace Yavsc.Blogs.Controllers
[HttpGet("{*subdir}")]
public IActionResult GetDir([ValidRemoteUserFilePath] string subdir="")
{
{
if (!ModelState.IsValid) return new BadRequestObjectResult(ModelState);
// _logger.LogInformation($"listing files from {User.Identity.Name}{subdir}");
var files = AbstractFileSystemHelpers.GetUserFiles(User.GetUserId(), subdir);
@ -57,20 +57,20 @@ namespace Yavsc.Blogs.Controllers
} catch (InvalidPathException ex) {
pathex = ex;
}
if (pathex!=null)
if (pathex!=null)
{
_logger.LogError($"invalid sub path: '{subdir}'.");
return BadRequest(pathex);
}
_logger.LogInformation($"Receiving files, saved in '{destDir}' (specified as '{subdir}').");
var uid = User.GetUserId();
var user = dbContext.Users.Single(
u => u.Id == uid
);
int i=0;
_logger.LogInformation($"Receiving {Request.Form.Files.Count} files.");
foreach (var f in Request.Form.Files)
{
var item = user.ReceiveUserFile(destDir, f);
@ -178,7 +178,7 @@ namespace Yavsc.Blogs.Controllers
return Ok(new { deleted=id });
}
}
}

View file

@ -8,7 +8,7 @@ using Yavsc.Models.Messaging;
using Yavsc.Services;
using Microsoft.AspNetCore.SignalR;
using Yavsc.Server.Helpers;
using static Yavsc.Blogs.Constants;
using static Yavsc.Constants;
using Yavsc.Server.Hubs;
namespace Yavsc.Blogs.Controllers

View file

@ -1,5 +1,5 @@
using Microsoft.AspNetCore.Mvc;
using static Yavsc.Blogs.Constants;
using static Yavsc.Constants;
namespace Yavsc.Blogs.Controllers
{

View file

@ -1,7 +1,7 @@
using Microsoft.AspNetCore.Mvc;
using Yavsc.Models;
using static Yavsc.Blogs.Constants;
using static Yavsc.Constants;
namespace Yavsc.Controllers
{

View file

@ -2,6 +2,7 @@ using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using Yavsc.Models;
using static Yavsc.Constants;
namespace Yavsc.Blogs.Controllers
{
@ -26,7 +27,7 @@ namespace Yavsc.Blogs.Controllers
/// exposing it.</para>
/// </summary>
[Produces("application/json")]
[Route( Constants.APIPrefix + "/user-search")]
[Route(APIPrefix + "/user-search")]
[Authorize]
public class UserSearchApiController : Controller
{
@ -66,8 +67,9 @@ namespace Yavsc.Blogs.Controllers
// book callers already know the email they're
// searching for and we don't want to surface a
// long tail of partial matches.
var normalised = e.Trim();
query = query.Where(u => u.Email != null && u.Email.ToLower() == normalised.ToLower());
var normalized = e.Trim();
query = query.Where(u => u.Email != null &&
string.Compare(u.Email, normalized, true) ==0);
}
if (!string.IsNullOrWhiteSpace(q))