mirror of
https://github.com/openvk/openvk
synced 2025-07-07 00:09:48 +03:00
FIX NEWSFEED and polls
This commit is contained in:
parent
8495f493d0
commit
8b857b9f15
5 changed files with 28 additions and 10 deletions
|
@ -51,8 +51,8 @@ final class Newsfeed extends VKAPIRequestHandler
|
|||
{
|
||||
$this->requireUser();
|
||||
|
||||
$queryBase = "FROM `posts` JOIN `profiles` ON `profiles`.`id` = ABS(`posts`.`wall`) LEFT JOIN `groups` ON GREATEST(`posts`.`wall`, 0) = 0 AND `groups`.`id` = ABS(`posts`.`wall`)";
|
||||
$queryBase .= "WHERE (`profiles`.`profile_type` = 0 OR `profiles`.`first_name` IS NULL) AND (`groups`.`hide_from_global_feed` = 0 OR `groups`.`name` IS NULL) AND `posts`.`deleted` = 0";
|
||||
$queryBase = "FROM `posts` LEFT JOIN `groups` ON GREATEST(`posts`.`wall`, 0) = 0 AND `groups`.`id` = ABS(`posts`.`wall`) LEFT JOIN `profiles` ON LEAST(`posts`.`wall`, 0) = 0 AND `profiles`.`id` = ABS(`posts`.`wall`)";
|
||||
$queryBase .= "WHERE (`groups`.`hide_from_global_feed` = 0 OR `groups`.`name` IS NULL) AND (`profiles`.`profile_type` = 0 OR `profiles`.`first_name` IS NULL) AND `posts`.`deleted` = 0";
|
||||
|
||||
if($this->getUser()->getNsfwTolerance() === User::NSFW_INTOLERANT)
|
||||
$queryBase .= " AND `nsfw` = 0";
|
||||
|
|
|
@ -35,7 +35,11 @@ final class Polls extends VKAPIRequestHandler
|
|||
foreach($poll->getUserVote($this->getUser()) as $vote)
|
||||
$userVote[] = $vote[0];
|
||||
|
||||
$ownerr = 0;
|
||||
if(!is_null($poll->getAttachedPost())) {
|
||||
$ownerr = $poll->getAttachedPost()->getOwner() instanceof User ? $poll->getAttachedPost()->getOwner()->getId() : $poll->getAttachedPost()->getOwner()->getId() * -1;
|
||||
}
|
||||
|
||||
$response = [
|
||||
"multiple" => $poll->isMultipleChoice(),
|
||||
"end_date" => $poll->endsAt() == NULL ? 0 : $poll->endsAt()->timestamp(),
|
||||
|
@ -45,7 +49,7 @@ final class Polls extends VKAPIRequestHandler
|
|||
"can_vote" => $poll->canVote($this->getUser()),
|
||||
"can_report" => false,
|
||||
"can_share" => true,
|
||||
"created" => $poll->getAttachedPost()->getPublicationTime()->timestamp(),
|
||||
"created" => $poll->getAttachedPost() ? $poll->getAttachedPost()->getPublicationTime()->timestamp() : 0,
|
||||
"id" => $poll->getId(),
|
||||
"owner_id" => $ownerr,
|
||||
"question" => $poll->getTitle(),
|
||||
|
|
|
@ -879,7 +879,12 @@ final class Wall extends VKAPIRequestHandler
|
|||
foreach($attachment->getUserVote($user) as $vote)
|
||||
$userVote[] = $vote[0];
|
||||
|
||||
$ownerr = 0;
|
||||
|
||||
if(!is_null($attachment->getAttachedPost())) {
|
||||
$ownerr = $attachment->getAttachedPost()->getOwner() instanceof User ? $attachment->getAttachedPost()->getOwner()->getId() : $attachment->getAttachedPost()->getOwner()->getId() * -1;
|
||||
}
|
||||
|
||||
return [
|
||||
"type" => "poll",
|
||||
"poll" => [
|
||||
|
@ -891,7 +896,7 @@ final class Wall extends VKAPIRequestHandler
|
|||
"can_vote" => $attachment->canVote($user),
|
||||
"can_report" => false,
|
||||
"can_share" => true,
|
||||
"created" => $attachment->getAttachedPost()->getPublicationTime()->timestamp(),
|
||||
"created" => $attachment->getAttachedPost() ? $attachment->getAttachedPost()->getPublicationTime()->timestamp() : 0,
|
||||
"id" => $attachment->getId(),
|
||||
"owner_id" => $ownerr,
|
||||
"question" => $attachment->getTitle(),
|
||||
|
|
|
@ -300,11 +300,20 @@ class Poll extends Attachable
|
|||
["attachable_type" => static::class,
|
||||
"attachable_id" => $this->getId()])->fetch();
|
||||
|
||||
if(!is_null($post->target_id)) {
|
||||
return (new Posts)->get($post->target_id);
|
||||
} else {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
function canBeViewedBy(?User $user = NULL): bool
|
||||
{
|
||||
if(!is_null($this->getAttachedPost())) {
|
||||
return $this->getAttachedPost()->canBeViewedBy($user);
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -177,8 +177,8 @@ final class WallPresenter extends OpenVKPresenter
|
|||
$page = (int) ($_GET["p"] ?? 1);
|
||||
$pPage = min((int) ($_GET["posts"] ?? OPENVK_DEFAULT_PER_PAGE), 50);
|
||||
|
||||
$queryBase = "FROM `posts` JOIN `profiles` ON `profiles`.`id` = ABS(`posts`.`wall`) LEFT JOIN `groups` ON GREATEST(`posts`.`wall`, 0) = 0 AND `groups`.`id` = ABS(`posts`.`wall`)";
|
||||
$queryBase .= "WHERE (`profiles`.`profile_type` = 0 OR `profiles`.`first_name` IS NULL) AND (`groups`.`hide_from_global_feed` = 0 OR `groups`.`name` IS NULL) AND `posts`.`deleted` = 0";
|
||||
$queryBase = "FROM `posts` LEFT JOIN `groups` ON GREATEST(`posts`.`wall`, 0) = 0 AND `groups`.`id` = ABS(`posts`.`wall`) LEFT JOIN `profiles` ON LEAST(`posts`.`wall`, 0) = 0 AND `profiles`.`id` = ABS(`posts`.`wall`)";
|
||||
$queryBase .= "WHERE (`groups`.`hide_from_global_feed` = 0 OR `groups`.`name` IS NULL) AND (`profiles`.`profile_type` = 0 OR `profiles`.`first_name` IS NULL) AND `posts`.`deleted` = 0";
|
||||
|
||||
if($this->user->identity->getNsfwTolerance() === User::NSFW_INTOLERANT)
|
||||
$queryBase .= " AND `nsfw` = 0";
|
||||
|
|
Loading…
Reference in a new issue