Skip to content

Commit a1bc31a

Browse files
committed
Add status record and status view
1 parent 9035a80 commit a1bc31a

File tree

8 files changed

+66
-19
lines changed

8 files changed

+66
-19
lines changed

readme.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,6 @@ The [releases page](https://github.com/blowdart/idunno.Bluesky/releases) provide
5353
* Wider test coverage
5454
* More deserialization tests with captured responses
5555

56-
### Minor
57-
58-
* [Live support](https://github.com/bluesky-social/atproto/pull/3824)
59-
6056
### Awaiting external
6157

6258
* Automatic Open Graph card generation when link facets detected.

samples/Samples.DirectMessages/Program.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,13 @@
88

99
using Microsoft.Extensions.Logging;
1010

11+
using idunno.AtProto;
1112
using idunno.Bluesky;
1213
using idunno.Bluesky.Actor;
13-
using idunno.AtProto;
1414
using idunno.Bluesky.Chat;
15+
using idunno.Bluesky.Embed;
1516

1617
using Samples.Common;
17-
using idunno.Bluesky.Embed;
18-
using System.Net.Http.Headers;
1918

2019
namespace Samples.DirectMessages
2120
{

src/idunno.Bluesky/Actor/ProfileViewBasic.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,11 @@ public ProfileViewBasic(
130130
/// </summary>
131131
public VerificationState? Verification { get; init; }
132132

133+
/// <summary>
134+
/// Gets the <see cref="StatusView" /> of the actor, if any.
135+
/// </summary>
136+
public StatusView? Status { get; init; }
137+
133138
/// <summary>
134139
/// Gets a string representation of the <see cref="ProfileView"/>.
135140
/// This returns the actor's display name, if any, otherwise returns the actor's handle.
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// Copyright (c) Barry Dorrans. All rights reserved.
2+
// Licensed under the MIT License.
3+
4+
using System.Text.Json.Nodes;
5+
6+
using idunno.Bluesky.Embed;
7+
8+
namespace idunno.Bluesky.Actor
9+
{
10+
/// <summary>
11+
/// Provides a view over an actor's current status
12+
/// </summary>
13+
/// <param name="Status">The status for the account.</param>
14+
/// <param name="Record">A record associated with the status</param>
15+
/// <param name="Embed">An optional <see cref="EmbeddedView"/> associated with the status.</param>
16+
/// <param name="ExpiresAt">An optional <see cref="DateTimeOffset" /> when this status will expire</param>
17+
/// <param name="IsActive">Gets a flag indicating if the status is not expired. Only present <paramref name="ExpiresAt"/> was set.</param>
18+
public sealed record StatusView(string Status, JsonNode Record, EmbeddedView? Embed, DateTimeOffset? ExpiresAt, bool? IsActive)
19+
{
20+
}
21+
}

src/idunno.Bluesky/Constants.cs

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -138,58 +138,62 @@ public static class CollectionNsid
138138
/// <summary>
139139
/// The NSID for a user's post collection.
140140
/// </summary>
141-
public static Nsid Post { get; } = new Nsid("app.bsky.feed.post");
141+
public static Nsid Post => new("app.bsky.feed.post");
142142

143143
/// <summary>
144144
/// The NSID for a user's likes collection.
145145
/// </summary>
146-
public static Nsid Like { get; } = new Nsid("app.bsky.feed.like");
146+
public static Nsid Like => new("app.bsky.feed.like");
147147

148148
/// <summary>
149149
/// The NSID for a user's reposts collection.
150150
/// </summary>
151-
public static Nsid Repost { get; } = new Nsid("app.bsky.feed.repost");
151+
public static Nsid Repost => new("app.bsky.feed.repost");
152152

153153
/// <summary>
154154
/// The NSID for a user's follows collection.
155155
/// </summary>
156-
public static Nsid Follow { get; } = new Nsid("app.bsky.graph.follow");
156+
public static Nsid Follow => new("app.bsky.graph.follow");
157157

158158
/// <summary>
159159
/// The NSID for a user's block collection.
160160
/// </summary>
161-
public static Nsid Block { get; } = new Nsid("app.bsky.graph.block");
161+
public static Nsid Block => new("app.bsky.graph.block");
162162

163163
/// <summary>
164164
/// The NSID for a user's thread gates collection.
165165
/// </summary>
166-
public static Nsid ThreadGate { get; } = new Nsid("app.bsky.feed.threadgate");
166+
public static Nsid ThreadGate => new("app.bsky.feed.threadgate");
167167

168168
/// <summary>
169169
/// The NSID for a user's post gates collection.
170170
/// </summary>
171-
public static Nsid PostGate { get; } = new Nsid("app.bsky.feed.postgate");
171+
public static Nsid PostGate => new("app.bsky.feed.postgate");
172172

173173
/// <summary>
174174
/// The NSID for an actor's profile.
175175
/// </summary>
176-
public static Nsid Profile { get; } = new Nsid("app.bsky.actor.profile");
176+
public static Nsid Profile => new("app.bsky.actor.profile");
177177

178178
/// <summary>
179179
/// The NSID for a user's verification collection.
180180
/// </summary>
181-
public static Nsid Verification { get; } = new Nsid("app.bsky.graph.verification");
181+
public static Nsid Verification => new("app.bsky.graph.verification");
182182

183183
/// <summary>
184184
/// The NSID for a user's list collection.
185185
/// </summary>
186-
public static Nsid List { get; } = new Nsid("app.bsky.graph.list");
186+
public static Nsid List => new("app.bsky.graph.list");
187187

188188
/// <summary>
189189
/// The NSID for the user's collection of users added to their own lists.
190190
/// </summary>
191-
public static Nsid ListItem { get; } = new Nsid("app.bsky.graph.listitem");
191+
public static Nsid ListItem => new("app.bsky.graph.listitem");
192192

193+
/// <summary>
194+
/// The NSID for an actor's status record.
195+
/// </summary>
196+
public static Nsid Status => new("app.bsky.actor.status");
193197
}
194198

195199
/// <summary>
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// Copyright (c) Barry Dorrans. All rights reserved.
2+
// Licensed under the MIT License.
3+
4+
using System.Text.Json.Serialization;
5+
using idunno.Bluesky.Embed;
6+
7+
namespace idunno.Bluesky.Record
8+
{
9+
/// <summary>
10+
/// Creates a new instance of <see cref="Status"/>.
11+
/// </summary>
12+
/// <param name="AccountStatus">The status for the account.</param>
13+
/// <param name="Embed">An optional embed associated with the status.</param>
14+
/// <param name="DurationMinutes">"The duration of the status in minutes. Applications can choose to impose minimum and maximum limits.</param>
15+
public record Status(
16+
[property: JsonPropertyName("status")] string AccountStatus,
17+
EmbeddedBase? Embed,
18+
int? DurationMinutes) : BlueskyRecord
19+
{
20+
}
21+
}

src/idunno.Bluesky/SourceGenerationContext.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ namespace idunno.Bluesky
7373
[JsonSerializable(typeof(ThreadViewPreference))]
7474
[JsonSerializable(typeof(VerificationState))]
7575
[JsonSerializable(typeof(VerificationView))]
76+
[JsonSerializable(typeof(StatusView))]
7677

7778
[JsonSerializable(typeof(BeginConversation))]
7879
[JsonSerializable(typeof(CreateMessage))]

version.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"$schema": "https://raw.githubusercontent.com/AArnott/Nerdbank.GitVersioning/master/src/NerdBank.GitVersioning/version.schema.json",
3-
"version": "0.9.4-prerelease",
3+
"version": "0.9.5-prerelease",
44
"publicReleaseRefSpec": [
55
"^refs\/heads\/rel\/.*$"
66
],

0 commit comments

Comments
 (0)