ActivityPub: Add support for avatars, verify barges and statuses

This commit is contained in:
veselcraft 2021-12-28 21:00:23 +03:00
parent 57d4f9da2d
commit 2fa2a61057
No known key found for this signature in database
GPG key ID: AED66BC1AC628A4E
4 changed files with 20 additions and 10 deletions

View file

@ -109,18 +109,18 @@ class User extends RowModel
return ovk_scheme(true) . $_SERVER["SERVER_NAME"] . "/id" . $this->getId();
}
function getAvatarUrl(): string
function getAvatarUrl(bool $nullForDel = false): string
{
$serverUrl = ovk_scheme(true) . $_SERVER["SERVER_NAME"];
if($this->getRecord()->deleted)
return "$serverUrl/assets/packages/static/openvk/img/camera_200.png";
return $nullForDel ? null : "$serverUrl/assets/packages/static/openvk/img/camera_200.png";
else if($this->isBanned())
return "$serverUrl/assets/packages/static/openvk/img/banned.jpg";
$avPhoto = $this->getAvatarPhoto();
if(is_null($avPhoto))
return "$serverUrl/assets/packages/static/openvk/img/camera_200.png";
return $nullForDel ? null : "$serverUrl/assets/packages/static/openvk/img/camera_200.png";
else
return $avPhoto->getURL();
}

View file

@ -61,9 +61,7 @@ final class ActivityPubPresenter extends OpenVKPresenter
'version' => OPENVK_VERSION);
$response->usage = array('localPosts' => $stats->posts,
'localComments' => $stats->comments,
'users' => array(
'total' => $stats->all
));
'users' => array('total' => $stats->all));
$response->metadata = (object)array();
$this->returnJson((array) $response);

View file

@ -301,6 +301,8 @@ abstract class OpenVKPresenter extends SimplePresenter
"@id": "sm:groups",
"@type": "@id"
},
"verified": "sm:verified",
"status": "sm:status",
"vcard": "http://www.w3.org/2006/vcard/ns#"
},
"https://w3id.org/security/v1"

View file

@ -35,6 +35,7 @@ final class UserPresenter extends OpenVKPresenter
/* ActivityPub quirks :DDDD */
if($this->isActivityPubClient()) {
$objUser = array(
"@context" => $this->getPersonContext(),
"type" => "Person",
"id" => $user->getFullURL(true),
"name" => $user->getFullName(),
@ -55,12 +56,21 @@ final class UserPresenter extends OpenVKPresenter
"middleName" => $user->getPseudo(), // Unlike Smithereen, the Middle name in OpenVK is a Nickname
"vcard:bday" => $user->getBirthday()->format('%Y-%m-%d'),
"gender" => "http://schema.org#" . $user->isFemale() ? "Male" : "Female",
"verified" => $user->isVerified(),
"status" => $user->getStatus(),
"supportsFriendRequests" => true,
"friends" => ovk_scheme(true) . $_SERVER['SERVER_NAME'] . "/friends" . $user->getId(),
"groups" => ovk_scheme(true) . $_SERVER['SERVER_NAME'] . "/groups" . $user->getId(),
"@context" => $this->getPersonContext()
"groups" => ovk_scheme(true) . $_SERVER['SERVER_NAME'] . "/groups" . $user->getId()
);
if($user->getAvatarUrl(true) !== null) {
$objUser['image'] = array(
"type" => "Image",
"mediaType" => "image/jpg",
"url" => $user->getAvatarUrl(true)
);
}
$this->returnJson($objUser);
}