things
This commit is contained in:
parent
e6a2ba6861
commit
131cb57e13
|
@ -12,7 +12,6 @@
|
|||
"axios": "^1.7.2",
|
||||
"express": "^4.19.2",
|
||||
"formdata-node": "^6.0.3",
|
||||
"misskey-js": "^2024.5.0",
|
||||
"node-fetch": "^3.3.2",
|
||||
"uuid": "^10.0.0"
|
||||
}
|
||||
|
@ -267,12 +266,6 @@
|
|||
"node": ">= 0.6"
|
||||
}
|
||||
},
|
||||
"node_modules/eventemitter3": {
|
||||
"version": "5.0.1",
|
||||
"resolved": "https://registry.npmjs.org/eventemitter3/-/eventemitter3-5.0.1.tgz",
|
||||
"integrity": "sha512-GWkBvjiSZK87ELrYOSESUYeVIc9mvLLf/nXalMOS5dYrgZq9o5OVkbZAVM06CVxYsCwH9BDZFPlQTlPA1j4ahA==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/express": {
|
||||
"version": "4.19.2",
|
||||
"resolved": "https://registry.npmjs.org/express/-/express-4.19.2.tgz",
|
||||
|
@ -617,16 +610,6 @@
|
|||
"node": ">= 0.6"
|
||||
}
|
||||
},
|
||||
"node_modules/misskey-js": {
|
||||
"version": "2024.5.0",
|
||||
"resolved": "https://registry.npmjs.org/misskey-js/-/misskey-js-2024.5.0.tgz",
|
||||
"integrity": "sha512-Bm5tAGIKsPzIH51MCBMbmtggxC/BsIBLv2vYAfQV0LQd9/UEu5ujOsH5p7U+UN5toCTwj50uYxa5Zj9mTbV9eg==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"eventemitter3": "5.0.1",
|
||||
"reconnecting-websocket": "4.4.0"
|
||||
}
|
||||
},
|
||||
"node_modules/ms": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
|
||||
|
@ -776,12 +759,6 @@
|
|||
"node": ">= 0.8"
|
||||
}
|
||||
},
|
||||
"node_modules/reconnecting-websocket": {
|
||||
"version": "4.4.0",
|
||||
"resolved": "https://registry.npmjs.org/reconnecting-websocket/-/reconnecting-websocket-4.4.0.tgz",
|
||||
"integrity": "sha512-D2E33ceRPga0NvTDhJmphEgJ7FUYF0v4lr1ki0csq06OdlxKfugGzN0dSkxM/NfqCxYELK4KcaTOUOjTV6Dcng==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/safe-buffer": {
|
||||
"version": "5.2.1",
|
||||
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz",
|
||||
|
|
|
@ -15,7 +15,6 @@
|
|||
"axios": "^1.7.2",
|
||||
"express": "^4.19.2",
|
||||
"formdata-node": "^6.0.3",
|
||||
"misskey-js": "^2024.5.0",
|
||||
"node-fetch": "^3.3.2",
|
||||
"uuid": "^10.0.0"
|
||||
}
|
||||
|
|
|
@ -11,6 +11,8 @@ async function create_image(host, access_token, file_path) {
|
|||
}
|
||||
});
|
||||
|
||||
if(create.status == 200)
|
||||
|
||||
return create;
|
||||
};
|
||||
|
||||
|
@ -23,9 +25,12 @@ async function create_note(host, access_token, text, media_ids, visibility) {
|
|||
headers: {
|
||||
'Authorization': `Bearer ${access_token}`
|
||||
}
|
||||
}).then((data) => {
|
||||
return data.json();
|
||||
}).then((response) => {
|
||||
let data = response.data;
|
||||
|
||||
return data;
|
||||
});
|
||||
}
|
||||
|
||||
module.exports.create_image = create_image;
|
||||
module.exports.create_note = create_note;
|
24
src/index.js
24
src/index.js
|
@ -2,7 +2,6 @@ import { v4 as uuidv4 } from 'uuid';
|
|||
import fs from 'node:fs';
|
||||
import path from 'node:path';
|
||||
import express from 'express';
|
||||
import * as Misskey from 'misskey-js';
|
||||
|
||||
import * as Post from './api/post.cjs';
|
||||
import * as Auth from './api/auth.cjs';
|
||||
|
@ -33,7 +32,7 @@ app.get('/callback', function(req, res) {
|
|||
});
|
||||
|
||||
(async () => {
|
||||
let access_token = false;
|
||||
let access_token = null;
|
||||
|
||||
if(!token_file.token) { // if existing token not exist
|
||||
console.log(auth_url);
|
||||
|
@ -52,16 +51,19 @@ app.get('/callback', function(req, res) {
|
|||
access_token = token_file.token;
|
||||
}
|
||||
|
||||
const cli = new Misskey.api.APIClient({
|
||||
origin: host,
|
||||
credential: access_token
|
||||
});
|
||||
|
||||
let static_image_path = path.join(__dirname, '/data/current_radar.jpg');
|
||||
const upload_image = await Post.create_image(host, access_token, static_image_path);
|
||||
|
||||
console.log(upload_image);
|
||||
let static_radar_path = path.join(__dirname, '/data/current_radar.jpg');
|
||||
const static_radar_image = await Post.create_image(host, access_token, static_radar_path);
|
||||
const static_radar_image__id = static_radar_image.id;
|
||||
console.log(static_radar_image);
|
||||
|
||||
/* let note_text = "hello fediverse";
|
||||
const post_note = await Post.create_note(
|
||||
host,
|
||||
access_token,
|
||||
note_text,
|
||||
["" + static_radar_image__id],
|
||||
"public"
|
||||
) */
|
||||
})();
|
||||
|
||||
app.listen(port);
|
||||
|
|
Loading…
Reference in New Issue