Skip to content

Commit

Permalink
Add missing fields to ThreadView/PostView (#69)
Browse files Browse the repository at this point in the history
* Add Parent to ThreadView

* Add PostViewer
  • Loading branch information
drasticactions committed Nov 4, 2024
1 parent 81ebb9f commit 0f43355
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 2 deletions.
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

0 comments on commit 0f43355

Please sign in to comment.