From 88f58a5474384d92913e6bcab0caccf2b5f2871f Mon Sep 17 00:00:00 2001 From: Yay295 Date: Thu, 14 Nov 2024 23:48:46 -0600 Subject: [PATCH] handle bluesky "handle" that is a "did" --- lib/philomena_proxy/scrapers/bluesky.ex | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/philomena_proxy/scrapers/bluesky.ex b/lib/philomena_proxy/scrapers/bluesky.ex index 598d1470..4f52a9cc 100644 --- a/lib/philomena_proxy/scrapers/bluesky.ex +++ b/lib/philomena_proxy/scrapers/bluesky.ex @@ -19,10 +19,15 @@ defmodule PhilomenaProxy.Scrapers.Bluesky do def scrape(_uri, url) do [handle, id] = Regex.run(@url_regex, url, capture: :all_but_first) - api_url_resolve_handle = - "https://public.api.bsky.app/xrpc/com.atproto.identity.resolveHandle?handle=#{handle}" + did = + if String.starts_with?(handle, "did:") do + handle + else + api_url_resolve_handle = + "https://public.api.bsky.app/xrpc/com.atproto.identity.resolveHandle?handle=#{handle}" - did = PhilomenaProxy.Http.get(api_url_resolve_handle) |> json!() |> Map.fetch!(:did) + PhilomenaProxy.Http.get(api_url_resolve_handle) |> json!() |> Map.fetch!(:did) + end api_url_get_posts = "https://public.api.bsky.app/xrpc/app.bsky.feed.getPosts?uris=at://#{did}/app.bsky.feed.post/#{id}"