Skip to content

Commit

Permalink
mastodon のバックエンドで post するようにした
Browse files Browse the repository at this point in the history
  • Loading branch information
amay077 committed Jun 27, 2024
1 parent 1060cfa commit b992897
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 23 deletions.
24 changes: 5 additions & 19 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,23 +1,9 @@
{
"typescript.preferences.importModuleSpecifier": "non-relative",
"workbench.colorTheme": "Monokai",
"workbench.colorCustomizations": {
"activityBar.activeBackground": "#ab307e",
"activityBar.background": "#ab307e",
"activityBar.foreground": "#e7e7e7",
"activityBar.inactiveForeground": "#e7e7e799",
"activityBarBadge.background": "#25320e",
"activityBarBadge.foreground": "#e7e7e7",
"commandCenter.border": "#e7e7e799",
"sash.hoverBorder": "#ab307e",
"statusBar.background": "#832561",
"statusBar.foreground": "#e7e7e7",
"statusBarItem.hoverBackground": "#ab307e",
"statusBarItem.remoteBackground": "#832561",
"statusBarItem.remoteForeground": "#e7e7e7",
"titleBar.activeBackground": "#832561",
"titleBar.activeForeground": "#e7e7e7",
"titleBar.inactiveBackground": "#83256199",
"titleBar.inactiveForeground": "#e7e7e799"
"titleBar.activeBackground": "#059212",
"titleBar.activeForeground": "#FFFFFF",
"activityBar.background": "#059212",
"activityBar.foreground": "#FFFFFF"
},
"peacock.color": "#832561"
}
17 changes: 13 additions & 4 deletions src/lib/MainContent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,15 +108,24 @@ const postToMastodon = async (text: string, images: string[]): Promise<boolean>
}
})();

const res = await fetch(`https://${MASTODON_HOST}/api/v1/statuses`, {
// const res = await fetch(`https://${MASTODON_HOST}/api/v1/statuses`, {
// method: 'POST',
// headers: {
// 'Authorization': `Bearer ${ACCESS_TOKEN}`,
// 'Content-Type': 'application/json',
// },
// body: JSON.stringify({ status, media_ids }),
// });

const res = await fetch(`${Config.API_ENDPOINT}/mastodon_post`, {
method: 'POST',
headers: {
'Authorization': `Bearer ${ACCESS_TOKEN}`,
'Content-Type': 'application/json',
'Content-Type': 'text/plain',
},
body: JSON.stringify({ status, media_ids }),
body: JSON.stringify({ host: MASTODON_HOST, token: settings.token_data.access_token, status, media_ids }),
});


if (res.ok) {
} else {
return false;
Expand Down

0 comments on commit b992897

Please sign in to comment.