diff --git a/lib/Listener/ShareLinkAccessedListener.php b/lib/Listener/ShareLinkAccessedListener.php index 2f9f460..a6637b7 100644 --- a/lib/Listener/ShareLinkAccessedListener.php +++ b/lib/Listener/ShareLinkAccessedListener.php @@ -33,6 +33,7 @@ use OCP\EventDispatcher\IEventListener; use OCP\IConfig; use OCP\Share\IManager; +use Psr\Log\LoggerInterface; /** @template-implements IEventListener */ class ShareLinkAccessedListener implements IEventListener { @@ -40,6 +41,7 @@ public function __construct( private IConfig $config, private IManager $manager, private LimitMapper $mapper, + private LoggerInterface $logger ) { } @@ -53,8 +55,12 @@ public function handle(Event $event): void { return; } - // Make sure we have a valid limit $token = $event->getShare()->getToken(); + if ($token === null) { + return; + } + + // Make sure we have a valid limit try { $shareLimit = $this->mapper->get($token); $limit = $shareLimit->getLimit(); @@ -76,6 +82,8 @@ public function handle(Event $event): void { $this->mapper->update($shareLimit); } catch (DoesNotExistException $e) { // No limit is set, ignore + } catch (\Exception $e) { + $this->logger->error('Error while handling share link accessed event: ' . $e->getMessage()); } } }