Skip to content

Commit 188617f

Browse files
committed
Fix Merge conflicts
2 parents 36bef53 + b38d099 commit 188617f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+2263
-24
lines changed

.github/workflows/ci-build.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ permissions:
1919
checks: write
2020

2121
env:
22-
DOTNET_NOLOGO: true
2322
DOTNET_GENERATE_ASPNET_CERTIFICATE: false
2423
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
2524

@@ -40,6 +39,10 @@ jobs:
4039

4140
- name: 'Setup .NET SDK'
4241
uses: actions/setup-dotnet@67a3573c9a986a3f9c594539f4ab511d57bb3ce9 # v4.3.1
42+
with:
43+
dotnet-version: |
44+
8.0.x
45+
9.0.x
4346
4447
- name: 'Restore external dependencies'
4548
run: dotnet restore

Directory.Build.props

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919

2020
<PropertyGroup>
2121
<Nullable>enable</Nullable>
22-
<LangVersion>12.0</LangVersion>
2322
<EnableNETAnalyzers>true</EnableNETAnalyzers>
2423
<EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild>
2524
</PropertyGroup>

Directory.Packages.props

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,6 @@
3131
<PackageVersion Include="Duende.IdentityModel.OidcClient.Extensions" Version="6.0.1" />
3232
<PackageVersion Include="Microsoft.AspNetCore.TestHost" Version="8.0.15" />
3333
<PackageVersion Include="Microsoft.AspNetCore.WebUtilities" Version="8.0.15" />
34+
<PackageVersion Include="ZstdSharp.Port" Version="0.8.5" />
3435
</ItemGroup>
35-
</Project>
36+
</Project>

THIRD-PARTY-NOTICES.txt

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -510,3 +510,28 @@ For the avoidance of doubt, this Public License does not, and shall not be inter
510510
To the extent possible, if any provision of this Public License is deemed unenforceable, it shall be automatically reformed to the minimum extent necessary to make it enforceable. If the provision cannot be reformed, it shall be severed from this Public License without affecting the enforceability of the remaining terms and conditions.
511511
No term or condition of this Public License will be waived and no failure to comply consented to unless expressly agreed to by the Licensor.
512512
Nothing in this Public License constitutes or may be interpreted as a limitation upon, or waiver of, any privileges and immunities that apply to the Licensor or You, including from the legal processes of any jurisdiction or authority.
513+
514+
License notice for ZstdSharp
515+
----------------------------
516+
517+
MIT License
518+
519+
Copyright (c) 2021 Oleg Stepanischev
520+
521+
Permission is hereby granted, free of charge, to any person obtaining a copy
522+
of this software and associated documentation files (the "Software"), to deal
523+
in the Software without restriction, including without limitation the rights
524+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
525+
copies of the Software, and to permit persons to whom the Software is
526+
furnished to do so, subject to the following conditions:
527+
528+
The above copyright notice and this permission notice shall be included in all
529+
copies or substantial portions of the Software.
530+
531+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
532+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
533+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
534+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
535+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
536+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
537+
SOFTWARE.

docs/docs/jetstream.md

Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
# Using the JetStream
2+
3+
The [Jetstream](https://github.com/bluesky-social/jetstream) is a streaming service that provides information on activity on the ATProto network.
4+
You can consume the Jetstream using the `AtProtoJetstream` class.
5+
6+
## Jetstream events
7+
8+
`AtProtoJetstream` has three events you can subscribe to:
9+
10+
* `ConnectionStateChanged` - fired when the state of the underlying WebSocket changes, typically on open and close.
11+
* `MessageReceived` - fired when a message has been received from the Jetstream, but has not yet been parsed.
12+
* `RecordReceived` - fired when a message has been parsed into a JetStream event.
13+
14+
There are three types of Jetstream event that are passed to `RecordReceived`:
15+
16+
* `AtJetstreamCommitEvent` - an event raised when a change happens to a record in a repo, creation, deletion or changes. For example a post is created, or a user profile is updated.
17+
* `AtJetstreamAccountEvent` - an event that has happened on an actor's account, activation or deactivation, with an optional status indicating if deactivation was performed by moderation.
18+
* `AtJetstreamIdentityEvent` - an event raised when an actor changes their handle
19+
20+
## Consuming the Jetstream
21+
22+
To connect to the Jetstream create a new instance of `AtProtoJetstream` and subscribe to the events you are interesting in reacting to.
23+
24+
Typical use would be subscribing to the `RecordReceived` event, examining the event arguments and reacting accordingly to the wanted jetstream events.
25+
26+
```c#
27+
using (var jetStream = new AtProtoJetstream())
28+
{
29+
jetStream.RecordReceived += (sender, e) =>
30+
{
31+
string timeStamp = e.ParsedEvent.DateTimeOffset.ToLocalTime().ToString("G", CultureInfo.DefaultThreadCurrentUICulture);
32+
33+
switch (e.ParsedEvent)
34+
{
35+
case AtJetstreamAccountEvent accountEvent:
36+
if (accountEvent.Account.Active)
37+
{
38+
Console.WriteLine($"ACCOUNT: {accountEvent.Did} activated at {timeStamp}");
39+
}
40+
else
41+
{
42+
Console.WriteLine($"ACCOUNT: {accountEvent.Did} deactivated at {timeStamp}");
43+
}
44+
break;
45+
46+
case AtJetstreamCommitEvent commitEvent:
47+
Console.WriteLine($"COMMIT: {commitEvent.Did} executed a {commitEvent.Commit.Operation} in {commitEvent.Commit.Collection} at {timeStamp}");
48+
break;
49+
50+
case AtJetstreamIdentityEvent identityEvent:
51+
Console.WriteLine($"IDENTITY: {identityEvent.Did} changed handle to {identityEvent.Identity.Handle} at {timeStamp}");
52+
break;
53+
54+
default:
55+
break;
56+
}
57+
};
58+
}
59+
```
60+
61+
If you want the raw messages from the jetstream subscribe to the `MessageReceived` event.
62+
63+
> [!WARNING]
64+
> The Jetstream covers all ATProto events. The Commit events cover not only Bluesky record commits but any commits from a registered PDS, such as [WhiteWind](https://whtwnd.com)
65+
> blog records or [Tangled](https://blog.tangled.sh/intro) collaboration messages. This is why the `Record` property in `AtJetstreamCommit` is presented as a `JsonDocument`.
66+
> When deserializing this property to, for example, a `BlueskyRecord` you will encounter exceptions if you attempt it on a non-Bluesky defined record
67+
68+
Once you have a configured instance of `AtProtoJetstream` call `ConnectAsync` and processing will begin in the background, raising events as appropriate.
69+
When you are finished with the jetstream call `CloseAsync`
70+
71+
```c#
72+
await jetStream.ConnectAsync();
73+
74+
await jetStream.CloseAsync();
75+
```
76+
77+
The [Jetstream sample](https://github.com/blowdart/idunno.Bluesky/tree/main/samples/Samples.Jetstream) shows subscribing to both raw messages and events,
78+
writing the raw message and a break down of the event to the console.type.
79+
80+
## Filtering commit events
81+
82+
You can limit the commit events you receive by [DID](commonTerms.md#dids) or [Collection](commonTerms.md#records). You can configure the filters
83+
when creating of `AtProtoJetstream`:
84+
85+
```c#
86+
using (var jetStream = new AtProtoJetstream(
87+
collections: ["app.bsky.feed.post"],
88+
dids: ["did:plc:ec72yg6n2sydzjvtovvdlxrk"])
89+
{
90+
}
91+
```
92+
93+
You can also change the `CollectionFilter` and `DidFilter` properties on a running instance.
94+
95+
## Configuring AtProtoJetstream
96+
97+
`AtProtoJetstream` has two configuration options, `options` and `webSocketOptions`.
98+
99+
The `options` parameter on the constructor allows you to configure
100+
101+
* `LoggerFactory` - The `ILoggerFactory` to use for logging
102+
* `UseCompression` - a flag indication whether compression should be used. This defaults to `true`.
103+
* `Dictionary` - the zst compression/decompression dictionary to use if compression is enabled. This defaults to a generated dictionary specific to the jetstream.
104+
* `TaskFactory` - the `TaskFactory` to use when creating new tasks. This allows you to configure `TaskScheduler` settings if needed.
105+
* `MaximumMessageSize` - the maximum size of messages you are willing to accept, in bytes. This defaults to 8096.
106+
107+
The `webSocketOptions` parameter allows you to configure the underlying web socket client,
108+
109+
* `Proxy` - A proxy to use, if supplied.
110+
* `KeepAliveInterval` - Sets the keep alive interval.
111+
112+
The following code snippet demonstrates setting a `LoggerFactory` and a `Proxy`
113+
114+
```c#
115+
using (var jetStream = new AtProtoJetstream(
116+
options: new JetstreamOptions()
117+
{
118+
LoggerFactory = loggerFactory
119+
},
120+
webSocketOptions: new WebSocketOptions()
121+
{
122+
Proxy = new WebProxy(new Uri("http://localhost:8866"))
123+
}))
124+
{
125+
}
126+
```

docs/docs/posting.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ if (postResult.Succeeded)
1616
```
1717

1818
The result from creating a post contains. amongst other things, a strong reference to the new record. This `StrongReference` consists of an
19-
[at:// uri](../commonTerms.md#uri) and a Content Identifier ([CID](https://github.com/multiformats/cid)).
19+
[at:// uri](commonTerms.md#uri) and a Content Identifier ([CID](https://github.com/multiformats/cid)).
2020

2121
An AT URI is a way to reference individual records in a specific repository (every Bluesky user has their own repository).
2222

docs/docs/timeline.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ When browsing timelines and feeds you will need to understand how AtProto implem
5151

5252
A timeline is a well known feed. A feed is a view created by a feed generator over collections of posts, the criteria for which the feed controls.
5353

54-
A feed is referenced by its [at:// uri](../commonTerms.md#uri), loaded with `GetFeed()` rather than `GetTimeLine()` and then paginated in exactly the same way.
54+
A feed is referenced by its [at:// uri](commonTerms.md#uri), loaded with `GetFeed()` rather than `GetTimeLine()` and then paginated in exactly the same way.
5555
5656
```c#
5757
AtUri feedUri = new("at://did:plc:z72i7hdynmk6r22z27h6tvur/app.bsky.feed.generator/whats-hot");

docs/docs/toc.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,12 @@ items:
4444
items:
4545
- name: Labels
4646
href: labels.md
47-
- name: Saving & restoring authentication state
48-
href: savingAndRestoringAuthentication.md
47+
- name: Using the Jetstream
48+
href: jetstream.md
4949
- name: Configuring logging
5050
href: logging.md
51+
- name: Saving & restoring authentication state
52+
href: savingAndRestoringAuthentication.md
5153
- name: Json Source Generation and Native AOT
5254
href: sourceGeneration.md
5355

exclusion.dic

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ nsid
1515
nsids
1616
Nsid
1717
Nsids
18+
DIDs
19+
dids
1820
uris
1921
threadgate
2022
postgate
@@ -47,3 +49,4 @@ Pexels
4749
dpop
4850
JsonTypeInfos
4951
csharp
52+
Jetstream

global.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"sdk": {
3+
"version": "9.0.200",
4+
"rollForward": "latestFeature"
5+
}
6+
}

0 commit comments

Comments
 (0)