accounts are now viewable
This commit is contained in:
parent
54e5c9017b
commit
cff163f6d0
2 changed files with 41 additions and 5 deletions
|
@ -54,6 +54,24 @@ export async function GetPublicTimeline(Cursor) {
|
|||
return body;
|
||||
}
|
||||
|
||||
export async function GetProfile(DID) {
|
||||
if (localStorage.getItem(Variables.BlueskyAccessToken) == null) {
|
||||
console.log("No access token!");
|
||||
return "";
|
||||
}
|
||||
|
||||
let DPoP = await ClientDPoPPDS("GET", localStorage.getItem(Variables.BlueskyPDS) + "/xrpc/app.bsky.actor.getProfile?actor=" + DID);
|
||||
let request = fetch(localStorage.getItem(Variables.BlueskyPDS) + "/xrpc/app.bsky.actor.getProfile?actor=" + DID, { method: "GET", headers: {"Authorization": "DPoP " + localStorage.getItem(Variables.BlueskyAccessToken), "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 GetProfile(DID);
|
||||
}
|
||||
return body;
|
||||
}
|
||||
|
||||
// This gets the post. If there are multiple URIs, they must be within an array.
|
||||
export async function GetPosts(URIs) {
|
||||
if (localStorage.getItem(Variables.BlueskyAccessToken) == null) {
|
||||
|
|
|
@ -27,10 +27,10 @@ async function FollowBoop() {
|
|||
if (website == "Mastodon") {
|
||||
let Relations = await MastodonAPI.GetRelationship(post.account.id);
|
||||
await MastodonAPI.CreateFollow(post.account.id, Relations[0].following);
|
||||
SetFollow();
|
||||
} else if (website == "Bluesky") {
|
||||
|
||||
await BlueskyAPI.CreateFollow(localStorage.getItem(Variables.BlueskyDID), post.post.author.did);
|
||||
}
|
||||
SetFollow();
|
||||
}
|
||||
|
||||
function SetFollow() {
|
||||
|
@ -50,10 +50,10 @@ async function BlockBoop() {
|
|||
if (website == "Mastodon") {
|
||||
let Relations = await MastodonAPI.GetRelationship(post.account.id);
|
||||
await MastodonAPI.CreateBlock(post.account.id, Relations[0].blocking);
|
||||
SetBlock();
|
||||
} else if (website == "Bluesky") {
|
||||
|
||||
await BlueskyAPI.CreateBlock(localStorage.getItem(Variables.BlueskyDID), post.post.author.did);
|
||||
}
|
||||
SetBlock();
|
||||
}
|
||||
|
||||
function SetBlock() {
|
||||
|
@ -99,6 +99,24 @@ async function GetAccount() {
|
|||
AccountDescription.innerHTML += Field;
|
||||
}
|
||||
} 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);
|
||||
let thing2 = await BlueskyAPI.GetRecord(localStorage.getItem(Variables.BlueskyDID), "app.bsky.graph.block", post.post.author.did);
|
||||
if (thing.hasOwnProperty("error") && thing.error == "RecordNotFound") {
|
||||
Following = true;
|
||||
} else {
|
||||
Following = false;
|
||||
}
|
||||
if (thing2.hasOwnProperty("error") && thing2.error == "RecordNotFound") {
|
||||
Blocking = true;
|
||||
} else {
|
||||
Blocking = false;
|
||||
}
|
||||
SetFollow();
|
||||
SetBlock();
|
||||
let account = await BlueskyAPI.GetProfile(post.post.author.did);
|
||||
AccountName.innerHTML = account.handle;
|
||||
AccountDescription.innerHTML = account.description;
|
||||
AccountImage.setAttribute("src", account.avatar);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue