bookmark/unbookmark from fediverse

This commit is contained in:
les
2019-08-08 16:52:13 +02:00
parent fc2c82ab1a
commit ca83f1c675
5 changed files with 39 additions and 15 deletions

View File

@@ -3,6 +3,7 @@ const request = require('request')
const crypto = require('crypto')
const config = require('config')
const httpSignature = require('http-signature')
const debug = require('debug')('fediverse:helpers')
const actorCache = []
@@ -68,8 +69,10 @@ const Helpers = {
async getActor(url, force=false) {
// try with cache first if not forced
if (!force && actorCache[url]) return actorCache[url]
debug('getActor %s', url)
const user = await fetch(url, { headers: {'Accept': 'application/jrd+json, application/json'} })
.then(res => res.json())
.catch(debug)
actorCache[url] = user
return user
},