mirror of
https://github.com/openvk/openvk
synced 2024-12-22 16:42:32 +03:00
ActivityPub: [Post] add attachment support and Smithereen's target field for wall support
This commit is contained in:
parent
966850dc61
commit
71a4e373d1
2 changed files with 35 additions and 7 deletions
|
@ -59,4 +59,11 @@ class Photo extends Media
|
||||||
|
|
||||||
return $photo;
|
return $photo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getDimentions()
|
||||||
|
{
|
||||||
|
$hash = $this->getRecord()->hash;
|
||||||
|
|
||||||
|
return getimagesize($this->pathFromHash($hash));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -311,6 +311,12 @@ final class WallPresenter extends OpenVKPresenter
|
||||||
|
|
||||||
if($this->isActivityPubClient()) {
|
if($this->isActivityPubClient()) {
|
||||||
$objPost = array(
|
$objPost = array(
|
||||||
|
"@context" => [
|
||||||
|
"https://www.w3.org/ns/activitystreams",
|
||||||
|
(object) array(
|
||||||
|
"sensitive" => "as:sensitive"
|
||||||
|
)
|
||||||
|
],
|
||||||
"type" => "Note",
|
"type" => "Note",
|
||||||
"id" => ovk_scheme(true) . $_SERVER['SERVER_NAME'] . "/wall" . $wall . "_" . $post_id,
|
"id" => ovk_scheme(true) . $_SERVER['SERVER_NAME'] . "/wall" . $wall . "_" . $post_id,
|
||||||
"attributedTo" => $post->getOwner()->getFullURL(true),
|
"attributedTo" => $post->getOwner()->getFullURL(true),
|
||||||
|
@ -335,15 +341,30 @@ final class WallPresenter extends OpenVKPresenter
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
"sensitive" => false,
|
"sensitive" => false,
|
||||||
"likes" => ovk_scheme(true) . $_SERVER['SERVER_NAME'] . "/wall" . $wall . "_" . $post_id . "/likes",
|
"likes" => ovk_scheme(true) . $_SERVER['SERVER_NAME'] . "/wall" . $wall . "_" . $post_id . "/likes"
|
||||||
"@context" => [
|
|
||||||
"https://www.w3.org/ns/activitystreams",
|
|
||||||
(object) array(
|
|
||||||
"sensitive" => "as:sensitive"
|
|
||||||
)
|
|
||||||
]
|
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if($post->getTargetWall() != $post->getOwner())
|
||||||
|
{
|
||||||
|
$objPost["target"] = array(
|
||||||
|
"type" => "Collection",
|
||||||
|
"id" => ovk_scheme(true) . $_SERVER['SERVER_NAME'] . "/wall" . $post->getTargetWall(),
|
||||||
|
"attributedTo" => ovk_scheme(true) . $_SERVER['SERVER_NAME'] . ($post->getTargetWall() > 0 ? "/id" . $post->getTargetWall() : "club" . abs($post->getTargetWall()))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach($post->getChildren() as $attachment) {
|
||||||
|
if($attachment instanceof \openvk\Web\Models\Entities\Photo) {
|
||||||
|
$objPost["attachment"][] = array(
|
||||||
|
"type" => "Image",
|
||||||
|
"mediaType" => "image/jpeg",
|
||||||
|
"width" => $attachment->getDimentions()[0],
|
||||||
|
"height" => $attachment->getDimentions()[1],
|
||||||
|
"url" => $attachment->getURL()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$this->returnJson($objPost, CT_AP);
|
$this->returnJson($objPost, CT_AP);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue