diff options
author | 2021-09-12 13:08:33 +0530 | |
---|---|---|
committer | 2021-09-12 07:38:33 +0000 | |
commit | 4b3385094ba8a89247be421c81603a8dcbc99753 (patch) | |
tree | 16ccbf79244e55b36af0f5aa9298b93eda5f0402 /recipes/misskey/index.js | |
parent | New recipe: 'clockwise' (#692) (diff) | |
download | ferdium-recipes-4b3385094ba8a89247be421c81603a8dcbc99753.tar.gz ferdium-recipes-4b3385094ba8a89247be421c81603a8dcbc99753.tar.zst ferdium-recipes-4b3385094ba8a89247be421c81603a8dcbc99753.zip |
New recipe: 'misskey' (#693)
Diffstat (limited to 'recipes/misskey/index.js')
-rw-r--r-- | recipes/misskey/index.js | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/recipes/misskey/index.js b/recipes/misskey/index.js new file mode 100644 index 0000000..3f51bf9 --- /dev/null +++ b/recipes/misskey/index.js | |||
@@ -0,0 +1,28 @@ | |||
1 | module.exports = Ferdi => class Misskey extends Ferdi { | ||
2 | constructor(...args) { | ||
3 | let _temp; | ||
4 | return _temp = super(...args), this.events = { | ||
5 | }, _temp; | ||
6 | } | ||
7 | |||
8 | async validateUrl(url) { | ||
9 | try { | ||
10 | const res = await window.fetch(`${url}/api/stats`, { | ||
11 | method: 'POST', | ||
12 | headers: { | ||
13 | 'Content-Type': 'application/json', | ||
14 | }, | ||
15 | }); | ||
16 | const data = await res.json(); | ||
17 | // check any field in API response | ||
18 | return [ | ||
19 | 'originalUsersCount', 'usersCount', 'notesCount', 'originalNotesCount' | ||
20 | ].reduce((r, key) => ( | ||
21 | r && Object.hasOwnProperty.call(data, 'uri') | ||
22 | ), true); | ||
23 | } catch (err) { | ||
24 | console.error(err); | ||
25 | } | ||
26 | return false; | ||
27 | } | ||
28 | }; | ||