Skip to content

Commit

Permalink
wall: fix 500 when no user
Browse files Browse the repository at this point in the history
  • Loading branch information
mrilyew committed Nov 2, 2024
1 parent 9b53839 commit 341226c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
5 changes: 4 additions & 1 deletion Web/Models/Entities/Comment.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,11 @@ function getOwner(bool $honourFlags = true, bool $real = false): RowModel
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) ||
Expand Down
10 changes: 8 additions & 2 deletions Web/Models/Entities/Post.php
Original file line number Diff line number Diff line change
Expand Up @@ -260,16 +260,22 @@ function unpin(): void
$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;

Expand Down

0 comments on commit 341226c

Please sign in to comment.