framework for bsky, bug fix

This commit is contained in:
CatAClock 2025-05-24 15:10:33 -07:00
parent 68560fc6ed
commit 54e5c9017b
3 changed files with 55 additions and 1 deletions

View file

@ -234,6 +234,46 @@ export async function CreateLike(DID, RefURI, RefCID) {
return body;
}
export async function CreateFollow(DID, SubjectDID) {
if (localStorage.getItem(Variables.BlueskyAccessToken) == null) {
console.log("No access token!");
return "";
}
let Record = {
"$type": "app.bsky.graph.follow",
"subject": SubjectDID,
"createdAt": new Date(Date.now()).toISOString()
}
let body = await GetRecord(DID, "app.bsky.graph.follow", SubjectDID);
// We might have a record. If we do, delete the thing. If we don't, create the thing.
if (body.hasOwnProperty("error") && body.error == "RecordNotFound") {
body = await CreateRecord(DID, "app.bsky.graph.follow", Record, SubjectDID);
} else {
body = await DeleteRecord(DID, "app.bsky.graph.follow", SubjectDID);
}
return body;
}
export async function CreateBlock(DID, SubjectDID) {
if (localStorage.getItem(Variables.BlueskyAccessToken) == null) {
console.log("No access token!");
return "";
}
let Record = {
"$type": "app.bsky.graph.block",
"subject": SubjectDID,
"createdAt": new Date(Date.now()).toISOString()
}
let body = await GetRecord(DID, "app.bsky.graph.block", SubjectDID);
// We might have a record. If we do, delete the thing. If we don't, create the thing.
if (body.hasOwnProperty("error") && body.error == "RecordNotFound") {
body = await CreateRecord(DID, "app.bsky.graph.block", Record, SubjectDID);
} else {
body = await DeleteRecord(DID, "app.bsky.graph.block", SubjectDID);
}
return body;
}
// Create a repost and send it to the server.
export async function CreateRepost(DID, RefURI, RefCID) {
if (localStorage.getItem(Variables.BlueskyAccessToken) == null) {

View file

@ -79,10 +79,24 @@ async function GetAccount() {
AccountName.innerHTML = post.reblog.account.username;
AccountDescription.innerHTML = post.reblog.account.note;
AccountImage.setAttribute("src", post.reblog.account.avatar);
// Build the fields
let Field = "<div style=\"display: flex; justify-content: center;\">";
for (let i of post.reblog.account.fields) {
Field += "<b>" + i.name + "</b><em>" + i.value + "</em>";
}
Field += "</div>";
AccountDescription.innerHTML += Field;
} else {
AccountName.innerHTML = post.account.username;
AccountDescription.innerHTML = post.account.note;
AccountImage.setAttribute("src", post.account.avatar);
// Build the fields
let Field = "<div style=\"display: flex; justify-content: center;\">";
for (let i of post.account.fields) {
Field += "<b>" + i.name + "</b><em>" + i.value + "</em>";
}
Field += "</div>";
AccountDescription.innerHTML += Field;
}
} else if (website == "Bluesky") {

View file

@ -226,7 +226,7 @@ async function PosterContainerUpdate(Direction) {
if (MastodonLoadedFeed[CurrentThing + counter].reblog.media_attachments.length != 0) {
if (MastodonLoadedFeed[CurrentThing + counter].reblog.media_attachments[0].type == "image") {
i.getElementsByClassName("PostContent")[0].innerHTML += "This post has an image!<br/>";
} else if (MastodonLoadedFeed[CurrentThing + counter].reblog.media_attachments[0].type == "video" || MastodonLoadedFeed[CurrentThing + counter].media_attachments[0].type == "gifv") {
} else if (MastodonLoadedFeed[CurrentThing + counter].reblog.media_attachments[0].type == "video" || MastodonLoadedFeed[CurrentThing + counter].reblog.media_attachments[0].type == "gifv") {
i.getElementsByClassName("PostContent")[0].innerHTML += "This post has a video!<br/>";
}
}