| 1 |
<?php |
| 2 |
/** |
| 3 |
* Inspired by the PHP ActivityPub Library by @Landrok |
| 4 |
* |
| 5 |
* @link https://github.com/landrok/activitypub |
| 6 |
*/ |
| 7 |
|
| 8 |
namespace Activitypub\Activity; |
| 9 |
|
| 10 |
/** |
| 11 |
* \Activitypub\Activity\Actor is an implementation of |
| 12 |
* one an Activity Streams Actor. |
| 13 |
* |
| 14 |
* Represents an individual actor. |
| 15 |
* |
| 16 |
* @see https://www.w3.org/TR/activitystreams-vocabulary/#actor-types |
| 17 |
*/ |
| 18 |
class Actor extends Base_Object { |
| 19 |
// Reduced context for actors. TODO: still unused. |
| 20 |
const JSON_LD_CONTEXT = array( |
| 21 |
'https://www.w3.org/ns/activitystreams', |
| 22 |
'https://w3id.org/security/v1', |
| 23 |
'https://purl.archive.org/socialweb/webfinger', |
| 24 |
array( |
| 25 |
'schema' => 'http://schema.org#', |
| 26 |
'toot' => 'http://joinmastodon.org/ns#', |
| 27 |
'lemmy' => 'https://join-lemmy.org/ns#', |
| 28 |
'manuallyApprovesFollowers' => 'as:manuallyApprovesFollowers', |
| 29 |
'PropertyValue' => 'schema:PropertyValue', |
| 30 |
'value' => 'schema:value', |
| 31 |
'Hashtag' => 'as:Hashtag', |
| 32 |
'featured' => array( |
| 33 |
'@id' => 'toot:featured', |
| 34 |
'@type' => '@id', |
| 35 |
), |
| 36 |
'featuredTags' => array( |
| 37 |
'@id' => 'toot:featuredTags', |
| 38 |
'@type' => '@id', |
| 39 |
), |
| 40 |
'moderators' => array( |
| 41 |
'@id' => 'lemmy:moderators', |
| 42 |
'@type' => '@id', |
| 43 |
), |
| 44 |
'postingRestrictedToMods' => 'lemmy:postingRestrictedToMods', |
| 45 |
'discoverable' => 'toot:discoverable', |
| 46 |
'indexable' => 'toot:indexable', |
| 47 |
), |
| 48 |
); |
| 49 |
|
| 50 |
/** |
| 51 |
* @var string |
| 52 |
*/ |
| 53 |
protected $type; |
| 54 |
|
| 55 |
/** |
| 56 |
* A reference to an ActivityStreams OrderedCollection comprised of |
| 57 |
* all the messages received by the actor. |
| 58 |
* |
| 59 |
* @see https://www.w3.org/TR/activitypub/#inbox |
| 60 |
* |
| 61 |
* @var string |
| 62 |
* | null |
| 63 |
*/ |
| 64 |
protected $inbox; |
| 65 |
|
| 66 |
/** |
| 67 |
* A reference to an ActivityStreams OrderedCollection comprised of |
| 68 |
* all the messages produced by the actor. |
| 69 |
* |
| 70 |
* @see https://www.w3.org/TR/activitypub/#outbox |
| 71 |
* |
| 72 |
* @var string |
| 73 |
* | null |
| 74 |
*/ |
| 75 |
protected $outbox; |
| 76 |
|
| 77 |
/** |
| 78 |
* A link to an ActivityStreams collection of the actors that this |
| 79 |
* actor is following. |
| 80 |
* |
| 81 |
* @see https://www.w3.org/TR/activitypub/#following |
| 82 |
* |
| 83 |
* @var string |
| 84 |
*/ |
| 85 |
protected $following; |
| 86 |
|
| 87 |
/** |
| 88 |
* A link to an ActivityStreams collection of the actors that |
| 89 |
* follow this actor. |
| 90 |
* |
| 91 |
* @see https://www.w3.org/TR/activitypub/#followers |
| 92 |
* |
| 93 |
* @var string |
| 94 |
*/ |
| 95 |
protected $followers; |
| 96 |
|
| 97 |
/** |
| 98 |
* A link to an ActivityStreams collection of objects this actor has |
| 99 |
* liked. |
| 100 |
* |
| 101 |
* @see https://www.w3.org/TR/activitypub/#liked |
| 102 |
* |
| 103 |
* @var string |
| 104 |
*/ |
| 105 |
protected $liked; |
| 106 |
|
| 107 |
/** |
| 108 |
* A list of supplementary Collections which may be of interest. |
| 109 |
* |
| 110 |
* @see https://www.w3.org/TR/activitypub/#streams-property |
| 111 |
* |
| 112 |
* @var array |
| 113 |
*/ |
| 114 |
protected $streams = array(); |
| 115 |
|
| 116 |
/** |
| 117 |
* A short username which may be used to refer to the actor, with no |
| 118 |
* uniqueness guarantees. |
| 119 |
* |
| 120 |
* @see https://www.w3.org/TR/activitypub/#preferredUsername |
| 121 |
* |
| 122 |
* @var string|null |
| 123 |
*/ |
| 124 |
protected $preferred_username; |
| 125 |
|
| 126 |
/** |
| 127 |
* A JSON object which maps additional typically server/domain-wide |
| 128 |
* endpoints which may be useful either for this actor or someone |
| 129 |
* referencing this actor. This mapping may be nested inside the |
| 130 |
* actor document as the value or may be a link to a JSON-LD |
| 131 |
* document with these properties. |
| 132 |
* |
| 133 |
* @see https://www.w3.org/TR/activitypub/#endpoints |
| 134 |
* |
| 135 |
* @var string|array|null |
| 136 |
*/ |
| 137 |
protected $endpoints; |
| 138 |
|
| 139 |
/** |
| 140 |
* It's not part of the ActivityPub protocol but it's a quite common |
| 141 |
* practice to handle an actor public key with a publicKey array: |
| 142 |
* [ |
| 143 |
* 'id' => 'https://my-example.com/actor#main-key' |
| 144 |
* 'owner' => 'https://my-example.com/actor', |
| 145 |
* 'publicKeyPem' => '-----BEGIN PUBLIC KEY----- |
| 146 |
* MIIBI [...] |
| 147 |
* DQIDAQAB |
| 148 |
* -----END PUBLIC KEY-----' |
| 149 |
* ] |
| 150 |
* |
| 151 |
* @see https://www.w3.org/wiki/SocialCG/ActivityPub/Authentication_Authorization#Signing_requests_using_HTTP_Signatures |
| 152 |
* |
| 153 |
* @var string|array|null |
| 154 |
*/ |
| 155 |
protected $public_key; |
| 156 |
|
| 157 |
/** |
| 158 |
* It's not part of the ActivityPub protocol but it's a quite common |
| 159 |
* practice to lock an account. If anabled, new followers will not be |
| 160 |
* automatically accepted, but will instead require you to manually |
| 161 |
* approve them. |
| 162 |
* |
| 163 |
* WordPress does only support 'false' at the moment. |
| 164 |
* |
| 165 |
* @see https://docs.joinmastodon.org/spec/activitypub/#as |
| 166 |
* |
| 167 |
* @context as:manuallyApprovesFollowers |
| 168 |
* |
| 169 |
* @var boolean |
| 170 |
*/ |
| 171 |
protected $manually_approves_followers = false; |
| 172 |
} |
| 173 |
|