Skip to content
Snippets Groups Projects
Actor.php 3.74 KiB
Newer Older
/**
 * @copyright  2021 Podlibre
 * @license    https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
 * @link       https://castopod.org/
 */

/**
 * @property int $id
 * @property string $uri
 * @property string $username
 * @property string $domain
 * @property string $display_name
 * @property string|null $summary
 * @property string|null $private_key
 * @property string|null $public_key
 * @property string|null $avatar_image_url
 * @property string|null $avatar_image_mimetype
 * @property string|null $cover_image_url
 * @property string|null $cover_image_mimetype
 * @property string $inbox_url
 * @property string|null $outbox_url
 * @property string|null $followers_url
 * @property int $followers_count
 * @property bool $is_blocked
 *
 * @property Actor[] $followers
 * @property bool $is_local
 */
    protected ?array $followers = null;
    protected $casts = [
        'id' => 'integer',
        'uri' => 'string',
        'username' => 'string',
        'domain' => 'string',
        'display_name' => 'string',
        'summary' => '?string',
        'private_key' => '?string',
        'public_key' => '?string',
        'avatar_image_url' => '?string',
        'avatar_image_mimetype' => '?string',
        'cover_image_url' => '?string',
        'cover_image_mimetype' => '?string',
        'inbox_url' => 'string',
        'outbox_url' => '?string',
        'followers_url' => '?string',
        'followers_count' => 'integer',
    public function getPublicKeyId(): string
            $uri = current_url(true);

            $this->is_local =
                $this->domain ===
                $uri->getHost() .
                    ($uri->getPort() ? ':' . $uri->getPort() : '');
        }

        return $this->is_local;
    }

            throw new RuntimeException('Actor must be created before getting followers.');
            $this->followers = (array) model('ActorModel', false)
        if ($this->attributes['avatar_image_url'] === null) {
            return base_url(config('Fediverse')->defaultAvatarImagePath);
        }

        return $this->attributes['avatar_image_url'];
    }

        if ($this->attributes['avatar_image_mimetype'] === null) {
            return config('Fediverse')->defaultAvatarImageMimetype;
        }

        return $this->attributes['avatar_image_mimetype'];
    }

        if ($this->attributes['cover_image_url'] === null) {
            return base_url(config('Fediverse')->defaultCoverImagePath);
        }

        return $this->attributes['cover_image_url'];
    }

        if ($this->attributes['cover_image_mimetype'] === null) {
            return config('Fediverse')->defaultCoverImageMimetype;
        }

        return $this->attributes['cover_image_mimetype'];
    }