Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<?php
/**
* @copyright 2021 Podlibre
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
* @link https://castopod.org/
*/
namespace ActivityPub\Entities;
use CodeIgniter\Entity;
class Actor extends Entity
{
/**
* @var string
*/
protected $key_id;
/**
* @var \ActivityPub\Entities\Actor[]
*/
protected $followers;
/**
* @var boolean
*/
protected $is_local;
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',
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
'cover_image_url' => '?string',
'cover_image_mimetype' => '?string',
'inbox_url' => 'string',
'outbox_url' => '?string',
'followers_url' => '?string',
'followers_count' => 'integer',
'notes_count' => 'integer',
'is_blocked' => 'boolean',
];
public function getKeyId()
{
return $this->uri . '#main-key';
}
public function getIsLocal()
{
if (!$this->is_local) {
$uri = current_url(true);
$this->is_local =
$this->domain ===
$uri->getHost() .
($uri->getPort() ? ':' . $uri->getPort() : '');
}
return $this->is_local;
}
public function getFollowers()
{
if (empty($this->id)) {
throw new \RuntimeException(
'Actor must be created before getting followers.',
);
}
if (empty($this->followers)) {
$this->followers = model('ActorModel')->getFollowers($this->id);
}
return $this->followers;
}
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
public function getAvatarImageUrl()
{
if (empty($this->attributes['avatar_image_url'])) {
return base_url(config('ActivityPub')->defaultAvatarImagePath);
}
return $this->attributes['avatar_image_url'];
}
public function getAvatarImageMimetype()
{
if (empty($this->attributes['avatar_image_mimetype'])) {
return config('ActivityPub')->defaultAvatarImageMimetype;
}
return $this->attributes['avatar_image_mimetype'];
}
public function getCoverImageUrl()
{
if (empty($this->attributes['cover_image_url'])) {
return base_url(config('ActivityPub')->defaultCoverImagePath);
}
return $this->attributes['cover_image_url'];
}
public function getCoverImageMimetype()
{
if (empty($this->attributes['cover_image_mimetype'])) {
return config('ActivityPub')->defaultCoverImageMimetype;
}
return $this->attributes['cover_image_mimetype'];
}