mirror of
https://github.com/openvk/openvk
synced 2024-11-14 19:19:14 +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
|
||||
{
|
||||
$this->requireUser();
|
||||
|
||||
return (object) [
|
||||
"first_name" => $this->getUser()->getFirstName(),
|
||||
"id" => $this->getUser()->getId(),
|
||||
"last_name" => $this->getUser()->getLastName(),
|
||||
"home_town" => $this->getUser()->getHometown(),
|
||||
"status" => $this->getUser()->getStatus(),
|
||||
"audio_status" => is_null($this->getUser()->getCurrentAudioStatus()) ? NULL : $this->getUser()->getCurrentAudioStatus()->toVkApiStruct($this->getUser()),
|
||||
"bdate" => is_null($this->getUser()->getBirthday()) ? '01.01.1970' : $this->getUser()->getBirthday()->format('%e.%m.%Y'),
|
||||
"bdate_visibility" => $this->getUser()->getBirthdayPrivacy(),
|
||||
$user = $this->getUser();
|
||||
$return_object = (object) [
|
||||
"first_name" => $user->getFirstName(),
|
||||
"photo_200" => $user->getAvatarURL("normal"),
|
||||
"nickname" => $user->getPseudo(),
|
||||
"is_service_account" => false,
|
||||
"id" => $user->getId(),
|
||||
"is_verified" => $user->isVerified(),
|
||||
"verification_status" => $user->isVerified() ? 'verified' : 'unverified',
|
||||
"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
|
||||
"relation" => $this->getUser()->getMaritalStatus(),
|
||||
"sex" => $this->getUser()->isFemale() ? 1 : 2
|
||||
"relation" => $user->getMaritalStatus(),
|
||||
"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
|
||||
|
@ -152,4 +164,30 @@ final class Account extends VKAPIRequestHandler
|
|||
|
||||
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
|
||||
{
|
||||
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();
|
||||
|
||||
$i = 0;
|
||||
|
||||
$i += $offset;
|
||||
$server_url = ovk_scheme(true) . $_SERVER["HTTP_HOST"];
|
||||
|
||||
$user = (new UsersRepo)->get($user_id);
|
||||
if($user_id)
|
||||
$user = (new UsersRepo)->get($user_id);
|
||||
else
|
||||
$user = $this->getUser();
|
||||
|
||||
if(!$user || $user->isDeleted())
|
||||
$this->fail(177, "Invalid user");
|
||||
|
@ -47,9 +50,9 @@ final class Gifts extends VKAPIRequestHandler
|
|||
"date" => $gift->sent->timestamp(),
|
||||
"gift" => [
|
||||
"id" => $gift->gift->getId(),
|
||||
"thumb_256" => $gift->gift->getImage(2),
|
||||
"thumb_96" => $gift->gift->getImage(2),
|
||||
"thumb_48" => $gift->gift->getImage(2)
|
||||
"thumb_256" => $server_url. $gift->gift->getImage(2),
|
||||
"thumb_96" => $server_url . $gift->gift->getImage(2),
|
||||
"thumb_48" => $server_url . $gift->gift->getImage(2)
|
||||
],
|
||||
"privacy" => 0
|
||||
];
|
||||
|
@ -125,12 +128,13 @@ final class Gifts extends VKAPIRequestHandler
|
|||
$this->fail(501, "Not implemented");
|
||||
}
|
||||
|
||||
# этих методов не было в ВК, но я их добавил чтобы можно было отобразить список подарков
|
||||
# в vk кстати называется gifts.getCatalog
|
||||
function getCategories(bool $extended = false, int $page = 1)
|
||||
{
|
||||
$cats = (new GiftsRepo)->getCategories($page);
|
||||
$categ = [];
|
||||
$i = 0;
|
||||
$server_url = ovk_scheme(true) . $_SERVER["HTTP_HOST"];
|
||||
|
||||
if(!OPENVK_ROOT_CONF['openvk']['preferences']['commerce'])
|
||||
$this->fail(105, "Commerce is disabled on this instance");
|
||||
|
@ -140,8 +144,8 @@ final class Gifts extends VKAPIRequestHandler
|
|||
"name" => $cat->getName(),
|
||||
"description" => $cat->getDescription(),
|
||||
"id" => $cat->getId(),
|
||||
"thumbnail" => $cat->getThumbnailURL(),
|
||||
];
|
||||
"thumbnail" => $server_url . $cat->getThumbnailURL(),
|
||||
];
|
||||
|
||||
if($extended == true) {
|
||||
$categ[$i]["localizations"] = [];
|
||||
|
@ -178,7 +182,7 @@ final class Gifts extends VKAPIRequestHandler
|
|||
"name" => $gift->getName(),
|
||||
"image" => $gift->getImage(2),
|
||||
"usages_left" => (int)$gift->getUsagesLeft($this->getUser()),
|
||||
"price" => $gift->getPrice(), # голосов
|
||||
"price" => $gift->getPrice(),
|
||||
"is_free" => $gift->isFree()
|
||||
];
|
||||
}
|
||||
|
|
|
@ -88,6 +88,10 @@ final class Groups extends VKAPIRequestHandler
|
|||
case "can_suggest":
|
||||
$rClubs[$i]->can_suggest = !$usr->canBeModifiedBy($this->getUser()) && $usr->getWallType() == 2;
|
||||
break;
|
||||
case "background":
|
||||
$backgrounds = $usr->getBackDropPictureURLs();
|
||||
$rClubs[$i]->background = $backgrounds;
|
||||
break;
|
||||
# unstandard feild
|
||||
case "suggested_count":
|
||||
if($usr->getWallType() != 2) {
|
||||
|
@ -208,6 +212,10 @@ final class Groups extends VKAPIRequestHandler
|
|||
case "can_suggest":
|
||||
$response[$i]->can_suggest = !$clb->canBeModifiedBy($this->getUser()) && $clb->getWallType() == 2;
|
||||
break;
|
||||
case "background":
|
||||
$backgrounds = $clb->getBackDropPictureURLs();
|
||||
$response[$i]->background = $backgrounds;
|
||||
break;
|
||||
# unstandard feild
|
||||
case "suggested_count":
|
||||
if($clb->getWallType() != 2) {
|
||||
|
|
|
@ -151,7 +151,6 @@ final class Users extends VKAPIRequestHandler
|
|||
}
|
||||
case "music":
|
||||
if(!$canView) {
|
||||
$response[$i]->music = "secret";
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -159,7 +158,6 @@ final class Users extends VKAPIRequestHandler
|
|||
break;
|
||||
case "movies":
|
||||
if(!$canView) {
|
||||
$response[$i]->movies = "secret";
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -167,7 +165,6 @@ final class Users extends VKAPIRequestHandler
|
|||
break;
|
||||
case "tv":
|
||||
if(!$canView) {
|
||||
$response[$i]->tv = "secret";
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -175,7 +172,6 @@ final class Users extends VKAPIRequestHandler
|
|||
break;
|
||||
case "books":
|
||||
if(!$canView) {
|
||||
$response[$i]->books = "secret";
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -183,7 +179,6 @@ final class Users extends VKAPIRequestHandler
|
|||
break;
|
||||
case "city":
|
||||
if(!$canView) {
|
||||
$response[$i]->city = "Воскресенск";
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -191,7 +186,6 @@ final class Users extends VKAPIRequestHandler
|
|||
break;
|
||||
case "interests":
|
||||
if(!$canView) {
|
||||
$response[$i]->interests = "secret";
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -199,7 +193,6 @@ final class Users extends VKAPIRequestHandler
|
|||
break;
|
||||
case "quotes":
|
||||
if(!$canView) {
|
||||
$response[$i]->quotes = "secret";
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -207,7 +200,6 @@ final class Users extends VKAPIRequestHandler
|
|||
break;
|
||||
case "email":
|
||||
if(!$canView) {
|
||||
$response[$i]->email = "secret@gmail.com";
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -215,7 +207,6 @@ final class Users extends VKAPIRequestHandler
|
|||
break;
|
||||
case "telegram":
|
||||
if(!$canView) {
|
||||
$response[$i]->telegram = "@secret";
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -223,7 +214,6 @@ final class Users extends VKAPIRequestHandler
|
|||
break;
|
||||
case "about":
|
||||
if(!$canView) {
|
||||
$response[$i]->about = "secret";
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -231,7 +221,6 @@ final class Users extends VKAPIRequestHandler
|
|||
break;
|
||||
case "rating":
|
||||
if(!$canView) {
|
||||
$response[$i]->rating = 22;
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -246,9 +235,34 @@ final class Users extends VKAPIRequestHandler
|
|||
"notes_count" => (new Notes)->getUserNotesCount($usr)
|
||||
];
|
||||
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":
|
||||
$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;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -126,65 +126,41 @@ final class Wall extends VKAPIRequestHandler
|
|||
else
|
||||
$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[] = [
|
||||
"id" => $attachment->getVirtualId(),
|
||||
"owner_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(),
|
||||
"post_type" => "post",
|
||||
"post_type" => $attachment->getVkApiType(),
|
||||
"text" => $attachment->getText(false),
|
||||
"attachments" => $repostAttachments,
|
||||
"post_source" => $post_source,
|
||||
"post_source" => $attachment->getPostSourceInfo(),
|
||||
];
|
||||
|
||||
if ($attachment->getVirtualId() > 0)
|
||||
$profiles[] = $attachment->getVirtualId();
|
||||
if ($attachment->getTargetWall() > 0)
|
||||
$profiles[] = $attachment->getTargetWall();
|
||||
else
|
||||
$groups[] = $attachment->getVirtualId();
|
||||
$groups[] = abs($attachment->getTargetWall());
|
||||
if($post->isSigned())
|
||||
$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;
|
||||
if($post->getSuggestionType() != 0)
|
||||
$postType = "suggest";
|
||||
|
||||
|
||||
if($post->isSigned()) {
|
||||
$actualAuthor = $post->getOwner(false);
|
||||
$signerId = $actualAuthor->getId();
|
||||
}
|
||||
|
||||
$items[] = (object)[
|
||||
# TODO "can_pin", "copy_history" и прочее не должны возвращаться, если равны null или false
|
||||
# Ну и ещё всё надо перенести в toVkApiStruct, а то слишком много дублированного кода
|
||||
|
||||
$post_temp_obj = (object)[
|
||||
"id" => $post->getVirtualId(),
|
||||
"from_id" => $from_id,
|
||||
"owner_id" => $post->getTargetWall(),
|
||||
"date" => $post->getPublicationTime()->timestamp(),
|
||||
"post_type" => $postType,
|
||||
"post_type" => $post->getVkApiType(),
|
||||
"text" => $post->getText(false),
|
||||
"copy_history" => $repost,
|
||||
"can_edit" => $post->canBeEditedBy($this->getUser()),
|
||||
|
@ -195,8 +171,7 @@ final class Wall extends VKAPIRequestHandler
|
|||
"is_pinned" => $post->isPinned(),
|
||||
"is_explicit" => $post->isExplicit(),
|
||||
"attachments" => $attachments,
|
||||
"post_source" => $post_source,
|
||||
"signer_id" => $signerId,
|
||||
"post_source" => $post->getPostSourceInfo(),
|
||||
"comments" => (object)[
|
||||
"count" => $post->getCommentsCount(),
|
||||
"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)
|
||||
$profiles[] = $from_id;
|
||||
else
|
||||
|
@ -332,17 +315,6 @@ final class Wall extends VKAPIRequestHandler
|
|||
else
|
||||
$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[] = [
|
||||
"id" => $attachment->getVirtualId(),
|
||||
"owner_id" => $attachment->isPostedOnBehalfOfGroup() ? $attachment->getOwner()->getId() * -1 : $attachment->getOwner()->getId(),
|
||||
|
@ -351,47 +323,29 @@ final class Wall extends VKAPIRequestHandler
|
|||
"post_type" => "post",
|
||||
"text" => $attachment->getText(false),
|
||||
"attachments" => $repostAttachments,
|
||||
"post_source" => $post_source,
|
||||
"post_source" => $attachment->getPostSourceInfo(),
|
||||
];
|
||||
|
||||
if ($attachment->getVirtualId() > 0)
|
||||
$profiles[] = $attachment->getVirtualId();
|
||||
if ($attachment->getTargetWall() > 0)
|
||||
$profiles[] = $attachment->getTargetWall();
|
||||
else
|
||||
$groups[] = $attachment->getVirtualId();
|
||||
$groups[] = abs($attachment->getTargetWall());
|
||||
if($post->isSigned())
|
||||
$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()) {
|
||||
$actualAuthor = $post->getOwner(false);
|
||||
$signerId = $actualAuthor->getId();
|
||||
}
|
||||
|
||||
$items[] = (object)[
|
||||
$post_temp_obj = (object)[
|
||||
"id" => $post->getVirtualId(),
|
||||
"from_id" => $from_id,
|
||||
"owner_id" => $post->getTargetWall(),
|
||||
"date" => $post->getPublicationTime()->timestamp(),
|
||||
"post_type" => $postType,
|
||||
"post_type" => $post->getVkApiType(),
|
||||
"text" => $post->getText(false),
|
||||
"copy_history" => $repost,
|
||||
"can_edit" => $post->canBeEditedBy($this->getUser()),
|
||||
|
@ -401,8 +355,7 @@ final class Wall extends VKAPIRequestHandler
|
|||
"is_archived" => false,
|
||||
"is_pinned" => $post->isPinned(),
|
||||
"is_explicit" => $post->isExplicit(),
|
||||
"post_source" => $post_source,
|
||||
"signer_id" => $signerId,
|
||||
"post_source" => $post->getPostSourceInfo(),
|
||||
"attachments" => $attachments,
|
||||
"comments" => (object)[
|
||||
"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)
|
||||
$profiles[] = $from_id;
|
||||
else
|
||||
|
@ -792,6 +753,9 @@ final class Wall extends VKAPIRequestHandler
|
|||
]
|
||||
];
|
||||
|
||||
if($comment->isFromPostAuthor($post))
|
||||
$item['is_from_post_author'] = true;
|
||||
|
||||
if($need_likes == true)
|
||||
$item['likes'] = [
|
||||
"can_like" => 1,
|
||||
|
@ -875,6 +839,9 @@ final class Wall extends VKAPIRequestHandler
|
|||
]
|
||||
];
|
||||
|
||||
if($comment->isFromPostAuthor())
|
||||
$item['is_from_post_author'] = true;
|
||||
|
||||
if($extended == true)
|
||||
$profiles[] = $comment->getOwner()->getId();
|
||||
|
||||
|
@ -890,8 +857,6 @@ final class Wall extends VKAPIRequestHandler
|
|||
$response['profiles'] = (!empty($profiles) ? (new Users)->get(implode(',', $profiles), $fields) : []);
|
||||
}
|
||||
|
||||
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
|
|
|
@ -103,6 +103,22 @@ class Comment extends Post
|
|||
|
||||
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()
|
||||
{
|
||||
|
|
|
@ -179,6 +179,31 @@ class Post extends Postable
|
|||
"img" => NULL
|
||||
];
|
||||
}
|
||||
|
||||
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
|
||||
{
|
||||
|
|
|
@ -1224,6 +1224,11 @@ class User extends RowModel
|
|||
return (bool) $this->getRecord()->activated;
|
||||
}
|
||||
|
||||
function isDead(): bool
|
||||
{
|
||||
return $this->onlineStatus() == 2;
|
||||
}
|
||||
|
||||
function getUnbanTime(): ?string
|
||||
{
|
||||
$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_200 = $this->getAvatarURL("normal");
|
||||
$res->photo_id = !is_null($this->getAvatarPhoto()) ? $this->getAvatarPhoto()->getPrettyId() : NULL;
|
||||
# TODO: Perenesti syuda vsyo ostalnoyie
|
||||
|
||||
$res->is_closed = $this->isClosed();
|
||||
|
||||
if(!is_null($user)) {
|
||||
if(!is_null($user))
|
||||
$res->can_access_closed = (bool)$this->canBeViewedBy($user);
|
||||
}
|
||||
|
||||
if($user->isDead())
|
||||
$res->is_dead = 1;
|
||||
|
||||
return $res;
|
||||
}
|
||||
|
|
|
@ -186,8 +186,12 @@ final class VKAPIPresenter extends OpenVKPresenter
|
|||
|
||||
function renderRoute(string $object, string $method): void
|
||||
{
|
||||
$callback = $this->queryParam("callback");
|
||||
$authMechanism = $this->queryParam("auth_mechanism") ?? "token";
|
||||
if($authMechanism === "roaming") {
|
||||
if($callback)
|
||||
$this->fail(-1, "User authorization failed: roaming mechanism is unavailable with jsonp.", $object, $method);
|
||||
|
||||
if(!$this->user->identity)
|
||||
$this->fail(5, "User authorization failed: roaming mechanism is selected, but user is not logged in.", $object, $method);
|
||||
else
|
||||
|
@ -259,10 +263,16 @@ final class VKAPIPresenter extends OpenVKPresenter
|
|||
$result = json_encode([
|
||||
"response" => $res,
|
||||
]);
|
||||
|
||||
if($callback) {
|
||||
$result = $callback . '(' . $result . ')';
|
||||
header('Content-Type: application/javascript');
|
||||
} else
|
||||
header("Content-Type: application/json");
|
||||
|
||||
$size = strlen($result);
|
||||
header("Content-Type: application/json");
|
||||
header("Content-Length: $size");
|
||||
|
||||
exit($result);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue