Added methods to retrieve Actor information (by ID, username)

This commit is contained in:
Niko 2022-02-11 01:49:13 +01:00
parent 0206084508
commit 7706c71f6d
1 changed files with 23 additions and 0 deletions

View File

@ -27,4 +27,27 @@ class DB {
$cursor = $this->manager->executeQuery($this->db_name.'.'.$table, $query);
return $cursor->toArray();
}
function getActorID($username) {
$domain = getenv('DOMAIN');
if ($domain === false)
$domain = 'localhost';
return 'https://'.$domain.'/u/'.$username;
}
function getActorByUsername($username, $includeMeta = false) {
return $this->getActor($this->getActorID($username), $includeMeta);
}
function getActor($id, $includeMeta = false) {
$actor = $this->findOne('objects', ['id' => $id]);
if ($actor === null)
return null;
if (!$includeMeta)
unset($actor->_meta);
if (!isset($actor->icon))
$actor->icon = '/assets/images/default_profile.png';
return $actor;
}
}