facets initialized
This commit is contained in:
parent
f67ecccc7d
commit
3b6145c621
2 changed files with 26 additions and 1 deletions
|
@ -167,7 +167,7 @@ export async function GetRecord(Repo, Collection, RKey) {
|
||||||
|
|
||||||
// Creators
|
// Creators
|
||||||
// This creates a post. Requires the DID of the account and the Text for the record.
|
// 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) {
|
if (Token == null) {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
@ -202,6 +202,23 @@ export async function CreatePost(DID, Text, ContentWarning = undefined, Tags = [
|
||||||
if (Tags.length != 0) {
|
if (Tags.length != 0) {
|
||||||
Record.tags = Tags;
|
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);
|
let body = await CreateRecord(DID, "app.bsky.feed.post", Record, undefined);
|
||||||
if (body.hasOwnProperty("error") && body.error == "InvalidRequest") {
|
if (body.hasOwnProperty("error") && body.error == "InvalidRequest") {
|
||||||
let matches = body.message.match(/(\d+)/);
|
let matches = body.message.match(/(\d+)/);
|
||||||
|
|
|
@ -140,6 +140,14 @@ async function Post() {
|
||||||
}
|
}
|
||||||
await BlueskyAPI.CreateThreadGate(localStorage.getItem(Variables.BlueskyDID), Post.uri, TempVisible);
|
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.
|
// Youtube posting.
|
||||||
if (YoutubePoser.checked == true) {
|
if (YoutubePoser.checked == true) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue