diff --git a/src/HTTP/JS/BlueskyAPI.js b/src/HTTP/JS/BlueskyAPI.js index 003ab27..ae8d8c8 100644 --- a/src/HTTP/JS/BlueskyAPI.js +++ b/src/HTTP/JS/BlueskyAPI.js @@ -167,7 +167,7 @@ export async function GetRecord(Repo, Collection, RKey) { // Creators // This creates a post. Requires the DID of the account and the Text for the record. -export async function CreatePost(DID, Text, ContentWarning = undefined, Tags = [], ReplyID = undefined, RootID = undefined) { +export async function CreatePost(DID, Text, ContentWarning = undefined, Tags = [], ReplyID = undefined, RootID = undefined, AddTags = false) { if (Token == null) { return ""; } @@ -202,6 +202,23 @@ export async function CreatePost(DID, Text, ContentWarning = undefined, Tags = [ if (Tags.length != 0) { Record.tags = Tags; } + if (AddTags == true) { + let Facets = []; + for (let i of Tags) { + let ThineIndex = tags.indexOf(i); + Facets.push({ + "index": { + "byteStart": ThineIndex, + "byteEnd": ThineIndex + i.length + }, + "features": { + "$type": "app.bsky.richtext.facet#tag", + "tag": i; + } + }); + } + Record.facets = Facets; + } let body = await CreateRecord(DID, "app.bsky.feed.post", Record, undefined); if (body.hasOwnProperty("error") && body.error == "InvalidRequest") { let matches = body.message.match(/(\d+)/); diff --git a/src/HTTP/JS/post.js b/src/HTTP/JS/post.js index c760c5f..f042b70 100644 --- a/src/HTTP/JS/post.js +++ b/src/HTTP/JS/post.js @@ -140,6 +140,14 @@ async function Post() { } await BlueskyAPI.CreateThreadGate(localStorage.getItem(Variables.BlueskyDID), Post.uri, TempVisible); } + // Try to apply tags as well in another post because Bsky sucks balls. + if (Tags != "") { + let Textures = ""; + for (let i of Tags) { + Textures = Textures + i + " "; + } + Post = await BlueskyAPI.CreatePost(localStorage.getItem(Variables.BlueskyDID), Textures, undefined, [], Post.post, Post.reply.root, true); + } } // Youtube posting. if (YoutubePoser.checked == true) {