mirror of
https://github.com/openvk/openvk
synced 2024-11-14 19:19:14 +03:00
wall: fix 500 when no user
This commit is contained in:
parent
9b53839192
commit
341226cac5
2 changed files with 12 additions and 3 deletions
|
@ -46,8 +46,11 @@ class Comment extends Post
|
|||
return parent::getOwner($honourFlags, $real);
|
||||
}
|
||||
|
||||
function canBeDeletedBy(User $user): bool
|
||||
function canBeDeletedBy(User $user = NULL): bool
|
||||
{
|
||||
if(!$user)
|
||||
return false;
|
||||
|
||||
return $this->getOwner()->getId() == $user->getId() ||
|
||||
$this->getTarget()->getOwner()->getId() == $user->getId() ||
|
||||
$this->getTarget() instanceof Post && $this->getTarget()->getTargetWall() < 0 && (new Clubs)->get(abs($this->getTarget()->getTargetWall()))->canBeModifiedBy($user) ||
|
||||
|
|
|
@ -260,16 +260,22 @@ class Post extends Postable
|
|||
$this->save();
|
||||
}
|
||||
|
||||
function canBePinnedBy(User $user): bool
|
||||
function canBePinnedBy(User $user = NULL): bool
|
||||
{
|
||||
if(!$user)
|
||||
return false;
|
||||
|
||||
if($this->getTargetWall() < 0)
|
||||
return (new Clubs)->get(abs($this->getTargetWall()))->canBeModifiedBy($user);
|
||||
|
||||
return $this->getTargetWall() === $user->getId();
|
||||
}
|
||||
|
||||
function canBeDeletedBy(User $user): bool
|
||||
function canBeDeletedBy(User $user = NULL): bool
|
||||
{
|
||||
if(!$user)
|
||||
return false;
|
||||
|
||||
if($this->getTargetWall() < 0 && !$this->getWallOwner()->canBeModifiedBy($user) && $this->getWallOwner()->getWallType() != 1 && $this->getSuggestionType() == 0)
|
||||
return false;
|
||||
|
||||
|
|
Loading…
Reference in a new issue