♻️ I have no idea what am I doing. Might be mixing stuff
This commit is contained in:
@@ -7,14 +7,14 @@
|
||||
}
|
||||
|
||||
@section Head {
|
||||
<meta property="og:title" content="@Model.Post?.Title" />
|
||||
<meta property="og:type" content="article" />
|
||||
<meta property="og:title" content="@Model.Post?.Title"/>
|
||||
<meta property="og:type" content="article"/>
|
||||
@if (imageUrl != null)
|
||||
{
|
||||
<meta property="og:image" content="/api/files/@imageUrl" />
|
||||
<meta property="og:image" content="/api/files/@imageUrl"/>
|
||||
}
|
||||
<meta property="og:url" content="@Request.Scheme://@Request.Host@Request.Path" />
|
||||
<meta property="og:description" content="@Model.Post?.Description" />
|
||||
<meta property="og:url" content="@Request.Scheme://@Request.Host@Request.Path"/>
|
||||
<meta property="og:description" content="@Model.Post?.Description"/>
|
||||
}
|
||||
|
||||
<div class="container mx-auto p-4">
|
||||
@@ -23,10 +23,7 @@
|
||||
<h1 class="text-3xl font-bold mb-4">@Model.Post.Title</h1>
|
||||
<p class="text-gray-600 mb-2">
|
||||
Created at: @Model.Post.CreatedAt
|
||||
@if (Model.Post.Publisher?.Account != null)
|
||||
{
|
||||
<span>by <a href="#" class="text-blue-500">@@@Model.Post.Publisher.Name</a></span>
|
||||
}
|
||||
<span>by <a href="#" class="text-blue-500">@@@Model.Post.Publisher.Name</a></span>
|
||||
</p>
|
||||
<div class="prose lg:prose-xl mb-4">
|
||||
@Html.Raw(Markdown.ToHtml(Model.Post.Content ?? string.Empty))
|
||||
@@ -41,7 +38,8 @@
|
||||
<div class="border p-2 rounded-md">
|
||||
@if (attachment.MimeType != null && attachment.MimeType.StartsWith("image/"))
|
||||
{
|
||||
<img src="/api/files/@attachment.Id" alt="@attachment.Name" class="w-full h-auto object-cover mb-2" />
|
||||
<img src="/api/files/@attachment.Id" alt="@attachment.Name"
|
||||
class="w-full h-auto object-cover mb-2"/>
|
||||
}
|
||||
else if (attachment.MimeType != null && attachment.MimeType.StartsWith("video/"))
|
||||
{
|
||||
|
@@ -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();
|
||||
|
Reference in New Issue
Block a user