You can now view an author's feed

This commit is contained in:
CatAClock 2025-06-01 17:21:28 -07:00
parent 54658b53ce
commit ce844825a3
3 changed files with 36 additions and 3 deletions

View file

@ -27,9 +27,7 @@
<img class="AccountImage"/>
<p class="AccountDescription"></p>
<hr/>
<div class="Posts">
<p>Not implemented. Posts should populate here.</p>
</div>
<div class="Posts"></div>
</div>
<footer>
<p class="Button" onclick="history.back();"><b>Back</b></p>

View file

@ -65,6 +65,23 @@ export async function GetProfile(DID) {
return body;
}
export async function GetProfileFeed(DID) {
if (Token == null) {
return "";
}
let FetchThing = localStorage.getItem(Variables.BlueskyPDS) + "/xrpc/app.bsky.feed.getAuthorFeed?actor=" + DID;
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 GetProfileFeed(DID);
}
return body;
}
// This gets the post. If there are multiple URIs, they must be within an array.
export async function GetPosts(URIs) {
if (Token == null) {

View file

@ -10,12 +10,16 @@ let post = JSON.parse(localStorage.getItem("post"));
let AccountName = document.getElementsByClassName("Account")[0];
let AccountImage = document.getElementsByClassName("AccountImage")[0];
let AccountDescription = document.getElementsByClassName("AccountDescription")[0];
let AlternateAccountName = document.getElementsByClassName("Account")[1];
let AlternateAccountImage = document.getElementsByClassName("AccountImage")[1];
let AlternateAccountDescription = document.getElementsByClassName("AccountDescription")[1];
let FollowButton = document.getElementsByClassName("Follow")[0];
let BlockButton = document.getElementsByClassName("Block")[0];
let AccountPosts = document.getElementsByClassName("Posts")[0];
// Other vars.
let Following = false;
let Blocking = false;
@ -96,6 +100,14 @@ async function GetAccount() {
}
Field += "</div>";
AccountDescription.innerHTML += Field;
// Get their recent posts. Determine if they are cewl or not.
let Posts = await MastodonAPI.GetAccountStatuses(post.account.id);
for (let i of Posts) {
if (i.reblog != null) {
i = i.reblog;
}
AccountPosts.innerHTML += i.content + "<br/><br/>";
}
} else if (website == "Bluesky") {
// Set the relationship follows
let thing = await BlueskyAPI.GetRecord(localStorage.getItem(Variables.BlueskyDID), "app.bsky.graph.follow", post.post.author.did);
@ -116,6 +128,12 @@ async function GetAccount() {
AccountName.innerHTML = account.handle;
AccountDescription.innerHTML = account.description;
AccountImage.setAttribute("src", account.avatar);
// Get their recent posts. Determine if they are cewl or not.
let Posts = await BlueskyAPI.GetProfileFeed(account.did);
console.log(Posts);
for (let i of Posts.feed) {
AccountPosts.innerHTML += i.post.record.text + "<br/><br/>";
}
} else {
FollowButton.setAttribute("hidden", "");
BlockButton.setAttribute("hidden", "");