♻️ I have no idea what am I doing. Might be mixing stuff

This commit is contained in:
2025-07-14 19:55:28 +08:00
parent ef9175d27d
commit cbfdb4aa60
232 changed files with 990 additions and 115807 deletions

View File

@@ -1,4 +1,4 @@
using DysonNetwork.Sphere.Account;
using DysonNetwork.Shared.Proto;
using DysonNetwork.Sphere.Post;
using DysonNetwork.Sphere.Publisher;
using Microsoft.AspNetCore.Mvc;
@@ -10,11 +10,10 @@ namespace DysonNetwork.Sphere.Pages.Posts;
public class PostDetailModel(
AppDatabase db,
PublisherService pub,
RelationshipService rels
AccountService.AccountServiceClient accounts
) : PageModel
{
[BindProperty(SupportsGet = true)]
public Guid PostId { get; set; }
[BindProperty(SupportsGet = true)] public Guid PostId { get; set; }
public Post.Post? Post { get; set; }
@@ -22,20 +21,24 @@ public class PostDetailModel(
{
if (PostId == Guid.Empty)
return NotFound();
HttpContext.Items.TryGetValue("CurrentUser", out var currentUserValue);
var currentUser = currentUserValue as Sphere.Account.Account;
var userFriends = currentUser is null ? [] : await rels.ListAccountFriends(currentUser);
var userPublishers = currentUser is null ? [] : await pub.GetUserPublishers(currentUser.Id);
var currentUser = currentUserValue as Account;
var accountId = currentUser is null ? Guid.Empty : Guid.Parse(currentUser.Id);
var userFriends = currentUser is null
? []
: (await accounts.ListFriendsAsync(
new ListUserRelationshipSimpleRequest { AccountId = currentUser.Id }
)).AccountsId.Select(Guid.Parse).ToList();
var userPublishers = currentUser is null ? [] : await pub.GetUserPublishers(accountId);
Post = await db.Posts
.Where(e => e.Id == PostId)
.Include(e => e.Publisher)
.ThenInclude(p => p.Account)
.Include(e => e.Tags)
.Include(e => e.Categories)
.FilterWithVisibility(currentUser, userFriends, userPublishers)
.FirstOrDefaultAsync();
.Where(e => e.Id == PostId)
.Include(e => e.Publisher)
.Include(e => e.Tags)
.Include(e => e.Categories)
.FilterWithVisibility(currentUser, userFriends, userPublishers)
.FirstOrDefaultAsync();
if (Post == null)
return NotFound();