Added methods to retrieve Actor information (by ID, username)
This commit is contained in:
parent
0206084508
commit
7706c71f6d
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue