From 0acd2a4e6f589bcbb428f7c7df9b1843de5a1b9d Mon Sep 17 00:00:00 2001
From: Robin Appelman <robin@icewind.nl>
Date: Thu, 9 Dec 2021 17:38:14 +0100
Subject: [PATCH] dont send notifications for files we know are outside the
 users view

Signed-off-by: Robin Appelman <robin@icewind.nl>
---
 lib/Listener.php | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/lib/Listener.php b/lib/Listener.php
index 3fe79b6..6adc075 100644
--- a/lib/Listener.php
+++ b/lib/Listener.php
@@ -28,6 +28,7 @@ use OCP\Activity\IConsumer;
 use OCP\Activity\IEvent;
 use OCP\EventDispatcher\Event;
 use OCP\Files\Cache\ICacheEvent;
+use OCP\Files\IHomeStorage;
 use OCP\Group\Events\UserAddedEvent;
 use OCP\Group\Events\UserRemovedEvent;
 use OCP\Notification\IApp;
@@ -46,6 +47,18 @@ class Listener implements IConsumer, IApp, INotifier, IDismissableNotifier {
 
 	public function cacheListener(Event $event): void {
 		if ($event instanceof ICacheEvent) {
+			// ignore files in home storage but outside home directory (trashbin, versions, etc)
+			if (
+				$event->getStorage()->instanceOfStorage(IHomeStorage::class) && !(
+					$event->getPath() === 'files' || str_starts_with($event->getPath(), "files/")
+				)
+			) {
+				return;
+			}
+			// ignore appdata
+			if (str_starts_with($event->getPath(), 'appdata_')) {
+				return;
+			}
 			$this->queue->push('notify_storage_update', [
 				'storage' => $event->getStorageId(),
 				'path' => $event->getPath(),
-- 
GitLab