🐛 Fix pub name
This commit is contained in:
@@ -107,7 +107,7 @@ public class PollController(AppDatabase db, PollService polls, PublisherService
|
|||||||
|
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
[Authorize]
|
[Authorize]
|
||||||
public async Task<ActionResult<Poll>> CreatePoll([FromBody] PollRequest request, [FromQuery] string pubName)
|
public async Task<ActionResult<Poll>> CreatePoll([FromBody] PollRequest request, [FromQuery(Name = "pub")] string pubName)
|
||||||
{
|
{
|
||||||
if (request.Questions is null) return BadRequest("Questions are required.");
|
if (request.Questions is null) return BadRequest("Questions are required.");
|
||||||
if (HttpContext.Items["CurrentUser"] is not Account currentUser) return Unauthorized();
|
if (HttpContext.Items["CurrentUser"] is not Account currentUser) return Unauthorized();
|
||||||
|
@@ -281,8 +281,7 @@ public class PostController(
|
|||||||
[RequiredPermission("global", "posts.create")]
|
[RequiredPermission("global", "posts.create")]
|
||||||
public async Task<ActionResult<Post>> CreatePost(
|
public async Task<ActionResult<Post>> CreatePost(
|
||||||
[FromBody] PostRequest request,
|
[FromBody] PostRequest request,
|
||||||
[FromQuery(Name = "pub")] [FromHeader(Name = "X-Pub")]
|
[FromQuery(Name = "pub")] string? pubName
|
||||||
string? pubName
|
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
request.Content = TextSanitizer.Sanitize(request.Content);
|
request.Content = TextSanitizer.Sanitize(request.Content);
|
||||||
@@ -303,7 +302,7 @@ public class PostController(
|
|||||||
{
|
{
|
||||||
publisher = await pub.GetPublisherByName(pubName);
|
publisher = await pub.GetPublisherByName(pubName);
|
||||||
if (publisher is null) return BadRequest("Publisher was not found.");
|
if (publisher is null) return BadRequest("Publisher was not found.");
|
||||||
if(!await pub.IsMemberWithRole(publisher.Id, accountId, PublisherMemberRole.Editor))
|
if (!await pub.IsMemberWithRole(publisher.Id, accountId, PublisherMemberRole.Editor))
|
||||||
return StatusCode(403, "You need at least be an editor to post as this publisher.");
|
return StatusCode(403, "You need at least be an editor to post as this publisher.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user