fuck man tags good enough
This commit is contained in:
parent
62820d4ede
commit
8c386c6701
3 changed files with 40 additions and 12 deletions
|
@ -115,7 +115,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, ReplyID = undefined, RootID = undefined) {
|
||||
export async function CreatePost(DID, Text, ContentWarning = undefined, Tags = [], ReplyID = undefined, RootID = undefined) {
|
||||
if (Token == null) {
|
||||
return "";
|
||||
}
|
||||
|
@ -146,15 +146,19 @@ export async function CreatePost(DID, Text, ContentWarning = undefined, ReplyID
|
|||
}
|
||||
};
|
||||
}
|
||||
// Tags
|
||||
if (Tags.length != 0) {
|
||||
Record.tags = Tags;
|
||||
}
|
||||
let body = await CreateRecord(DID, "app.bsky.feed.post", Record, undefined);
|
||||
if (body.hasOwnProperty("error") && body.error == "InvalidRequest") {
|
||||
let matches = body.message.match(/(\d+)/);
|
||||
Record.text = Text.slice(0, matches[0] - 1);
|
||||
body = await CreateRecord(DID, "app.bsky.feed.post", Record, undefined);
|
||||
if (ReplyID != undefined && RootID != undefined) {
|
||||
await CreatePost(DID, Text.slice(matches[0] - 1, Text.length), ContentWarning, body, body);
|
||||
await CreatePost(DID, Text.slice(matches[0] - 1, Text.length), ContentWarning, Tags, body, body);
|
||||
} else {
|
||||
await CreatePost(DID, Text.slice(matches[0] - 1, Text.length), ContentWarning, body, RootID);
|
||||
await CreatePost(DID, Text.slice(matches[0] - 1, Text.length), ContentWarning, Tags, body, RootID);
|
||||
}
|
||||
}
|
||||
return body;
|
||||
|
|
|
@ -126,7 +126,7 @@ export async function CreateStatus(Text, Visibility = "public", SpoilerText = un
|
|||
request = fetch(enFetchThing, {method: "POST", headers: {"Authorization": TokenType + " " + Token}});
|
||||
body = await request.then((response) => response.json());
|
||||
if (ReplyID != undefined) {
|
||||
await CreateReplyStatus(Text.slice(matches[0] - 1, SpoilerText, Text.length), Visibility, body.id);
|
||||
await CreateReplyStatus(Text.slice(matches[0] - 1, Text.length), Visibility, SpoilerText, body.id);
|
||||
}
|
||||
}
|
||||
return body;
|
||||
|
|
40
JS/post.js
40
JS/post.js
|
@ -33,7 +33,18 @@ async function Post() {
|
|||
// Mastodon posting.
|
||||
if (localStorage.getItem(Variables.MastodonAccessToken) != null) {
|
||||
let TempVisible;
|
||||
let TempText = Text + "<br/><br/>" + TagsInputArea.value;
|
||||
// Adding tags
|
||||
let TempText = Text + "<br/><br/>";
|
||||
let Tags = TagsInputArea.value.split(";");
|
||||
for (let i of Tags) {
|
||||
while (i[0] == " ") {
|
||||
i = i.substring(1, i.length);
|
||||
}
|
||||
if (i[0] != "#") {
|
||||
i = "#" + i;
|
||||
}
|
||||
TempText += i + " ";
|
||||
}
|
||||
switch(Visible) {
|
||||
case "Public":
|
||||
TempVisible = "public";
|
||||
|
@ -60,7 +71,7 @@ async function Post() {
|
|||
return;
|
||||
} else if (website == "All") {
|
||||
if (WarningInputArea.value == "") {
|
||||
await MastodonAPI.CreateStatus(TempText, TempVisible);
|
||||
await MastodonAPI.CreateStatus(TempText, TempVisible, undefined);
|
||||
} else {
|
||||
await MastodonAPI.CreateStatus(TempText, TempVisible, WarningInputArea.value);
|
||||
}
|
||||
|
@ -69,6 +80,19 @@ async function Post() {
|
|||
// Bluesky posting.
|
||||
if (localStorage.getItem(Variables.BlueskyAccessToken) != null) {
|
||||
let TempVisible;
|
||||
// Adding tags
|
||||
let Tags = TagsInputArea.value.split(";");
|
||||
let TagsTemp = [];
|
||||
for (let i of Tags) {
|
||||
while (i[0] == " ") {
|
||||
i = i.substring(1, i.length);
|
||||
}
|
||||
if (i[0] != "#") {
|
||||
i = "#" + i;
|
||||
}
|
||||
TagsTemp.push(i);
|
||||
}
|
||||
Tags = TagsTemp;
|
||||
switch(Visible) {
|
||||
case "Public":
|
||||
TempVisible = undefined;
|
||||
|
@ -87,16 +111,16 @@ async function Post() {
|
|||
let Post;
|
||||
if (JSON.parse(localStorage.getItem("post")).hasOwnProperty("reply")) {
|
||||
if (WarningInputArea.value == "") {
|
||||
Post = await BlueskyAPI.CreatePost(localStorage.getItem(Variables.BlueskyDID), Text, undefined, JSON.parse(localStorage.getItem("post")).post, JSON.parse(localStorage.getItem("post")).reply.root);
|
||||
Post = await BlueskyAPI.CreatePost(localStorage.getItem(Variables.BlueskyDID), Text, undefined, Tags, JSON.parse(localStorage.getItem("post")).post, JSON.parse(localStorage.getItem("post")).reply.root);
|
||||
} else {
|
||||
Post = await BlueskyAPI.CreatePost(localStorage.getItem(Variables.BlueskyDID), Text, WarningInputArea.value, JSON.parse(localStorage.getItem("post")).post, JSON.parse(localStorage.getItem("post")).reply.root);
|
||||
Post = await BlueskyAPI.CreatePost(localStorage.getItem(Variables.BlueskyDID), Text, WarningInputArea.value, Tags, JSON.parse(localStorage.getItem("post")).post, JSON.parse(localStorage.getItem("post")).reply.root);
|
||||
}
|
||||
await BlueskyAPI.CreateThreadGate(localStorage.getItem(Variables.BlueskyDID), Post.uri, TempVisible);
|
||||
} else {
|
||||
if (WarningInputArea.value == "") {
|
||||
Post = await BlueskyAPI.CreatePost(localStorage.getItem(Variables.BlueskyDID), Text, undefined, JSON.parse(localStorage.getItem("post")).post, JSON.parse(localStorage.getItem("post")).post);
|
||||
Post = await BlueskyAPI.CreatePost(localStorage.getItem(Variables.BlueskyDID), Text, undefined, Tags, JSON.parse(localStorage.getItem("post")).post, JSON.parse(localStorage.getItem("post")).post);
|
||||
} else {
|
||||
Post = await BlueskyAPI.CreatePost(localStorage.getItem(Variables.BlueskyDID), Text, WarningInputArea.value, JSON.parse(localStorage.getItem("post")).post, JSON.parse(localStorage.getItem("post")).post);
|
||||
Post = await BlueskyAPI.CreatePost(localStorage.getItem(Variables.BlueskyDID), Text, WarningInputArea.value, Tags, JSON.parse(localStorage.getItem("post")).post, JSON.parse(localStorage.getItem("post")).post);
|
||||
}
|
||||
await BlueskyAPI.CreateThreadGate(localStorage.getItem(Variables.BlueskyDID), Post.uri, TempVisible);
|
||||
}
|
||||
|
@ -107,9 +131,9 @@ async function Post() {
|
|||
} else if (website == "All") {
|
||||
let Post;
|
||||
if (WarningInputArea.value == "") {
|
||||
Post = await BlueskyAPI.CreatePost(localStorage.getItem(Variables.BlueskyDID), Text);
|
||||
Post = await BlueskyAPI.CreatePost(localStorage.getItem(Variables.BlueskyDID), Text, undefined, Tags);
|
||||
} else {
|
||||
Post = await BlueskyAPI.CreatePost(localStorage.getItem(Variables.BlueskyDID), Text, WarningInputArea.value);
|
||||
Post = await BlueskyAPI.CreatePost(localStorage.getItem(Variables.BlueskyDID), Text, WarningInputArea.value, Tags);
|
||||
}
|
||||
await BlueskyAPI.CreateThreadGate(localStorage.getItem(Variables.BlueskyDID), Post.uri, TempVisible);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue