diff --git a/src/HTTP/JS/BlueskyAPI.js b/src/HTTP/JS/BlueskyAPI.js index a9c4e60..dae55a9 100644 --- a/src/HTTP/JS/BlueskyAPI.js +++ b/src/HTTP/JS/BlueskyAPI.js @@ -100,6 +100,23 @@ export async function GetPosts(URIs) { return body; } +export async function GetPostThread(URI) { + if (Token == null) { + return ""; + } + let FetchThing = localStorage.getItem(Variables.BlueskyPDS) + "/xrpc/app.bsky.feed.getPostThread?uri=" + URI; + let DPoP = await ClientDPoPPDS("GET", FetchThing); + let request = fetch(FetchThing, { method: "GET", headers: {"Authorization": "DPoP " + Token, "DPoP": DPoP}}); + let body = await request.then((response) => response.json()); + let status = await request.then((response) => response.status); + let header = await request.then((response) => response.headers.get("dpop-nonce")); + if (status == 401) { + await HandleError(body, header); + body = await GetPostThread(URI); + } + return body; +} + // Get a blob (like an image or video). Authentication need not apply. export async function GetBlob(DID, CID) { let request = fetch("https://bsky.social/xrpc/com.atproto.sync.getBlob?did=" + DID + "&cid=" + CID, {method: "GET"}); diff --git a/src/HTTP/JS/expanded.js b/src/HTTP/JS/expanded.js index 4159e0f..d560879 100644 --- a/src/HTTP/JS/expanded.js +++ b/src/HTTP/JS/expanded.js @@ -182,6 +182,21 @@ async function GetPost() { } NumberOfThreads += 1; } + // Replies, anyone? + let Context = await BlueskyAPI.GetPostThread(post.record.uri); + console.log(Context); + for (let i of Context.descendants) { + TemporaryPost = await BlueskyReplyFunction(NumberOfThreads, i); + ThreadedPost.push(TemporaryPost); + // Any posts? Give them the thing :3 + for (let j of document.getElementsByClassName(NumberOfThreads)) { + let TempID = NumberOfThreads; + j.onclick = (event) => { + SetThreadPost(ThreadedPost[TempID], j); + } + } + NumberOfThreads += 1; + } } else { document.getElementsByClassName("PostText")[0].innerHTML = "Nothing to load."; }