sedi-relay/viera/remote_actor.py

15 lines
468 B
Python
Raw Normal View History

2018-08-10 21:14:22 +00:00
import aiohttp
from .database import DATABASE
ACTORS = DATABASE.get("actors", {})
async def fetch_actor(uri, force=False):
if uri in ACTORS and not force:
return ACTORS[uri]
async with aiohttp.ClientSession() as session:
async with session.get(uri, headers={'Accept': 'application/activity+json'}) as resp:
2018-08-11 02:24:23 +00:00
ACTORS[uri] = (await resp.json(content_type=None))
2018-08-10 21:14:22 +00:00
DATABASE["actors"] = ACTORS
return ACTORS[uri]