From 2be41af60d44f8b9d88c2bacd4f6fe5150f068d8 Mon Sep 17 00:00:00 2001 From: adb Date: Thu, 25 Feb 2021 23:58:03 +0100 Subject: [PATCH] log media upload --- node_app/main.js | 2 +- node_app/mastodonHandler.js | 16 ++++++++++------ node_app/package.json | 2 +- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/node_app/main.js b/node_app/main.js index 9a3659c..09626f4 100644 --- a/node_app/main.js +++ b/node_app/main.js @@ -9,7 +9,7 @@ const allowedMedia = ["jpg", "jpeg", "gif", "png"]; const interval = 1000*60*60; let tokenHandler = new MastodonTokenHandler(baseUrl); -tokenHandler.getAccessToken((accessToken) => { +await tokenHandler.getAccessToken((accessToken) => { let client = new MastodonHandler({ api_url: `${baseUrl}/api/v1/`, access_token: accessToken, diff --git a/node_app/mastodonHandler.js b/node_app/mastodonHandler.js index 7566ee4..5be92c1 100644 --- a/node_app/mastodonHandler.js +++ b/node_app/mastodonHandler.js @@ -3,16 +3,20 @@ import fs from "fs"; export class MastodonHandler extends Mastodon{ postStatus(status){ - this.post('statuses', {status: status}) - .then(console.log("status posted => ")) - .then((resp) => console.log(resp.data)); + this.post('statuses', {status: status}).then((resp) => { + console.log("status posted => "); + console.log(resp.data); + }); } postMedia(status, mediaPath){ this.post('media', { file: fs.createReadStream(mediaPath) }).then(resp => { let id = resp.data.id; - this.post('statuses', { status: status, media_ids: [id] }) - .then(console.log("media posted => ")) - .then((resp) => console.log(resp.data)); + console.log("media uploaded => "); + console.log(resp.data); + this.post('statuses', { status: status, media_ids: [id] }).then((resp) => { + console.log("media posted => "); + console.log(resp.data); + }); }); } } \ No newline at end of file diff --git a/node_app/package.json b/node_app/package.json index 073f94d..59bd293 100644 --- a/node_app/package.json +++ b/node_app/package.json @@ -9,7 +9,7 @@ }, "keywords": [], "author": "adb", - "license": "MPLv2", + "license": "MPL-2.0", "dependencies": { "mastodon-api": "^1.3.0" }