-
Notifications
You must be signed in to change notification settings - Fork 11
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
Doc request: How do we fetch profile and post information based #9
Comments
@csharpfritz I apologize for the late response! I've been on vacation, so I haven't checked my messages. I started a sample project to start writing out code to show it, which could eventually be used as a base for written docs. 92907ab#diff-fa9122cadd2ea8808f8746b016ecae8d70017a741e84f920a5de5f46d08e7a0a Getting an actors information can depend on if you're logged in or not. Assuming that you are unauthed, most of your requests are made from the "Repo" class. var handle = "drasticactions.dev";
// Resolve the handle to the ATProtocol DID.
var profile = (await protocol.Identity.ResolveHandleAsync(ATHandle.Create(handle)!)).HandleResult();
// Based on the did, get the full actor record. This contains their profile information, including avatar images.
ActorRecord actorRecord = (await protocol.Repo.GetActorAsync(profile?.Did)).HandleResult();
// The avatar is contained in actorRecord.Value.Avatar, but it's a CID object, pointing to the Avatar blob.
// We can get that through the "Sync" classes GetBlobAsync. We pass in the Actors DID and the Avatars CID link.
// this will return a blob, which contains a JPEG byte array.
Blob avatar = (await protocol.Sync.GetBlobAsync(actorRecord.Uri.Did, actorRecord.Value.Avatar.Ref.Link)).HandleResult();
// You can also request the image directly from your instance by crafting the URL request directly, this will return the direct object. So with this, you can bind it as an image binary array and not need to handle it through FishyFlip itself.
var imageUri = $"https://{protocol.Options.Url.Host}{Constants.Urls.ATProtoSync.GetBlob}?did={actorRecord.Uri.Did!}&cid={actorRecord.Value.Avatar.Ref.Link}"; |
For getting the post url from the Firehost, you can reconstruct it. I've updated the C# sample to show how, but there could be other ways I don't see. I think this is right though, based on what's there. There could be more helper method I could make for it to be easier. if (message.Record is Post post)
{
// The Actor Did.
var did = message.Commit.Repo;
// Commit.Ops are the actions used when creating the message.
// In this case, it's a create record for the post.
// The path contains the post action and path, we need the path, so we split to get it.
var url = $"https://bsky.app/profile/{did}/post/{message.Commit.Ops![0]!.Path!.Split("/").Last()}";
Console.WriteLine($"Post URL: {url}");
} That should get you a full bsky.app URL. |
This worked great for me in TagzApp... but I am still looking for a way to capture the screen name of the Actor who posted the message. I can get their DisplayName, but I'd also like to fetch their screen name like "@csharpfritz.com" in my case |
Thanks @drasticactions ! I'll give that a try. |
For TagzApp we're attempting to use FishyFlip to read messages from the firehose and assemble a TagzApp content record based on the Bluesky message.
We're having a hard time identifying the following data points:
I'd like to help contribute some docs back to Fishyflip that shows how to extract this information in the firehose sample
I have an integration in process, and need these last few data points to complete it: FritzAndFriends/TagzApp#350
The text was updated successfully, but these errors were encountered: