mirror of
https://github.com/openvk/openvk
synced 2024-11-15 03:31:18 +03:00
api: add some fields and 2 new methods и jsonp
- Изменения коснулись методов account.getProfileInfo, account.getBalance, account.getOvkSettings, gifts.get, gifts.getCategories, groups.get, groups.getById, users.get, wall.get, wall.getById, wall.getComments, wall.getComment. - Добавлена поддержка JSONP
This commit is contained in:
parent
2795e1e1a4
commit
b3e57147b7
9 changed files with 198 additions and 112 deletions
|
@ -7,20 +7,32 @@ final class Account extends VKAPIRequestHandler
|
||||||
function getProfileInfo(): object
|
function getProfileInfo(): object
|
||||||
{
|
{
|
||||||
$this->requireUser();
|
$this->requireUser();
|
||||||
|
$user = $this->getUser();
|
||||||
return (object) [
|
$return_object = (object) [
|
||||||
"first_name" => $this->getUser()->getFirstName(),
|
"first_name" => $user->getFirstName(),
|
||||||
"id" => $this->getUser()->getId(),
|
"photo_200" => $user->getAvatarURL("normal"),
|
||||||
"last_name" => $this->getUser()->getLastName(),
|
"nickname" => $user->getPseudo(),
|
||||||
"home_town" => $this->getUser()->getHometown(),
|
"is_service_account" => false,
|
||||||
"status" => $this->getUser()->getStatus(),
|
"id" => $user->getId(),
|
||||||
"audio_status" => is_null($this->getUser()->getCurrentAudioStatus()) ? NULL : $this->getUser()->getCurrentAudioStatus()->toVkApiStruct($this->getUser()),
|
"is_verified" => $user->isVerified(),
|
||||||
"bdate" => is_null($this->getUser()->getBirthday()) ? '01.01.1970' : $this->getUser()->getBirthday()->format('%e.%m.%Y'),
|
"verification_status" => $user->isVerified() ? 'verified' : 'unverified',
|
||||||
"bdate_visibility" => $this->getUser()->getBirthdayPrivacy(),
|
"last_name" => $user->getLastName(),
|
||||||
|
"home_town" => $user->getHometown(),
|
||||||
|
"status" => $user->getStatus(),
|
||||||
|
"bdate" => is_null($user->getBirthday()) ? '01.01.1970' : $user->getBirthday()->format('%e.%m.%Y'),
|
||||||
|
"bdate_visibility" => $user->getBirthdayPrivacy(),
|
||||||
"phone" => "+420 ** *** 228", # TODO
|
"phone" => "+420 ** *** 228", # TODO
|
||||||
"relation" => $this->getUser()->getMaritalStatus(),
|
"relation" => $user->getMaritalStatus(),
|
||||||
"sex" => $this->getUser()->isFemale() ? 1 : 2
|
"screen_name" => $user->getShortCode(),
|
||||||
|
"sex" => $user->isFemale() ? 1 : 2,
|
||||||
|
#"email" => $user->getEmail(),
|
||||||
];
|
];
|
||||||
|
|
||||||
|
$audio_status = $user->getCurrentAudioStatus();
|
||||||
|
if(!is_null($audio_status))
|
||||||
|
$return_object->audio_status = $audio_status->toVkApiStruct($user);
|
||||||
|
|
||||||
|
return $return_object;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getInfo(): object
|
function getInfo(): object
|
||||||
|
@ -152,4 +164,30 @@ final class Account extends VKAPIRequestHandler
|
||||||
|
|
||||||
return (object) $output;
|
return (object) $output;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getBalance(): object
|
||||||
|
{
|
||||||
|
$this->requireUser();
|
||||||
|
if(!OPENVK_ROOT_CONF['openvk']['preferences']['commerce'])
|
||||||
|
$this->fail(105, "Commerce is disabled on this instance");
|
||||||
|
|
||||||
|
return (object) ['votes' => $this->getUser()->getCoins()];
|
||||||
|
}
|
||||||
|
|
||||||
|
function getOvkSettings(): object
|
||||||
|
{
|
||||||
|
$this->requireUser();
|
||||||
|
$user = $this->getUser();
|
||||||
|
|
||||||
|
$settings_list = (object)[
|
||||||
|
'avatar_style' => $user->getStyleAvatar(),
|
||||||
|
'style' => $user->getStyle(),
|
||||||
|
'show_rating' => !$user->prefersNotToSeeRating(),
|
||||||
|
'nsfw_tolerance' => $user->getNsfwTolerance(),
|
||||||
|
'post_view' => $user->hasMicroblogEnabled() ? 'microblog' : 'old',
|
||||||
|
'main_page' => $user->getMainPage() == 0 ? 'my_page' : 'news',
|
||||||
|
];
|
||||||
|
|
||||||
|
return $settings_list;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,15 +6,18 @@ use openvk\Web\Models\Entities\Notifications\GiftNotification;
|
||||||
|
|
||||||
final class Gifts extends VKAPIRequestHandler
|
final class Gifts extends VKAPIRequestHandler
|
||||||
{
|
{
|
||||||
function get(int $user_id, int $count = 10, int $offset = 0)
|
function get(int $user_id = NULL, int $count = 10, int $offset = 0)
|
||||||
{
|
{
|
||||||
$this->requireUser();
|
$this->requireUser();
|
||||||
|
|
||||||
$i = 0;
|
$i = 0;
|
||||||
|
|
||||||
$i += $offset;
|
$i += $offset;
|
||||||
|
$server_url = ovk_scheme(true) . $_SERVER["HTTP_HOST"];
|
||||||
|
|
||||||
|
if($user_id)
|
||||||
$user = (new UsersRepo)->get($user_id);
|
$user = (new UsersRepo)->get($user_id);
|
||||||
|
else
|
||||||
|
$user = $this->getUser();
|
||||||
|
|
||||||
if(!$user || $user->isDeleted())
|
if(!$user || $user->isDeleted())
|
||||||
$this->fail(177, "Invalid user");
|
$this->fail(177, "Invalid user");
|
||||||
|
@ -47,9 +50,9 @@ final class Gifts extends VKAPIRequestHandler
|
||||||
"date" => $gift->sent->timestamp(),
|
"date" => $gift->sent->timestamp(),
|
||||||
"gift" => [
|
"gift" => [
|
||||||
"id" => $gift->gift->getId(),
|
"id" => $gift->gift->getId(),
|
||||||
"thumb_256" => $gift->gift->getImage(2),
|
"thumb_256" => $server_url. $gift->gift->getImage(2),
|
||||||
"thumb_96" => $gift->gift->getImage(2),
|
"thumb_96" => $server_url . $gift->gift->getImage(2),
|
||||||
"thumb_48" => $gift->gift->getImage(2)
|
"thumb_48" => $server_url . $gift->gift->getImage(2)
|
||||||
],
|
],
|
||||||
"privacy" => 0
|
"privacy" => 0
|
||||||
];
|
];
|
||||||
|
@ -125,12 +128,13 @@ final class Gifts extends VKAPIRequestHandler
|
||||||
$this->fail(501, "Not implemented");
|
$this->fail(501, "Not implemented");
|
||||||
}
|
}
|
||||||
|
|
||||||
# этих методов не было в ВК, но я их добавил чтобы можно было отобразить список подарков
|
# в vk кстати называется gifts.getCatalog
|
||||||
function getCategories(bool $extended = false, int $page = 1)
|
function getCategories(bool $extended = false, int $page = 1)
|
||||||
{
|
{
|
||||||
$cats = (new GiftsRepo)->getCategories($page);
|
$cats = (new GiftsRepo)->getCategories($page);
|
||||||
$categ = [];
|
$categ = [];
|
||||||
$i = 0;
|
$i = 0;
|
||||||
|
$server_url = ovk_scheme(true) . $_SERVER["HTTP_HOST"];
|
||||||
|
|
||||||
if(!OPENVK_ROOT_CONF['openvk']['preferences']['commerce'])
|
if(!OPENVK_ROOT_CONF['openvk']['preferences']['commerce'])
|
||||||
$this->fail(105, "Commerce is disabled on this instance");
|
$this->fail(105, "Commerce is disabled on this instance");
|
||||||
|
@ -140,7 +144,7 @@ final class Gifts extends VKAPIRequestHandler
|
||||||
"name" => $cat->getName(),
|
"name" => $cat->getName(),
|
||||||
"description" => $cat->getDescription(),
|
"description" => $cat->getDescription(),
|
||||||
"id" => $cat->getId(),
|
"id" => $cat->getId(),
|
||||||
"thumbnail" => $cat->getThumbnailURL(),
|
"thumbnail" => $server_url . $cat->getThumbnailURL(),
|
||||||
];
|
];
|
||||||
|
|
||||||
if($extended == true) {
|
if($extended == true) {
|
||||||
|
@ -178,7 +182,7 @@ final class Gifts extends VKAPIRequestHandler
|
||||||
"name" => $gift->getName(),
|
"name" => $gift->getName(),
|
||||||
"image" => $gift->getImage(2),
|
"image" => $gift->getImage(2),
|
||||||
"usages_left" => (int)$gift->getUsagesLeft($this->getUser()),
|
"usages_left" => (int)$gift->getUsagesLeft($this->getUser()),
|
||||||
"price" => $gift->getPrice(), # голосов
|
"price" => $gift->getPrice(),
|
||||||
"is_free" => $gift->isFree()
|
"is_free" => $gift->isFree()
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
|
@ -88,6 +88,10 @@ final class Groups extends VKAPIRequestHandler
|
||||||
case "can_suggest":
|
case "can_suggest":
|
||||||
$rClubs[$i]->can_suggest = !$usr->canBeModifiedBy($this->getUser()) && $usr->getWallType() == 2;
|
$rClubs[$i]->can_suggest = !$usr->canBeModifiedBy($this->getUser()) && $usr->getWallType() == 2;
|
||||||
break;
|
break;
|
||||||
|
case "background":
|
||||||
|
$backgrounds = $usr->getBackDropPictureURLs();
|
||||||
|
$rClubs[$i]->background = $backgrounds;
|
||||||
|
break;
|
||||||
# unstandard feild
|
# unstandard feild
|
||||||
case "suggested_count":
|
case "suggested_count":
|
||||||
if($usr->getWallType() != 2) {
|
if($usr->getWallType() != 2) {
|
||||||
|
@ -208,6 +212,10 @@ final class Groups extends VKAPIRequestHandler
|
||||||
case "can_suggest":
|
case "can_suggest":
|
||||||
$response[$i]->can_suggest = !$clb->canBeModifiedBy($this->getUser()) && $clb->getWallType() == 2;
|
$response[$i]->can_suggest = !$clb->canBeModifiedBy($this->getUser()) && $clb->getWallType() == 2;
|
||||||
break;
|
break;
|
||||||
|
case "background":
|
||||||
|
$backgrounds = $clb->getBackDropPictureURLs();
|
||||||
|
$response[$i]->background = $backgrounds;
|
||||||
|
break;
|
||||||
# unstandard feild
|
# unstandard feild
|
||||||
case "suggested_count":
|
case "suggested_count":
|
||||||
if($clb->getWallType() != 2) {
|
if($clb->getWallType() != 2) {
|
||||||
|
|
|
@ -151,7 +151,6 @@ final class Users extends VKAPIRequestHandler
|
||||||
}
|
}
|
||||||
case "music":
|
case "music":
|
||||||
if(!$canView) {
|
if(!$canView) {
|
||||||
$response[$i]->music = "secret";
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -159,7 +158,6 @@ final class Users extends VKAPIRequestHandler
|
||||||
break;
|
break;
|
||||||
case "movies":
|
case "movies":
|
||||||
if(!$canView) {
|
if(!$canView) {
|
||||||
$response[$i]->movies = "secret";
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -167,7 +165,6 @@ final class Users extends VKAPIRequestHandler
|
||||||
break;
|
break;
|
||||||
case "tv":
|
case "tv":
|
||||||
if(!$canView) {
|
if(!$canView) {
|
||||||
$response[$i]->tv = "secret";
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -175,7 +172,6 @@ final class Users extends VKAPIRequestHandler
|
||||||
break;
|
break;
|
||||||
case "books":
|
case "books":
|
||||||
if(!$canView) {
|
if(!$canView) {
|
||||||
$response[$i]->books = "secret";
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -183,7 +179,6 @@ final class Users extends VKAPIRequestHandler
|
||||||
break;
|
break;
|
||||||
case "city":
|
case "city":
|
||||||
if(!$canView) {
|
if(!$canView) {
|
||||||
$response[$i]->city = "Воскресенск";
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -191,7 +186,6 @@ final class Users extends VKAPIRequestHandler
|
||||||
break;
|
break;
|
||||||
case "interests":
|
case "interests":
|
||||||
if(!$canView) {
|
if(!$canView) {
|
||||||
$response[$i]->interests = "secret";
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -199,7 +193,6 @@ final class Users extends VKAPIRequestHandler
|
||||||
break;
|
break;
|
||||||
case "quotes":
|
case "quotes":
|
||||||
if(!$canView) {
|
if(!$canView) {
|
||||||
$response[$i]->quotes = "secret";
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -207,7 +200,6 @@ final class Users extends VKAPIRequestHandler
|
||||||
break;
|
break;
|
||||||
case "email":
|
case "email":
|
||||||
if(!$canView) {
|
if(!$canView) {
|
||||||
$response[$i]->email = "secret@gmail.com";
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -215,7 +207,6 @@ final class Users extends VKAPIRequestHandler
|
||||||
break;
|
break;
|
||||||
case "telegram":
|
case "telegram":
|
||||||
if(!$canView) {
|
if(!$canView) {
|
||||||
$response[$i]->telegram = "@secret";
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -223,7 +214,6 @@ final class Users extends VKAPIRequestHandler
|
||||||
break;
|
break;
|
||||||
case "about":
|
case "about":
|
||||||
if(!$canView) {
|
if(!$canView) {
|
||||||
$response[$i]->about = "secret";
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -231,7 +221,6 @@ final class Users extends VKAPIRequestHandler
|
||||||
break;
|
break;
|
||||||
case "rating":
|
case "rating":
|
||||||
if(!$canView) {
|
if(!$canView) {
|
||||||
$response[$i]->rating = 22;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -246,8 +235,33 @@ final class Users extends VKAPIRequestHandler
|
||||||
"notes_count" => (new Notes)->getUserNotesCount($usr)
|
"notes_count" => (new Notes)->getUserNotesCount($usr)
|
||||||
];
|
];
|
||||||
break;
|
break;
|
||||||
|
case "correct_counters":
|
||||||
|
$response[$i]->counters = (object) [
|
||||||
|
"friends" => $usr->getFriendsCount(),
|
||||||
|
"photos" => (new Photos)->getUserPhotosCount($usr),
|
||||||
|
"videos" => (new Videos)->getUserVideosCount($usr),
|
||||||
|
"audios" => (new Audios)->getUserCollectionSize($usr),
|
||||||
|
"notes" => (new Notes)->getUserNotesCount($usr),
|
||||||
|
"groups" => $usr->getClubCount(),
|
||||||
|
"online_friends" => $usr->getFriendsOnlineCount(),
|
||||||
|
];
|
||||||
|
break;
|
||||||
case "guid":
|
case "guid":
|
||||||
$response[$i]->guid = $usr->getChandlerGUID();
|
$response[$i]->guid = $usr->getChandlerGUID();
|
||||||
|
break;
|
||||||
|
case 'background':
|
||||||
|
$backgrounds = $usr->getBackDropPictureURLs();
|
||||||
|
$response[$i]->background = $backgrounds;
|
||||||
|
break;
|
||||||
|
case 'reg_date':
|
||||||
|
if(!$canView) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
$response[$i]->reg_date = $usr->getRegistrationTime()->timestamp();
|
||||||
|
break;
|
||||||
|
case 'is_dead':
|
||||||
|
$response[$i]->is_dead = $usr->isDead();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -126,65 +126,41 @@ final class Wall extends VKAPIRequestHandler
|
||||||
else
|
else
|
||||||
$profiles[] = $attachment->getOwner()->getId();
|
$profiles[] = $attachment->getOwner()->getId();
|
||||||
|
|
||||||
$post_source = [];
|
|
||||||
|
|
||||||
if($attachment->getPlatform(true) === NULL) {
|
|
||||||
$post_source = (object)["type" => "vk"];
|
|
||||||
} else {
|
|
||||||
$post_source = (object)[
|
|
||||||
"type" => "api",
|
|
||||||
"platform" => $attachment->getPlatform(true)
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
$repost[] = [
|
$repost[] = [
|
||||||
"id" => $attachment->getVirtualId(),
|
"id" => $attachment->getVirtualId(),
|
||||||
"owner_id" => $attachment->isPostedOnBehalfOfGroup() ? $attachment->getOwner()->getId() * -1 : $attachment->getOwner()->getId(),
|
"owner_id" => $attachment->isPostedOnBehalfOfGroup() ? $attachment->getOwner()->getId() * -1 : $attachment->getOwner()->getId(),
|
||||||
"from_id" => $attachment->isPostedOnBehalfOfGroup() ? $attachment->getOwner()->getId() * -1 : $attachment->getOwner()->getId(),
|
"from_id" => $attachment->isPostedOnBehalfOfGroup() ? $attachment->getOwner()->getId() * -1 : $attachment->getOwner()->getId(),
|
||||||
"date" => $attachment->getPublicationTime()->timestamp(),
|
"date" => $attachment->getPublicationTime()->timestamp(),
|
||||||
"post_type" => "post",
|
"post_type" => $attachment->getVkApiType(),
|
||||||
"text" => $attachment->getText(false),
|
"text" => $attachment->getText(false),
|
||||||
"attachments" => $repostAttachments,
|
"attachments" => $repostAttachments,
|
||||||
"post_source" => $post_source,
|
"post_source" => $attachment->getPostSourceInfo(),
|
||||||
];
|
];
|
||||||
|
|
||||||
if ($attachment->getVirtualId() > 0)
|
if ($attachment->getTargetWall() > 0)
|
||||||
$profiles[] = $attachment->getVirtualId();
|
$profiles[] = $attachment->getTargetWall();
|
||||||
else
|
else
|
||||||
$groups[] = $attachment->getVirtualId();
|
$groups[] = abs($attachment->getTargetWall());
|
||||||
if($post->isSigned())
|
if($post->isSigned())
|
||||||
$profiles[] = $attachment->getOwner()->getId();
|
$profiles[] = $attachment->getOwner()->getId();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$post_source = [];
|
|
||||||
|
|
||||||
if($post->getPlatform(true) === NULL) {
|
|
||||||
$post_source = (object)["type" => "vk"];
|
|
||||||
} else {
|
|
||||||
$post_source = (object)[
|
|
||||||
"type" => "api",
|
|
||||||
"platform" => $post->getPlatform(true)
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
$postType = "post";
|
|
||||||
$signerId = NULL;
|
$signerId = NULL;
|
||||||
if($post->getSuggestionType() != 0)
|
|
||||||
$postType = "suggest";
|
|
||||||
|
|
||||||
|
|
||||||
if($post->isSigned()) {
|
if($post->isSigned()) {
|
||||||
$actualAuthor = $post->getOwner(false);
|
$actualAuthor = $post->getOwner(false);
|
||||||
$signerId = $actualAuthor->getId();
|
$signerId = $actualAuthor->getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
$items[] = (object)[
|
# TODO "can_pin", "copy_history" и прочее не должны возвращаться, если равны null или false
|
||||||
|
# Ну и ещё всё надо перенести в toVkApiStruct, а то слишком много дублированного кода
|
||||||
|
|
||||||
|
$post_temp_obj = (object)[
|
||||||
"id" => $post->getVirtualId(),
|
"id" => $post->getVirtualId(),
|
||||||
"from_id" => $from_id,
|
"from_id" => $from_id,
|
||||||
"owner_id" => $post->getTargetWall(),
|
"owner_id" => $post->getTargetWall(),
|
||||||
"date" => $post->getPublicationTime()->timestamp(),
|
"date" => $post->getPublicationTime()->timestamp(),
|
||||||
"post_type" => $postType,
|
"post_type" => $post->getVkApiType(),
|
||||||
"text" => $post->getText(false),
|
"text" => $post->getText(false),
|
||||||
"copy_history" => $repost,
|
"copy_history" => $repost,
|
||||||
"can_edit" => $post->canBeEditedBy($this->getUser()),
|
"can_edit" => $post->canBeEditedBy($this->getUser()),
|
||||||
|
@ -195,8 +171,7 @@ final class Wall extends VKAPIRequestHandler
|
||||||
"is_pinned" => $post->isPinned(),
|
"is_pinned" => $post->isPinned(),
|
||||||
"is_explicit" => $post->isExplicit(),
|
"is_explicit" => $post->isExplicit(),
|
||||||
"attachments" => $attachments,
|
"attachments" => $attachments,
|
||||||
"post_source" => $post_source,
|
"post_source" => $post->getPostSourceInfo(),
|
||||||
"signer_id" => $signerId,
|
|
||||||
"comments" => (object)[
|
"comments" => (object)[
|
||||||
"count" => $post->getCommentsCount(),
|
"count" => $post->getCommentsCount(),
|
||||||
"can_post" => 1
|
"can_post" => 1
|
||||||
|
@ -213,6 +188,14 @@ final class Wall extends VKAPIRequestHandler
|
||||||
]
|
]
|
||||||
];
|
];
|
||||||
|
|
||||||
|
if($signerId)
|
||||||
|
$post_temp_obj->signer_id = $signerId;
|
||||||
|
|
||||||
|
if($post->isDeactivationMessage())
|
||||||
|
$post_temp_obj->final_post = 1;
|
||||||
|
|
||||||
|
$items[] = $post_temp_obj;
|
||||||
|
|
||||||
if ($from_id > 0)
|
if ($from_id > 0)
|
||||||
$profiles[] = $from_id;
|
$profiles[] = $from_id;
|
||||||
else
|
else
|
||||||
|
@ -332,17 +315,6 @@ final class Wall extends VKAPIRequestHandler
|
||||||
else
|
else
|
||||||
$profiles[] = $attachment->getOwner()->getId();
|
$profiles[] = $attachment->getOwner()->getId();
|
||||||
|
|
||||||
$post_source = [];
|
|
||||||
|
|
||||||
if($attachment->getPlatform(true) === NULL) {
|
|
||||||
$post_source = (object)["type" => "vk"];
|
|
||||||
} else {
|
|
||||||
$post_source = (object)[
|
|
||||||
"type" => "api",
|
|
||||||
"platform" => $attachment->getPlatform(true)
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
$repost[] = [
|
$repost[] = [
|
||||||
"id" => $attachment->getVirtualId(),
|
"id" => $attachment->getVirtualId(),
|
||||||
"owner_id" => $attachment->isPostedOnBehalfOfGroup() ? $attachment->getOwner()->getId() * -1 : $attachment->getOwner()->getId(),
|
"owner_id" => $attachment->isPostedOnBehalfOfGroup() ? $attachment->getOwner()->getId() * -1 : $attachment->getOwner()->getId(),
|
||||||
|
@ -351,47 +323,29 @@ final class Wall extends VKAPIRequestHandler
|
||||||
"post_type" => "post",
|
"post_type" => "post",
|
||||||
"text" => $attachment->getText(false),
|
"text" => $attachment->getText(false),
|
||||||
"attachments" => $repostAttachments,
|
"attachments" => $repostAttachments,
|
||||||
"post_source" => $post_source,
|
"post_source" => $attachment->getPostSourceInfo(),
|
||||||
];
|
];
|
||||||
|
|
||||||
if ($attachment->getVirtualId() > 0)
|
if ($attachment->getTargetWall() > 0)
|
||||||
$profiles[] = $attachment->getVirtualId();
|
$profiles[] = $attachment->getTargetWall();
|
||||||
else
|
else
|
||||||
$groups[] = $attachment->getVirtualId();
|
$groups[] = abs($attachment->getTargetWall());
|
||||||
if($post->isSigned())
|
if($post->isSigned())
|
||||||
$profiles[] = $attachment->getOwner()->getId();
|
$profiles[] = $attachment->getOwner()->getId();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$post_source = [];
|
|
||||||
|
|
||||||
if($post->getPlatform(true) === NULL) {
|
|
||||||
$post_source = (object)["type" => "vk"];
|
|
||||||
} else {
|
|
||||||
$post_source = (object)[
|
|
||||||
"type" => "api",
|
|
||||||
"platform" => $post->getPlatform(true)
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
# TODO: $post->getVkApiType()
|
|
||||||
$postType = "post";
|
|
||||||
$signerId = NULL;
|
|
||||||
if($post->getSuggestionType() != 0)
|
|
||||||
$postType = "suggest";
|
|
||||||
|
|
||||||
|
|
||||||
if($post->isSigned()) {
|
if($post->isSigned()) {
|
||||||
$actualAuthor = $post->getOwner(false);
|
$actualAuthor = $post->getOwner(false);
|
||||||
$signerId = $actualAuthor->getId();
|
$signerId = $actualAuthor->getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
$items[] = (object)[
|
$post_temp_obj = (object)[
|
||||||
"id" => $post->getVirtualId(),
|
"id" => $post->getVirtualId(),
|
||||||
"from_id" => $from_id,
|
"from_id" => $from_id,
|
||||||
"owner_id" => $post->getTargetWall(),
|
"owner_id" => $post->getTargetWall(),
|
||||||
"date" => $post->getPublicationTime()->timestamp(),
|
"date" => $post->getPublicationTime()->timestamp(),
|
||||||
"post_type" => $postType,
|
"post_type" => $post->getVkApiType(),
|
||||||
"text" => $post->getText(false),
|
"text" => $post->getText(false),
|
||||||
"copy_history" => $repost,
|
"copy_history" => $repost,
|
||||||
"can_edit" => $post->canBeEditedBy($this->getUser()),
|
"can_edit" => $post->canBeEditedBy($this->getUser()),
|
||||||
|
@ -401,8 +355,7 @@ final class Wall extends VKAPIRequestHandler
|
||||||
"is_archived" => false,
|
"is_archived" => false,
|
||||||
"is_pinned" => $post->isPinned(),
|
"is_pinned" => $post->isPinned(),
|
||||||
"is_explicit" => $post->isExplicit(),
|
"is_explicit" => $post->isExplicit(),
|
||||||
"post_source" => $post_source,
|
"post_source" => $post->getPostSourceInfo(),
|
||||||
"signer_id" => $signerId,
|
|
||||||
"attachments" => $attachments,
|
"attachments" => $attachments,
|
||||||
"comments" => (object)[
|
"comments" => (object)[
|
||||||
"count" => $post->getCommentsCount(),
|
"count" => $post->getCommentsCount(),
|
||||||
|
@ -420,6 +373,14 @@ final class Wall extends VKAPIRequestHandler
|
||||||
]
|
]
|
||||||
];
|
];
|
||||||
|
|
||||||
|
if($signerId)
|
||||||
|
$post_temp_obj->signer_id = $signerId;
|
||||||
|
|
||||||
|
if($post->isDeactivationMessage())
|
||||||
|
$post_temp_obj->final_post = 1;
|
||||||
|
|
||||||
|
$items[] = $post_temp_obj;
|
||||||
|
|
||||||
if ($from_id > 0)
|
if ($from_id > 0)
|
||||||
$profiles[] = $from_id;
|
$profiles[] = $from_id;
|
||||||
else
|
else
|
||||||
|
@ -792,6 +753,9 @@ final class Wall extends VKAPIRequestHandler
|
||||||
]
|
]
|
||||||
];
|
];
|
||||||
|
|
||||||
|
if($comment->isFromPostAuthor($post))
|
||||||
|
$item['is_from_post_author'] = true;
|
||||||
|
|
||||||
if($need_likes == true)
|
if($need_likes == true)
|
||||||
$item['likes'] = [
|
$item['likes'] = [
|
||||||
"can_like" => 1,
|
"can_like" => 1,
|
||||||
|
@ -875,6 +839,9 @@ final class Wall extends VKAPIRequestHandler
|
||||||
]
|
]
|
||||||
];
|
];
|
||||||
|
|
||||||
|
if($comment->isFromPostAuthor())
|
||||||
|
$item['is_from_post_author'] = true;
|
||||||
|
|
||||||
if($extended == true)
|
if($extended == true)
|
||||||
$profiles[] = $comment->getOwner()->getId();
|
$profiles[] = $comment->getOwner()->getId();
|
||||||
|
|
||||||
|
@ -890,8 +857,6 @@ final class Wall extends VKAPIRequestHandler
|
||||||
$response['profiles'] = (!empty($profiles) ? (new Users)->get(implode(',', $profiles), $fields) : []);
|
$response['profiles'] = (!empty($profiles) ? (new Users)->get(implode(',', $profiles), $fields) : []);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return $response;
|
return $response;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -104,6 +104,22 @@ class Comment extends Post
|
||||||
return $this->getTarget()->canBeViewedBy($user);
|
return $this->getTarget()->canBeViewedBy($user);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function isFromPostAuthor($target = NULL)
|
||||||
|
{
|
||||||
|
if(!$target)
|
||||||
|
$target = $this->getTarget();
|
||||||
|
|
||||||
|
$target_owner = $target->getOwner();
|
||||||
|
$comment_owner = $this->getOwner();
|
||||||
|
|
||||||
|
if($target_owner->getRealId() === $comment_owner->getRealId())
|
||||||
|
return true;
|
||||||
|
|
||||||
|
# TODO: make it work with signer_id
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
function toNotifApiStruct()
|
function toNotifApiStruct()
|
||||||
{
|
{
|
||||||
$res = (object)[];
|
$res = (object)[];
|
||||||
|
|
|
@ -180,6 +180,31 @@ class Post extends Postable
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getPostSourceInfo(): array
|
||||||
|
{
|
||||||
|
$post_source = ["type" => "vk"];
|
||||||
|
if($this->getPlatform(true) !== NULL) {
|
||||||
|
$post_source = [
|
||||||
|
"type" => "api",
|
||||||
|
"platform" => $this->getPlatform(true)
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
if($this->isUpdateAvatarMessage())
|
||||||
|
$post_source['data'] = 'profile_photo';
|
||||||
|
|
||||||
|
return $post_source;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getVkApiType(): string
|
||||||
|
{
|
||||||
|
$type = 'post';
|
||||||
|
if($this->getSuggestionType() != 0)
|
||||||
|
$type = 'suggest';
|
||||||
|
|
||||||
|
return $type;
|
||||||
|
}
|
||||||
|
|
||||||
function pin(): void
|
function pin(): void
|
||||||
{
|
{
|
||||||
DB::i()
|
DB::i()
|
||||||
|
|
|
@ -1224,6 +1224,11 @@ class User extends RowModel
|
||||||
return (bool) $this->getRecord()->activated;
|
return (bool) $this->getRecord()->activated;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function isDead(): bool
|
||||||
|
{
|
||||||
|
return $this->onlineStatus() == 2;
|
||||||
|
}
|
||||||
|
|
||||||
function getUnbanTime(): ?string
|
function getUnbanTime(): ?string
|
||||||
{
|
{
|
||||||
$ban = (new Bans)->get((int) $this->getRecord()->block_reason);
|
$ban = (new Bans)->get((int) $this->getRecord()->block_reason);
|
||||||
|
@ -1338,13 +1343,14 @@ class User extends RowModel
|
||||||
$res->photo_100 = $this->getAvatarURL("tiny");
|
$res->photo_100 = $this->getAvatarURL("tiny");
|
||||||
$res->photo_200 = $this->getAvatarURL("normal");
|
$res->photo_200 = $this->getAvatarURL("normal");
|
||||||
$res->photo_id = !is_null($this->getAvatarPhoto()) ? $this->getAvatarPhoto()->getPrettyId() : NULL;
|
$res->photo_id = !is_null($this->getAvatarPhoto()) ? $this->getAvatarPhoto()->getPrettyId() : NULL;
|
||||||
# TODO: Perenesti syuda vsyo ostalnoyie
|
|
||||||
|
|
||||||
$res->is_closed = $this->isClosed();
|
$res->is_closed = $this->isClosed();
|
||||||
|
|
||||||
if(!is_null($user)) {
|
if(!is_null($user))
|
||||||
$res->can_access_closed = (bool)$this->canBeViewedBy($user);
|
$res->can_access_closed = (bool)$this->canBeViewedBy($user);
|
||||||
}
|
|
||||||
|
if($user->isDead())
|
||||||
|
$res->is_dead = 1;
|
||||||
|
|
||||||
return $res;
|
return $res;
|
||||||
}
|
}
|
||||||
|
|
|
@ -186,8 +186,12 @@ final class VKAPIPresenter extends OpenVKPresenter
|
||||||
|
|
||||||
function renderRoute(string $object, string $method): void
|
function renderRoute(string $object, string $method): void
|
||||||
{
|
{
|
||||||
|
$callback = $this->queryParam("callback");
|
||||||
$authMechanism = $this->queryParam("auth_mechanism") ?? "token";
|
$authMechanism = $this->queryParam("auth_mechanism") ?? "token";
|
||||||
if($authMechanism === "roaming") {
|
if($authMechanism === "roaming") {
|
||||||
|
if($callback)
|
||||||
|
$this->fail(-1, "User authorization failed: roaming mechanism is unavailable with jsonp.", $object, $method);
|
||||||
|
|
||||||
if(!$this->user->identity)
|
if(!$this->user->identity)
|
||||||
$this->fail(5, "User authorization failed: roaming mechanism is selected, but user is not logged in.", $object, $method);
|
$this->fail(5, "User authorization failed: roaming mechanism is selected, but user is not logged in.", $object, $method);
|
||||||
else
|
else
|
||||||
|
@ -260,9 +264,15 @@ final class VKAPIPresenter extends OpenVKPresenter
|
||||||
"response" => $res,
|
"response" => $res,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$size = strlen($result);
|
if($callback) {
|
||||||
|
$result = $callback . '(' . $result . ')';
|
||||||
|
header('Content-Type: application/javascript');
|
||||||
|
} else
|
||||||
header("Content-Type: application/json");
|
header("Content-Type: application/json");
|
||||||
|
|
||||||
|
$size = strlen($result);
|
||||||
header("Content-Length: $size");
|
header("Content-Length: $size");
|
||||||
|
|
||||||
exit($result);
|
exit($result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue