log media upload
This commit is contained in:
parent
c9bc576a15
commit
2be41af60d
@ -9,7 +9,7 @@ const allowedMedia = ["jpg", "jpeg", "gif", "png"];
|
|||||||
const interval = 1000*60*60;
|
const interval = 1000*60*60;
|
||||||
|
|
||||||
let tokenHandler = new MastodonTokenHandler(baseUrl);
|
let tokenHandler = new MastodonTokenHandler(baseUrl);
|
||||||
tokenHandler.getAccessToken((accessToken) => {
|
await tokenHandler.getAccessToken((accessToken) => {
|
||||||
let client = new MastodonHandler({
|
let client = new MastodonHandler({
|
||||||
api_url: `${baseUrl}/api/v1/`,
|
api_url: `${baseUrl}/api/v1/`,
|
||||||
access_token: accessToken,
|
access_token: accessToken,
|
||||||
|
@ -3,16 +3,20 @@ import fs from "fs";
|
|||||||
|
|
||||||
export class MastodonHandler extends Mastodon{
|
export class MastodonHandler extends Mastodon{
|
||||||
postStatus(status){
|
postStatus(status){
|
||||||
this.post('statuses', {status: status})
|
this.post('statuses', {status: status}).then((resp) => {
|
||||||
.then(console.log("status posted => "))
|
console.log("status posted => ");
|
||||||
.then((resp) => console.log(resp.data));
|
console.log(resp.data);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
postMedia(status, mediaPath){
|
postMedia(status, mediaPath){
|
||||||
this.post('media', { file: fs.createReadStream(mediaPath) }).then(resp => {
|
this.post('media', { file: fs.createReadStream(mediaPath) }).then(resp => {
|
||||||
let id = resp.data.id;
|
let id = resp.data.id;
|
||||||
this.post('statuses', { status: status, media_ids: [id] })
|
console.log("media uploaded => ");
|
||||||
.then(console.log("media posted => "))
|
console.log(resp.data);
|
||||||
.then((resp) => console.log(resp.data));
|
this.post('statuses', { status: status, media_ids: [id] }).then((resp) => {
|
||||||
|
console.log("media posted => ");
|
||||||
|
console.log(resp.data);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -9,7 +9,7 @@
|
|||||||
},
|
},
|
||||||
"keywords": [],
|
"keywords": [],
|
||||||
"author": "adb",
|
"author": "adb",
|
||||||
"license": "MPLv2",
|
"license": "MPL-2.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"mastodon-api": "^1.3.0"
|
"mastodon-api": "^1.3.0"
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user