Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add missing fields to ThreadView/PostView #69

Merged
merged 2 commits into from
Oct 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/FishyFlip/Models/PostView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@ public record PostView(
FeedProfile Author,
Post? Record,
DateTime IndexedAt,
IReadOnlyList<Label> Label);
IReadOnlyList<Label> Label,
PostViewer? Viewer = null);
16 changes: 16 additions & 0 deletions src/FishyFlip/Models/PostViewer.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// <copyright file="PostViewer.cs" company="Drastic Actions">
// Copyright (c) Drastic Actions. All rights reserved.
// </copyright>

namespace FishyFlip.Models;

/// <summary>
/// Metadata about the requesting account's relationship with the subject content. Only has meaningful content for authed requests.
/// </summary>
public record PostViewer(
bool ThreadMuted,
bool ReplyDisabled,
bool EmbeddingDisabled,
bool Pinned,
ATUri? Like,
ATUri? Repost);
9 changes: 8 additions & 1 deletion src/FishyFlip/Models/ThreadView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,24 @@ public class ThreadView : ATRecord
/// <summary>
/// Initializes a new instance of the <see cref="ThreadView"/> class.
/// </summary>
/// <param name="parent">The parent of the post.</param>
/// <param name="post">The main post of the thread.</param>
/// <param name="replies">The replies to the main post.</param>
/// <param name="type">The type of the thread.</param>
[JsonConstructor]
public ThreadView(PostView? post, ThreadView[] replies, string type)
public ThreadView(ThreadView? parent, PostView? post, ThreadView[] replies, string type)
{
this.Parent = parent;
this.Post = post;
this.Replies = replies;
this.Type = type;
}

/// <summary>
/// Gets the parent of the thread.
/// </summary>
public ThreadView? Parent { get; }

/// <summary>
/// Gets the main post of the thread.
/// </summary>
Expand Down
1 change: 1 addition & 0 deletions src/FishyFlip/SourceGenerationContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ namespace FishyFlip;
[JsonSerializable(typeof(ATWebSocketRecord))]
[JsonSerializable(typeof(ActorRecord))]
[JsonSerializable(typeof(ActorIdentity))]
[JsonSerializable(typeof(PostViewer))]
[JsonSerializable(typeof(Microsoft.IdentityModel.Tokens.JsonWebKey), TypeInfoPropertyName = nameof(Microsoft.IdentityModel.Tokens.JsonWebKey) + "_A")]
internal partial class SourceGenerationContext : JsonSerializerContext
{
Expand Down
Loading