mirror of
https://github.com/openvk/openvk
synced 2024-12-23 17:12:01 +03:00
ActivityPub: Add support for avatars, verify barges and statuses
This commit is contained in:
parent
57d4f9da2d
commit
2fa2a61057
4 changed files with 20 additions and 10 deletions
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue