Completed
Push — master ( ce1082...44be41 )
by
unknown
22:16 queued 18s
created
lib/private/Encryption/EncryptionEventListener.php 1 patch
Indentation   +62 added lines, -62 removed lines patch added patch discarded remove patch
@@ -27,74 +27,74 @@
 block discarded – undo
27 27
 
28 28
 /** @template-implements IEventListener<NodeRenamedEvent|ShareCreatedEvent|ShareDeletedEvent|NodeRestoredEvent> */
29 29
 class EncryptionEventListener implements IEventListener {
30
-	private ?Update $updater = null;
30
+    private ?Update $updater = null;
31 31
 
32
-	public function __construct(
33
-		private IUserSession $userSession,
34
-		private SetupManager $setupManager,
35
-		private Manager $encryptionManager,
36
-		private IUserManager $userManager,
37
-	) {
38
-	}
32
+    public function __construct(
33
+        private IUserSession $userSession,
34
+        private SetupManager $setupManager,
35
+        private Manager $encryptionManager,
36
+        private IUserManager $userManager,
37
+    ) {
38
+    }
39 39
 
40
-	public static function register(IEventDispatcher $dispatcher): void {
41
-		$dispatcher->addServiceListener(NodeRenamedEvent::class, static::class);
42
-		$dispatcher->addServiceListener(ShareCreatedEvent::class, static::class);
43
-		$dispatcher->addServiceListener(ShareDeletedEvent::class, static::class);
44
-		$dispatcher->addServiceListener(NodeRestoredEvent::class, static::class);
45
-	}
40
+    public static function register(IEventDispatcher $dispatcher): void {
41
+        $dispatcher->addServiceListener(NodeRenamedEvent::class, static::class);
42
+        $dispatcher->addServiceListener(ShareCreatedEvent::class, static::class);
43
+        $dispatcher->addServiceListener(ShareDeletedEvent::class, static::class);
44
+        $dispatcher->addServiceListener(NodeRestoredEvent::class, static::class);
45
+    }
46 46
 
47
-	public function handle(Event $event): void {
48
-		if (!$this->encryptionManager->isEnabled()) {
49
-			return;
50
-		}
51
-		if ($event instanceof NodeRenamedEvent) {
52
-			$this->getUpdate()->postRename($event->getSource(), $event->getTarget());
53
-		} elseif ($event instanceof ShareCreatedEvent) {
54
-			$this->getUpdate()->postShared($event->getShare()->getNode());
55
-		} elseif ($event instanceof ShareDeletedEvent) {
56
-			try {
57
-				// In case the unsharing happens in a background job, we don't have
58
-				// a session and we load instead the user from the UserManager
59
-				$owner = $this->userManager->get($event->getShare()->getShareOwner());
60
-				$this->getUpdate($owner)->postUnshared($event->getShare()->getNode());
61
-			} catch (NotFoundException $e) {
62
-				/* The node was deleted already, nothing to update */
63
-			}
64
-		} elseif ($event instanceof NodeRestoredEvent) {
65
-			$this->getUpdate()->postRestore($event->getTarget());
66
-		}
67
-	}
47
+    public function handle(Event $event): void {
48
+        if (!$this->encryptionManager->isEnabled()) {
49
+            return;
50
+        }
51
+        if ($event instanceof NodeRenamedEvent) {
52
+            $this->getUpdate()->postRename($event->getSource(), $event->getTarget());
53
+        } elseif ($event instanceof ShareCreatedEvent) {
54
+            $this->getUpdate()->postShared($event->getShare()->getNode());
55
+        } elseif ($event instanceof ShareDeletedEvent) {
56
+            try {
57
+                // In case the unsharing happens in a background job, we don't have
58
+                // a session and we load instead the user from the UserManager
59
+                $owner = $this->userManager->get($event->getShare()->getShareOwner());
60
+                $this->getUpdate($owner)->postUnshared($event->getShare()->getNode());
61
+            } catch (NotFoundException $e) {
62
+                /* The node was deleted already, nothing to update */
63
+            }
64
+        } elseif ($event instanceof NodeRestoredEvent) {
65
+            $this->getUpdate()->postRestore($event->getTarget());
66
+        }
67
+    }
68 68
 
69
-	private function getUpdate(?IUser $owner = null): Update {
70
-		if (is_null($this->updater)) {
71
-			$user = $this->userSession->getUser();
72
-			if (!$user && ($owner !== null)) {
73
-				$user = $owner;
74
-			}
75
-			if (!$user) {
76
-				throw new \Exception('Inconsistent data, File unshared, but owner not found. Should not happen');
77
-			}
69
+    private function getUpdate(?IUser $owner = null): Update {
70
+        if (is_null($this->updater)) {
71
+            $user = $this->userSession->getUser();
72
+            if (!$user && ($owner !== null)) {
73
+                $user = $owner;
74
+            }
75
+            if (!$user) {
76
+                throw new \Exception('Inconsistent data, File unshared, but owner not found. Should not happen');
77
+            }
78 78
 
79
-			$uid = $user->getUID();
79
+            $uid = $user->getUID();
80 80
 
81
-			if (!$this->setupManager->isSetupComplete($user)) {
82
-				$this->setupManager->setupForUser($user);
83
-			}
81
+            if (!$this->setupManager->isSetupComplete($user)) {
82
+                $this->setupManager->setupForUser($user);
83
+            }
84 84
 
85
-			$this->updater = new Update(
86
-				new Util(
87
-					new View(),
88
-					$this->userManager,
89
-					\OC::$server->getGroupManager(),
90
-					\OC::$server->getConfig()),
91
-				\OC::$server->getEncryptionManager(),
92
-				\OC::$server->get(IFile::class),
93
-				\OC::$server->get(LoggerInterface::class),
94
-				$uid
95
-			);
96
-		}
85
+            $this->updater = new Update(
86
+                new Util(
87
+                    new View(),
88
+                    $this->userManager,
89
+                    \OC::$server->getGroupManager(),
90
+                    \OC::$server->getConfig()),
91
+                \OC::$server->getEncryptionManager(),
92
+                \OC::$server->get(IFile::class),
93
+                \OC::$server->get(LoggerInterface::class),
94
+                $uid
95
+            );
96
+        }
97 97
 
98
-		return $this->updater;
99
-	}
98
+        return $this->updater;
99
+    }
100 100
 }
Please login to merge, or discard this patch.