Skip to content

Commit

Permalink
fix: properly handle public link share deletion
Browse files Browse the repository at this point in the history
IShare::getSharedWith returns null for public links, and so
AlbumMapper::removeFileWithOwner throws a TypeError (500)

Signed-off-by: Varun Patil <varunpatil@ucla.edu>
  • Loading branch information
pulsejet authored and backportbot-nextcloud[bot] committed May 22, 2023
1 parent 76fe329 commit 0e13bd0
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions lib/Listener/AlbumsManagementEventListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,13 @@ public function handle(Event $event): void {
}
} elseif ($event instanceof ShareDeletedEvent) {
$receiverId = $event->getShare()->getSharedWith();
$this->forEachSubNode(
$event->getShare()->getNode(),
// Remove node from any album when the owner is $receiverId.
fn ($node) => $this->albumMapper->removeFileWithOwner($node->getId(), $receiverId),
);
if ($receiverId !== null) { // null for public link shares
$this->forEachSubNode(
$event->getShare()->getNode(),
// Remove node from any album when the owner is $receiverId.
fn ($node) => $this->albumMapper->removeFileWithOwner($node->getId(), $receiverId),
);
}
} elseif ($event instanceof UserRemovedEvent) {
// Get all shared albums for this group:
$albums_group = $this->albumMapper->getSharedAlbumsForCollaborator($event->getGroup()->getGID(), AlbumMapper::TYPE_GROUP);
Expand Down

0 comments on commit 0e13bd0

Please sign in to comment.