✨ Featured post
This commit is contained in:
@@ -19,7 +19,7 @@ public class AuthController(
|
|||||||
IConfiguration configuration
|
IConfiguration configuration
|
||||||
) : ControllerBase
|
) : ControllerBase
|
||||||
{
|
{
|
||||||
private readonly string CookieDomain = configuration["AuthToken:CookieDomain"]!;
|
private readonly string _cookieDomain = configuration["AuthToken:CookieDomain"]!;
|
||||||
|
|
||||||
public class ChallengeRequest
|
public class ChallengeRequest
|
||||||
{
|
{
|
||||||
@@ -257,7 +257,7 @@ public class AuthController(
|
|||||||
HttpOnly = true,
|
HttpOnly = true,
|
||||||
Secure = true,
|
Secure = true,
|
||||||
SameSite = SameSiteMode.Lax,
|
SameSite = SameSiteMode.Lax,
|
||||||
Domain = CookieDomain,
|
Domain = _cookieDomain,
|
||||||
Expires = DateTime.UtcNow.AddDays(30)
|
Expires = DateTime.UtcNow.AddDays(30)
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -281,7 +281,7 @@ public class AuthController(
|
|||||||
{
|
{
|
||||||
Response.Cookies.Delete(AuthConstants.CookieTokenName, new CookieOptions
|
Response.Cookies.Delete(AuthConstants.CookieTokenName, new CookieOptions
|
||||||
{
|
{
|
||||||
Domain = CookieDomain,
|
Domain = _cookieDomain,
|
||||||
HttpOnly = true,
|
HttpOnly = true,
|
||||||
Secure = true,
|
Secure = true,
|
||||||
SameSite = SameSiteMode.Lax
|
SameSite = SameSiteMode.Lax
|
||||||
|
@@ -119,7 +119,8 @@ public class PostController(
|
|||||||
var friendsResponse = await accounts.ListFriendsAsync(new ListRelationshipSimpleRequest
|
var friendsResponse = await accounts.ListFriendsAsync(new ListRelationshipSimpleRequest
|
||||||
{ AccountId = currentUser.Id });
|
{ AccountId = currentUser.Id });
|
||||||
userFriends = friendsResponse.AccountsId.Select(Guid.Parse).ToList();
|
userFriends = friendsResponse.AccountsId.Select(Guid.Parse).ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
var userPublishers = currentUser is null ? [] : await pub.GetUserPublishers(Guid.Parse(currentUser.Id));
|
var userPublishers = currentUser is null ? [] : await pub.GetUserPublishers(Guid.Parse(currentUser.Id));
|
||||||
|
|
||||||
var queryable = db.Posts
|
var queryable = db.Posts
|
||||||
@@ -150,6 +151,22 @@ public class PostController(
|
|||||||
return Ok(posts);
|
return Ok(posts);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[HttpGet("{id:guid}/replies/featured")]
|
||||||
|
public async Task<ActionResult<Post>> GetFeaturedReply(Guid id)
|
||||||
|
{
|
||||||
|
var now = SystemClock.Instance.GetCurrentInstant();
|
||||||
|
var post = await db.Posts
|
||||||
|
.Where(e => e.RepliedPostId == id)
|
||||||
|
.OrderByDescending(p =>
|
||||||
|
p.Upvotes * 2 -
|
||||||
|
p.Downvotes +
|
||||||
|
((p.CreatedAt - now).TotalMinutes < 60 ? 5 : 0)
|
||||||
|
)
|
||||||
|
.FirstOrDefaultAsync();
|
||||||
|
if (post is null) return NotFound();
|
||||||
|
return await ps.LoadPostInfo(post);
|
||||||
|
}
|
||||||
|
|
||||||
[HttpGet("{id:guid}/replies")]
|
[HttpGet("{id:guid}/replies")]
|
||||||
public async Task<ActionResult<List<Post>>> ListReplies(Guid id, [FromQuery] int offset = 0,
|
public async Task<ActionResult<List<Post>>> ListReplies(Guid id, [FromQuery] int offset = 0,
|
||||||
[FromQuery] int take = 20)
|
[FromQuery] int take = 20)
|
||||||
|
Reference in New Issue
Block a user