summaryrefslogtreecommitdiff
path: root/includes/external/addressbook/mastodon.js
diff options
context:
space:
mode:
authorRaindropsSys <contact@minteck.org>2023-04-05 15:55:48 +0200
committerRaindropsSys <contact@minteck.org>2023-04-05 15:55:48 +0200
commit47b8f2299a483024c4a6a8876af825a010954caa (patch)
tree8c8dc4e99e1e971eeda964a95942340f5a71f546 /includes/external/addressbook/mastodon.js
parent164d31aeb4d1e4d4b796fa4c5fbc356ab1a6ad67 (diff)
downloadpluralconnect-47b8f2299a483024c4a6a8876af825a010954caa.tar.gz
pluralconnect-47b8f2299a483024c4a6a8876af825a010954caa.tar.bz2
pluralconnect-47b8f2299a483024c4a6a8876af825a010954caa.zip
Updated 2 files and added 3 files (automated)
Diffstat (limited to 'includes/external/addressbook/mastodon.js')
-rw-r--r--includes/external/addressbook/mastodon.js59
1 files changed, 59 insertions, 0 deletions
diff --git a/includes/external/addressbook/mastodon.js b/includes/external/addressbook/mastodon.js
new file mode 100644
index 0000000..3209b7b
--- /dev/null
+++ b/includes/external/addressbook/mastodon.js
@@ -0,0 +1,59 @@
+const axios = require('axios');
+const apiVersion = "v1"
+
+function sleep(ms) {
+ return new Promise((res) => {
+ setTimeout(res, ms);
+ });
+}
+
+(async () => {
+ let user = process.argv[2];
+
+ try {
+ let data = (await axios.get(`https://mastodon.social/api/${apiVersion}/accounts/lookup?acct=${user}`)).data;
+
+ let obj = {
+ error: null,
+ avatar: "https://img.icons8.com/external-tal-revivo-regular-tal-revivo/64/ffffff/external-mastodon-is-an-online-self-hosted-social-media-and-social-networking-service-logo-regular-tal-revivo.png",
+ name: data['display_name'] ?? data['username'],
+ description: `@${data['acct']}`,
+ link: data['url'],
+ copy: [
+ {
+ title: "Copy link to profile",
+ text: data['url']
+ },
+ {
+ title: "Copy local username",
+ text: data['username']
+ },
+ {
+ title: "Copy full username",
+ text: data['acct']
+ },
+ data['avatar_static'] ? {
+ title: "Copy avatar URL",
+ text: data['avatar_static']
+ } : null
+ ]
+ }
+
+ if (data['avatar_static']) {
+ obj.avatar = data['avatar_static'];
+ }
+
+ console.log(JSON.stringify(obj, null, 2));
+ } catch (e) {
+ console.log(JSON.stringify({
+ error: e,
+ avatar: "https://img.icons8.com/external-tal-revivo-regular-tal-revivo/64/ffffff/external-mastodon-is-an-online-self-hosted-social-media-and-social-networking-service-logo-regular-tal-revivo.png",
+ name: user,
+ description: "Mastodon",
+ link: null,
+ copy: []
+ }, null, 2));
+ }
+
+
+})(); \ No newline at end of file