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();
|
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"];
|
$serverUrl = ovk_scheme(true) . $_SERVER["SERVER_NAME"];
|
||||||
|
|
||||||
if($this->getRecord()->deleted)
|
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())
|
else if($this->isBanned())
|
||||||
return "$serverUrl/assets/packages/static/openvk/img/banned.jpg";
|
return "$serverUrl/assets/packages/static/openvk/img/banned.jpg";
|
||||||
|
|
||||||
$avPhoto = $this->getAvatarPhoto();
|
$avPhoto = $this->getAvatarPhoto();
|
||||||
if(is_null($avPhoto))
|
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
|
else
|
||||||
return $avPhoto->getURL();
|
return $avPhoto->getURL();
|
||||||
}
|
}
|
||||||
|
|
|
@ -61,9 +61,7 @@ final class ActivityPubPresenter extends OpenVKPresenter
|
||||||
'version' => OPENVK_VERSION);
|
'version' => OPENVK_VERSION);
|
||||||
$response->usage = array('localPosts' => $stats->posts,
|
$response->usage = array('localPosts' => $stats->posts,
|
||||||
'localComments' => $stats->comments,
|
'localComments' => $stats->comments,
|
||||||
'users' => array(
|
'users' => array('total' => $stats->all));
|
||||||
'total' => $stats->all
|
|
||||||
));
|
|
||||||
$response->metadata = (object)array();
|
$response->metadata = (object)array();
|
||||||
|
|
||||||
$this->returnJson((array) $response);
|
$this->returnJson((array) $response);
|
||||||
|
|
|
@ -301,6 +301,8 @@ abstract class OpenVKPresenter extends SimplePresenter
|
||||||
"@id": "sm:groups",
|
"@id": "sm:groups",
|
||||||
"@type": "@id"
|
"@type": "@id"
|
||||||
},
|
},
|
||||||
|
"verified": "sm:verified",
|
||||||
|
"status": "sm:status",
|
||||||
"vcard": "http://www.w3.org/2006/vcard/ns#"
|
"vcard": "http://www.w3.org/2006/vcard/ns#"
|
||||||
},
|
},
|
||||||
"https://w3id.org/security/v1"
|
"https://w3id.org/security/v1"
|
||||||
|
|
|
@ -35,6 +35,7 @@ final class UserPresenter extends OpenVKPresenter
|
||||||
/* ActivityPub quirks :DDDD */
|
/* ActivityPub quirks :DDDD */
|
||||||
if($this->isActivityPubClient()) {
|
if($this->isActivityPubClient()) {
|
||||||
$objUser = array(
|
$objUser = array(
|
||||||
|
"@context" => $this->getPersonContext(),
|
||||||
"type" => "Person",
|
"type" => "Person",
|
||||||
"id" => $user->getFullURL(true),
|
"id" => $user->getFullURL(true),
|
||||||
"name" => $user->getFullName(),
|
"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
|
"middleName" => $user->getPseudo(), // Unlike Smithereen, the Middle name in OpenVK is a Nickname
|
||||||
"vcard:bday" => $user->getBirthday()->format('%Y-%m-%d'),
|
"vcard:bday" => $user->getBirthday()->format('%Y-%m-%d'),
|
||||||
"gender" => "http://schema.org#" . $user->isFemale() ? "Male" : "Female",
|
"gender" => "http://schema.org#" . $user->isFemale() ? "Male" : "Female",
|
||||||
|
"verified" => $user->isVerified(),
|
||||||
|
"status" => $user->getStatus(),
|
||||||
"supportsFriendRequests" => true,
|
"supportsFriendRequests" => true,
|
||||||
"friends" => ovk_scheme(true) . $_SERVER['SERVER_NAME'] . "/friends" . $user->getId(),
|
"friends" => ovk_scheme(true) . $_SERVER['SERVER_NAME'] . "/friends" . $user->getId(),
|
||||||
"groups" => ovk_scheme(true) . $_SERVER['SERVER_NAME'] . "/groups" . $user->getId(),
|
"groups" => ovk_scheme(true) . $_SERVER['SERVER_NAME'] . "/groups" . $user->getId()
|
||||||
"@context" => $this->getPersonContext()
|
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if($user->getAvatarUrl(true) !== null) {
|
||||||
|
$objUser['image'] = array(
|
||||||
|
"type" => "Image",
|
||||||
|
"mediaType" => "image/jpg",
|
||||||
|
"url" => $user->getAvatarUrl(true)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
$this->returnJson($objUser);
|
$this->returnJson($objUser);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue