Skip to content

Commit

Permalink
Add GetListFeed
Browse files Browse the repository at this point in the history
  • Loading branch information
drasticactions committed Jan 15, 2024
1 parent 358fe4e commit c92b761
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ As a general rule of thumb, `com.atproto` endpoints (such as `com.atproto.sync`)
| [app.bsky.feed.getPosts](https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/feed/getPosts.json) ||
| [app.bsky.feed.getFeed](https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/feed/getFeed.json) ||
| [app.bsky.feed.getFeedSkeleton](https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/feed/getFeedSkeleton.json) ||
| [app.bsky.feed.getListFeed](https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/feed/getListFeed.json) | |
| [app.bsky.feed.getListFeed](https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/feed/getListFeed.json) | |
| [app.bsky.feed.getSuggestedFeeds](https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/feed/getSuggestedFeeds.json) ||
| [app.bsky.feed.getActorFeeds](https://github.com/bluesky-social/atproto/blob/main/lexicons/app/bsky/feed/getActorFeeds.json) ||

Expand Down
14 changes: 14 additions & 0 deletions samples/FishyFlipSamplesApp/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ async Task GetListViaATUri(ATProtocol protocol)
defaultValue: "at://did:plc:yhgc5rlqhoezrx6fbawajxlh/app.bsky.graph.list/3kiwyqwydde2x",
validators: new[] { Validators.Required() });
var lists = (await protocol.Graph.GetListAsync(ATUri.Create(uri))).HandleResult();
var feed = (await protocol.Feed.GetListFeedAsync(ATUri.Create(uri))).HandleResult();
if (lists is null)
{
Console.WriteLine("No lists found.");
Expand All @@ -185,6 +186,19 @@ async Task GetListViaATUri(ATProtocol protocol)
Console.WriteLine(item.Subject.Handle);
Console.WriteLine("-----");
}

if (feed is null)
{
Console.WriteLine("No feed found.");
return;
}

foreach (var item in feed.Feed)
{
Console.WriteLine(item.Post.Author);
Console.WriteLine(item.Post.IndexedAt);
Console.WriteLine("-----");
}
}

async Task GetListsViaATIdent(ATProtocol protocol)
Expand Down
11 changes: 11 additions & 0 deletions src/FishyFlip/BlueskyFeed.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,17 @@ public async Task<Result<LikesFeed>> GetLikesAsync(ATUri uri, int limit = 50, Ci
error => error!);
}

public async Task<Result<ListFeed>> GetListFeedAsync(ATUri uri, int limit = 30, CancellationToken cancellationToken = default)
{
string url = $"{Constants.Urls.Bluesky.Feed.GetListFeed}?list={uri.ToString()}&limit={limit}";

Multiple<ListFeed?, Error> result = await this.Client.Get<ListFeed>(url, this.Options.JsonSerializerOptions, cancellationToken, this.Options.Logger);
return result
.Match<Result<ListFeed>>(
timeline => (timeline ?? new ListFeed(Array.Empty<FeedViewPost>(), null))!,
error => error!);
}

public async Task<Result<Timeline>> GetAuthorFeedAsync(ATIdentifier handle, int limit = 50, string? cursor = default, CancellationToken cancellationToken = default)
{
string url = $"{Constants.Urls.Bluesky.Feed.GetAuthorFeed}?actor={handle.ToString()}&limit={limit}";
Expand Down
1 change: 1 addition & 0 deletions src/FishyFlip/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ public static class Feed
public const string GetFeedGenerator = "/xrpc/app.bsky.feed.getFeedGenerator";
public const string GetFeedGenerators = "/xrpc/app.bsky.feed.getFeedGenerators";
public const string GetFeed = "/xrpc/app.bsky.feed.getFeed";
public const string GetListFeed = "/xrpc/app.bsky.feed.getListFeed";
public const string GetPosts = "/xrpc/app.bsky.feed.getPosts";
public const string GetLikes = "/xrpc/app.bsky.feed.getLikes";
public const string GetRepostedBy = "/xrpc/app.bsky.feed.getRepostedBy";
Expand Down
7 changes: 7 additions & 0 deletions src/FishyFlip/Models/ListFeed.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// <copyright file="ListFeed.cs" company="Drastic Actions">
// Copyright (c) Drastic Actions. All rights reserved.
// </copyright>

namespace FishyFlip.Models;

public record ListFeed(FeedViewPost[] Feed, string? Cursor);

0 comments on commit c92b761

Please sign in to comment.