Skip to content

Commit

Permalink
Add custom appName for posting to steem
Browse files Browse the repository at this point in the history
  • Loading branch information
anpigon committed Mar 28, 2022
1 parent 0bdbfff commit 09da667
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions src/steemit-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,29 +49,32 @@ export class SteemitClient {
.replace(/^<!--.*-->$/ms, '')
.trim();

const appName = this.plugin.settings?.appName || `${this.plugin.manifest.id}/${this.plugin.manifest.version}`;
const jsonMetadata: SteemitJsonMetadata = {
app: `${this.plugin.manifest.id}/${this.plugin.manifest.version}`,
format: 'markdown',
app: appName,
};
if (tags && tags.length) {
jsonMetadata['tags'] = tags;
}
const data = {
parent_author: '', // Leave parent author empty
parent_permlink: category, // Main tag
author: username, // Author
permlink: permlink, // Permlink
title: title, // Title
body: parsedContent, // Body
json_metadata: JSON.stringify(jsonMetadata), // Json Meta
};

const client = new Client('https://api.steemit.com');
const response = await client.broadcast.comment(
{
parent_author: '', // Leave parent author empty
parent_permlink: category, // Main tag
author: username, // Author
permlink: permlink, // Permlink
title: title, // Title
body: parsedContent, // Body
json_metadata: JSON.stringify(jsonMetadata), // Json Meta
},
data,
PrivateKey.fromString(password),
);

await this.app.vault.modify(
activeView.file,
activeView!.file,
fileContent.replace(/^(permlink:).*$/m, `$1 ${permlink}`),
);

Expand Down

0 comments on commit 09da667

Please sign in to comment.