find($id); } /** * Looks for actor with username and domain, * if no domain has been specified, the current host will be used * * @param mixed $username * @param mixed|null $domain * @return mixed */ public function getActorByUsername($username, $domain = null) { // TODO: is there a better way? helper('activitypub'); if (!$domain) { $domain = get_current_domain(); } if (!($found = cache("actor@{$username}@{$domain}"))) { $found = $this->where([ 'username' => $username, 'domain' => $domain, ])->first(); cache()->save("actor@{$username}@{$domain}", $found, DECADE); } return $found; } public function getActorByUri($actorUri) { return $this->where('uri', $actorUri)->first(); } public function getFollowers($actorId) { return $this->join( 'activitypub_follows', 'activitypub_follows.actor_id = id', 'inner', ) ->where('activitypub_follows.target_actor_id', $actorId) ->findAll(); } /** * Check if an actor is blocked using its uri * * @param mixed $actorUri * @return boolean */ public function isActorBlocked($actorUri) { return $this->where(['uri' => $actorUri, 'is_blocked' => true])->first() ? true : false; } /** * Retrieves all blocked actors. * * @return \ActivityPub\Entities\Actor[] */ public function getBlockedActors() { return $this->where('is_blocked', 1)->findAll(); } public function blockActor($actorId) { $this->update($actorId, ['is_blocked' => 1]); } public function unblockActor($actorId) { $this->update($actorId, ['is_blocked' => 0]); } }