mirror of
https://git.pleroma.social/pleroma/relay.git
synced 2024-11-10 02:17:59 +00:00
15 lines
486 B
Python
15 lines
486 B
Python
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:
|
|
ACTORS[uri] = (await resp.json(encoding='utf-8', content_type=None))
|
|
DATABASE["actors"] = ACTORS
|
|
return ACTORS[uri]
|