Completed
Push — master ( 247b25...4111bd )
by Thomas
26:36 queued 10s
created
core/Migrations/Version21000Date20210309185127.php 1 patch
Indentation   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -31,22 +31,22 @@
 block discarded – undo
31 31
 use OCP\Migration\SimpleMigrationStep;
32 32
 
33 33
 class Version21000Date20210309185127 extends SimpleMigrationStep {
34
-	/**
35
-	 * @param IOutput $output
36
-	 * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
37
-	 * @param array $options
38
-	 * @return null|ISchemaWrapper
39
-	 */
40
-	public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper {
41
-		/** @var ISchemaWrapper $schema */
42
-		$schema = $schemaClosure();
34
+    /**
35
+     * @param IOutput $output
36
+     * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
37
+     * @param array $options
38
+     * @return null|ISchemaWrapper
39
+     */
40
+    public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper {
41
+        /** @var ISchemaWrapper $schema */
42
+        $schema = $schemaClosure();
43 43
 
44
-		$table = $schema->getTable('known_users');
45
-		if (!$table->hasIndex('ku_known_user')) {
46
-			$table->addIndex(['known_user'], 'ku_known_user');
47
-			return $schema;
48
-		}
44
+        $table = $schema->getTable('known_users');
45
+        if (!$table->hasIndex('ku_known_user')) {
46
+            $table->addIndex(['known_user'], 'ku_known_user');
47
+            return $schema;
48
+        }
49 49
 
50
-		return null;
51
-	}
50
+        return null;
51
+    }
52 52
 }
Please login to merge, or discard this patch.
core/Command/Preview/ResetRenderedTexts.php 2 patches
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
 		$avatarsToDeleteCount = 0;
96 96
 
97 97
 		foreach ($this->getAvatarsToDelete() as [$userId, $avatar]) {
98
-			$output->writeln('Deleting avatar for ' . $userId, OutputInterface::VERBOSITY_VERBOSE);
98
+			$output->writeln('Deleting avatar for '.$userId, OutputInterface::VERBOSITY_VERBOSE);
99 99
 
100 100
 			$avatarsToDeleteCount++;
101 101
 
@@ -112,7 +112,7 @@  discard block
 block discarded – undo
112 112
 			}
113 113
 		}
114 114
 
115
-		$output->writeln('Deleted ' . $avatarsToDeleteCount . ' avatars');
115
+		$output->writeln('Deleted '.$avatarsToDeleteCount.' avatars');
116 116
 		$output->writeln('');
117 117
 	}
118 118
 
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
 		$previewsToDeleteCount = 0;
131 131
 
132 132
 		foreach ($this->getPreviewsToDelete() as ['name' => $previewFileId, 'path' => $filePath]) {
133
-			$output->writeln('Deleting previews for ' . $filePath, OutputInterface::VERBOSITY_VERBOSE);
133
+			$output->writeln('Deleting previews for '.$filePath, OutputInterface::VERBOSITY_VERBOSE);
134 134
 
135 135
 			$previewsToDeleteCount++;
136 136
 
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
 			}
140 140
 
141 141
 			try {
142
-				$preview = $this->previewFolder->getFolder((string)$previewFileId);
142
+				$preview = $this->previewFolder->getFolder((string) $previewFileId);
143 143
 				$preview->delete();
144 144
 			} catch (NotFoundException $e) {
145 145
 				// continue
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
 			}
149 149
 		}
150 150
 
151
-		$output->writeln('Deleted ' . $previewsToDeleteCount . ' previews');
151
+		$output->writeln('Deleted '.$previewsToDeleteCount.' previews');
152 152
 	}
153 153
 
154 154
 	// Copy pasted and adjusted from
@@ -171,7 +171,7 @@  discard block
 block discarded – undo
171 171
 		 * We take the md5 of the name (fileid) and split the first 7 chars. That way
172 172
 		 * there are not a gazillion files in the root of the preview appdata.
173 173
 		 */
174
-		$like = $this->connection->escapeLikeParameter($data['path']) . '/_/_/_/_/_/_/_/%';
174
+		$like = $this->connection->escapeLikeParameter($data['path']).'/_/_/_/_/_/_/_/%';
175 175
 
176 176
 		$qb = $this->connection->getQueryBuilder();
177 177
 		$qb->select('a.name', 'b.path')
Please login to merge, or discard this patch.
Indentation   +135 added lines, -135 removed lines patch added patch discarded remove patch
@@ -22,143 +22,143 @@
 block discarded – undo
22 22
 use Symfony\Component\Console\Output\OutputInterface;
23 23
 
24 24
 class ResetRenderedTexts extends Command {
25
-	public function __construct(
26
-		protected IDBConnection $connection,
27
-		protected IUserManager $userManager,
28
-		protected IAvatarManager $avatarManager,
29
-		private Root $previewFolder,
30
-		private IMimeTypeLoader $mimeTypeLoader,
31
-	) {
32
-		parent::__construct();
33
-	}
34
-
35
-	protected function configure() {
36
-		$this
37
-			->setName('preview:reset-rendered-texts')
38
-			->setDescription('Deletes all generated avatars and previews of text and md files')
39
-			->addOption('dry', 'd', InputOption::VALUE_NONE, 'Dry mode - will not delete any files - in combination with the verbose mode one could check the operations.');
40
-	}
41
-
42
-	protected function execute(InputInterface $input, OutputInterface $output): int {
43
-		$dryMode = $input->getOption('dry');
44
-
45
-		if ($dryMode) {
46
-			$output->writeln('INFO: The command is run in dry mode and will not modify anything.');
47
-			$output->writeln('');
48
-		}
49
-
50
-		$this->deleteAvatars($output, $dryMode);
51
-		$this->deletePreviews($output, $dryMode);
52
-
53
-		return 0;
54
-	}
55
-
56
-	private function deleteAvatars(OutputInterface $output, bool $dryMode): void {
57
-		$avatarsToDeleteCount = 0;
58
-
59
-		foreach ($this->getAvatarsToDelete() as [$userId, $avatar]) {
60
-			$output->writeln('Deleting avatar for ' . $userId, OutputInterface::VERBOSITY_VERBOSE);
61
-
62
-			$avatarsToDeleteCount++;
63
-
64
-			if ($dryMode) {
65
-				continue;
66
-			}
67
-
68
-			try {
69
-				$avatar->remove();
70
-			} catch (NotFoundException $e) {
71
-				// continue
72
-			} catch (NotPermittedException $e) {
73
-				// continue
74
-			}
75
-		}
76
-
77
-		$output->writeln('Deleted ' . $avatarsToDeleteCount . ' avatars');
78
-		$output->writeln('');
79
-	}
80
-
81
-	private function getAvatarsToDelete(): \Iterator {
82
-		foreach ($this->userManager->search('') as $user) {
83
-			$avatar = $this->avatarManager->getAvatar($user->getUID());
84
-
85
-			if (!$avatar->isCustomAvatar()) {
86
-				yield [$user->getUID(), $avatar];
87
-			}
88
-		}
89
-	}
90
-
91
-	private function deletePreviews(OutputInterface $output, bool $dryMode): void {
92
-		$previewsToDeleteCount = 0;
93
-
94
-		foreach ($this->getPreviewsToDelete() as ['name' => $previewFileId, 'path' => $filePath]) {
95
-			$output->writeln('Deleting previews for ' . $filePath, OutputInterface::VERBOSITY_VERBOSE);
96
-
97
-			$previewsToDeleteCount++;
98
-
99
-			if ($dryMode) {
100
-				continue;
101
-			}
102
-
103
-			try {
104
-				$preview = $this->previewFolder->getFolder((string)$previewFileId);
105
-				$preview->delete();
106
-			} catch (NotFoundException $e) {
107
-				// continue
108
-			} catch (NotPermittedException $e) {
109
-				// continue
110
-			}
111
-		}
112
-
113
-		$output->writeln('Deleted ' . $previewsToDeleteCount . ' previews');
114
-	}
115
-
116
-	// Copy pasted and adjusted from
117
-	// "lib/private/Preview/BackgroundCleanupJob.php".
118
-	private function getPreviewsToDelete(): \Iterator {
119
-		$qb = $this->connection->getQueryBuilder();
120
-		$qb->select('path', 'mimetype')
121
-			->from('filecache')
122
-			->where($qb->expr()->eq('fileid', $qb->createNamedParameter($this->previewFolder->getId())));
123
-		$cursor = $qb->executeQuery();
124
-		$data = $cursor->fetch();
125
-		$cursor->closeCursor();
126
-
127
-		if ($data === null) {
128
-			return [];
129
-		}
130
-
131
-		/*
25
+    public function __construct(
26
+        protected IDBConnection $connection,
27
+        protected IUserManager $userManager,
28
+        protected IAvatarManager $avatarManager,
29
+        private Root $previewFolder,
30
+        private IMimeTypeLoader $mimeTypeLoader,
31
+    ) {
32
+        parent::__construct();
33
+    }
34
+
35
+    protected function configure() {
36
+        $this
37
+            ->setName('preview:reset-rendered-texts')
38
+            ->setDescription('Deletes all generated avatars and previews of text and md files')
39
+            ->addOption('dry', 'd', InputOption::VALUE_NONE, 'Dry mode - will not delete any files - in combination with the verbose mode one could check the operations.');
40
+    }
41
+
42
+    protected function execute(InputInterface $input, OutputInterface $output): int {
43
+        $dryMode = $input->getOption('dry');
44
+
45
+        if ($dryMode) {
46
+            $output->writeln('INFO: The command is run in dry mode and will not modify anything.');
47
+            $output->writeln('');
48
+        }
49
+
50
+        $this->deleteAvatars($output, $dryMode);
51
+        $this->deletePreviews($output, $dryMode);
52
+
53
+        return 0;
54
+    }
55
+
56
+    private function deleteAvatars(OutputInterface $output, bool $dryMode): void {
57
+        $avatarsToDeleteCount = 0;
58
+
59
+        foreach ($this->getAvatarsToDelete() as [$userId, $avatar]) {
60
+            $output->writeln('Deleting avatar for ' . $userId, OutputInterface::VERBOSITY_VERBOSE);
61
+
62
+            $avatarsToDeleteCount++;
63
+
64
+            if ($dryMode) {
65
+                continue;
66
+            }
67
+
68
+            try {
69
+                $avatar->remove();
70
+            } catch (NotFoundException $e) {
71
+                // continue
72
+            } catch (NotPermittedException $e) {
73
+                // continue
74
+            }
75
+        }
76
+
77
+        $output->writeln('Deleted ' . $avatarsToDeleteCount . ' avatars');
78
+        $output->writeln('');
79
+    }
80
+
81
+    private function getAvatarsToDelete(): \Iterator {
82
+        foreach ($this->userManager->search('') as $user) {
83
+            $avatar = $this->avatarManager->getAvatar($user->getUID());
84
+
85
+            if (!$avatar->isCustomAvatar()) {
86
+                yield [$user->getUID(), $avatar];
87
+            }
88
+        }
89
+    }
90
+
91
+    private function deletePreviews(OutputInterface $output, bool $dryMode): void {
92
+        $previewsToDeleteCount = 0;
93
+
94
+        foreach ($this->getPreviewsToDelete() as ['name' => $previewFileId, 'path' => $filePath]) {
95
+            $output->writeln('Deleting previews for ' . $filePath, OutputInterface::VERBOSITY_VERBOSE);
96
+
97
+            $previewsToDeleteCount++;
98
+
99
+            if ($dryMode) {
100
+                continue;
101
+            }
102
+
103
+            try {
104
+                $preview = $this->previewFolder->getFolder((string)$previewFileId);
105
+                $preview->delete();
106
+            } catch (NotFoundException $e) {
107
+                // continue
108
+            } catch (NotPermittedException $e) {
109
+                // continue
110
+            }
111
+        }
112
+
113
+        $output->writeln('Deleted ' . $previewsToDeleteCount . ' previews');
114
+    }
115
+
116
+    // Copy pasted and adjusted from
117
+    // "lib/private/Preview/BackgroundCleanupJob.php".
118
+    private function getPreviewsToDelete(): \Iterator {
119
+        $qb = $this->connection->getQueryBuilder();
120
+        $qb->select('path', 'mimetype')
121
+            ->from('filecache')
122
+            ->where($qb->expr()->eq('fileid', $qb->createNamedParameter($this->previewFolder->getId())));
123
+        $cursor = $qb->executeQuery();
124
+        $data = $cursor->fetch();
125
+        $cursor->closeCursor();
126
+
127
+        if ($data === null) {
128
+            return [];
129
+        }
130
+
131
+        /*
132 132
 		 * This lovely like is the result of the way the new previews are stored
133 133
 		 * We take the md5 of the name (fileid) and split the first 7 chars. That way
134 134
 		 * there are not a gazillion files in the root of the preview appdata.
135 135
 		 */
136
-		$like = $this->connection->escapeLikeParameter($data['path']) . '/_/_/_/_/_/_/_/%';
137
-
138
-		$qb = $this->connection->getQueryBuilder();
139
-		$qb->select('a.name', 'b.path')
140
-			->from('filecache', 'a')
141
-			->leftJoin('a', 'filecache', 'b', $qb->expr()->eq(
142
-				$qb->expr()->castColumn('a.name', IQueryBuilder::PARAM_INT), 'b.fileid'
143
-			))
144
-			->where(
145
-				$qb->expr()->andX(
146
-					$qb->expr()->like('a.path', $qb->createNamedParameter($like)),
147
-					$qb->expr()->eq('a.mimetype', $qb->createNamedParameter($this->mimeTypeLoader->getId('httpd/unix-directory'))),
148
-					$qb->expr()->orX(
149
-						$qb->expr()->eq('b.mimetype', $qb->createNamedParameter($this->mimeTypeLoader->getId('text/plain'))),
150
-						$qb->expr()->eq('b.mimetype', $qb->createNamedParameter($this->mimeTypeLoader->getId('text/markdown'))),
151
-						$qb->expr()->eq('b.mimetype', $qb->createNamedParameter($this->mimeTypeLoader->getId('text/x-markdown')))
152
-					)
153
-				)
154
-			);
155
-
156
-		$cursor = $qb->executeQuery();
157
-
158
-		while ($row = $cursor->fetch()) {
159
-			yield $row;
160
-		}
161
-
162
-		$cursor->closeCursor();
163
-	}
136
+        $like = $this->connection->escapeLikeParameter($data['path']) . '/_/_/_/_/_/_/_/%';
137
+
138
+        $qb = $this->connection->getQueryBuilder();
139
+        $qb->select('a.name', 'b.path')
140
+            ->from('filecache', 'a')
141
+            ->leftJoin('a', 'filecache', 'b', $qb->expr()->eq(
142
+                $qb->expr()->castColumn('a.name', IQueryBuilder::PARAM_INT), 'b.fileid'
143
+            ))
144
+            ->where(
145
+                $qb->expr()->andX(
146
+                    $qb->expr()->like('a.path', $qb->createNamedParameter($like)),
147
+                    $qb->expr()->eq('a.mimetype', $qb->createNamedParameter($this->mimeTypeLoader->getId('httpd/unix-directory'))),
148
+                    $qb->expr()->orX(
149
+                        $qb->expr()->eq('b.mimetype', $qb->createNamedParameter($this->mimeTypeLoader->getId('text/plain'))),
150
+                        $qb->expr()->eq('b.mimetype', $qb->createNamedParameter($this->mimeTypeLoader->getId('text/markdown'))),
151
+                        $qb->expr()->eq('b.mimetype', $qb->createNamedParameter($this->mimeTypeLoader->getId('text/x-markdown')))
152
+                    )
153
+                )
154
+            );
155
+
156
+        $cursor = $qb->executeQuery();
157
+
158
+        while ($row = $cursor->fetch()) {
159
+            yield $row;
160
+        }
161
+
162
+        $cursor->closeCursor();
163
+    }
164 164
 }
Please login to merge, or discard this patch.
apps/comments/lib/MaxAutoCompleteResultsInitialState.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -43,6 +43,6 @@
 block discarded – undo
43 43
 	}
44 44
 
45 45
 	public function getData(): int {
46
-		return (int)$this->config->getAppValue('comments', 'maxAutoCompleteResults', '10');
46
+		return (int) $this->config->getAppValue('comments', 'maxAutoCompleteResults', '10');
47 47
 	}
48 48
 }
Please login to merge, or discard this patch.
Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -12,16 +12,16 @@
 block discarded – undo
12 12
 use OCP\IConfig;
13 13
 
14 14
 class MaxAutoCompleteResultsInitialState extends InitialStateProvider {
15
-	public function __construct(
16
-		private IConfig $config,
17
-	) {
18
-	}
15
+    public function __construct(
16
+        private IConfig $config,
17
+    ) {
18
+    }
19 19
 
20
-	public function getKey(): string {
21
-		return 'maxAutoCompleteResults';
22
-	}
20
+    public function getKey(): string {
21
+        return 'maxAutoCompleteResults';
22
+    }
23 23
 
24
-	public function getData(): int {
25
-		return (int)$this->config->getAppValue('comments', 'maxAutoCompleteResults', '10');
26
-	}
24
+    public function getData(): int {
25
+        return (int)$this->config->getAppValue('comments', 'maxAutoCompleteResults', '10');
26
+    }
27 27
 }
Please login to merge, or discard this patch.
apps/twofactor_backupcodes/lib/Migration/Version1002Date20170919123342.php 1 patch
Indentation   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -36,27 +36,27 @@
 block discarded – undo
36 36
 
37 37
 class Version1002Date20170919123342 extends SimpleMigrationStep {
38 38
 
39
-	/**
40
-	 * @param IOutput $output
41
-	 * @param \Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
42
-	 * @param array $options
43
-	 * @return null|ISchemaWrapper
44
-	 * @since 13.0.0
45
-	 */
46
-	public function changeSchema(IOutput $output, \Closure $schemaClosure, array $options) {
47
-		/** @var ISchemaWrapper $schema */
48
-		$schema = $schemaClosure();
49
-
50
-		$table = $schema->getTable('twofactor_backupcodes');
51
-		$column = $table->getColumn('user_id');
52
-		$column->setDefault('');
53
-
54
-		$column = $table->getColumn('used');
55
-		if ($column->getType()->getName() !== Types::SMALLINT) {
56
-			$column->setType(Type::getType(Types::SMALLINT));
57
-			$column->setOptions(['length' => 6]);
58
-		}
59
-
60
-		return $schema;
61
-	}
39
+    /**
40
+     * @param IOutput $output
41
+     * @param \Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
42
+     * @param array $options
43
+     * @return null|ISchemaWrapper
44
+     * @since 13.0.0
45
+     */
46
+    public function changeSchema(IOutput $output, \Closure $schemaClosure, array $options) {
47
+        /** @var ISchemaWrapper $schema */
48
+        $schema = $schemaClosure();
49
+
50
+        $table = $schema->getTable('twofactor_backupcodes');
51
+        $column = $table->getColumn('user_id');
52
+        $column->setDefault('');
53
+
54
+        $column = $table->getColumn('used');
55
+        if ($column->getType()->getName() !== Types::SMALLINT) {
56
+            $column->setType(Type::getType(Types::SMALLINT));
57
+            $column->setOptions(['length' => 6]);
58
+        }
59
+
60
+        return $schema;
61
+    }
62 62
 }
Please login to merge, or discard this patch.
apps/twofactor_backupcodes/composer/composer/autoload_static.php 1 patch
Spacing   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -6,51 +6,51 @@
 block discarded – undo
6 6
 
7 7
 class ComposerStaticInitTwoFactorBackupCodes
8 8
 {
9
-    public static $prefixLengthsPsr4 = array (
9
+    public static $prefixLengthsPsr4 = array(
10 10
         'O' => 
11
-        array (
11
+        array(
12 12
             'OCA\\TwoFactorBackupCodes\\' => 25,
13 13
         ),
14 14
     );
15 15
 
16
-    public static $prefixDirsPsr4 = array (
16
+    public static $prefixDirsPsr4 = array(
17 17
         'OCA\\TwoFactorBackupCodes\\' => 
18
-        array (
19
-            0 => __DIR__ . '/..' . '/../lib',
18
+        array(
19
+            0 => __DIR__.'/..'.'/../lib',
20 20
         ),
21 21
     );
22 22
 
23
-    public static $classMap = array (
24
-        'Composer\\InstalledVersions' => __DIR__ . '/..' . '/composer/InstalledVersions.php',
25
-        'OCA\\TwoFactorBackupCodes\\Activity\\Provider' => __DIR__ . '/..' . '/../lib/Activity/Provider.php',
26
-        'OCA\\TwoFactorBackupCodes\\AppInfo\\Application' => __DIR__ . '/..' . '/../lib/AppInfo/Application.php',
27
-        'OCA\\TwoFactorBackupCodes\\BackgroundJob\\CheckBackupCodes' => __DIR__ . '/..' . '/../lib/BackgroundJob/CheckBackupCodes.php',
28
-        'OCA\\TwoFactorBackupCodes\\BackgroundJob\\RememberBackupCodesJob' => __DIR__ . '/..' . '/../lib/BackgroundJob/RememberBackupCodesJob.php',
29
-        'OCA\\TwoFactorBackupCodes\\Controller\\SettingsController' => __DIR__ . '/..' . '/../lib/Controller/SettingsController.php',
30
-        'OCA\\TwoFactorBackupCodes\\Db\\BackupCode' => __DIR__ . '/..' . '/../lib/Db/BackupCode.php',
31
-        'OCA\\TwoFactorBackupCodes\\Db\\BackupCodeMapper' => __DIR__ . '/..' . '/../lib/Db/BackupCodeMapper.php',
32
-        'OCA\\TwoFactorBackupCodes\\Event\\CodesGenerated' => __DIR__ . '/..' . '/../lib/Event/CodesGenerated.php',
33
-        'OCA\\TwoFactorBackupCodes\\Listener\\ActivityPublisher' => __DIR__ . '/..' . '/../lib/Listener/ActivityPublisher.php',
34
-        'OCA\\TwoFactorBackupCodes\\Listener\\ClearNotifications' => __DIR__ . '/..' . '/../lib/Listener/ClearNotifications.php',
35
-        'OCA\\TwoFactorBackupCodes\\Listener\\ProviderDisabled' => __DIR__ . '/..' . '/../lib/Listener/ProviderDisabled.php',
36
-        'OCA\\TwoFactorBackupCodes\\Listener\\ProviderEnabled' => __DIR__ . '/..' . '/../lib/Listener/ProviderEnabled.php',
37
-        'OCA\\TwoFactorBackupCodes\\Listener\\RegistryUpdater' => __DIR__ . '/..' . '/../lib/Listener/RegistryUpdater.php',
38
-        'OCA\\TwoFactorBackupCodes\\Listener\\UserDeleted' => __DIR__ . '/..' . '/../lib/Listener/UserDeleted.php',
39
-        'OCA\\TwoFactorBackupCodes\\Migration\\CheckBackupCodes' => __DIR__ . '/..' . '/../lib/Migration/CheckBackupCodes.php',
40
-        'OCA\\TwoFactorBackupCodes\\Migration\\Version1002Date20170607104347' => __DIR__ . '/..' . '/../lib/Migration/Version1002Date20170607104347.php',
41
-        'OCA\\TwoFactorBackupCodes\\Migration\\Version1002Date20170607113030' => __DIR__ . '/..' . '/../lib/Migration/Version1002Date20170607113030.php',
42
-        'OCA\\TwoFactorBackupCodes\\Migration\\Version1002Date20170919123342' => __DIR__ . '/..' . '/../lib/Migration/Version1002Date20170919123342.php',
43
-        'OCA\\TwoFactorBackupCodes\\Migration\\Version1002Date20170926101419' => __DIR__ . '/..' . '/../lib/Migration/Version1002Date20170926101419.php',
44
-        'OCA\\TwoFactorBackupCodes\\Migration\\Version1002Date20180821043638' => __DIR__ . '/..' . '/../lib/Migration/Version1002Date20180821043638.php',
45
-        'OCA\\TwoFactorBackupCodes\\Notifications\\Notifier' => __DIR__ . '/..' . '/../lib/Notifications/Notifier.php',
46
-        'OCA\\TwoFactorBackupCodes\\Provider\\BackupCodesProvider' => __DIR__ . '/..' . '/../lib/Provider/BackupCodesProvider.php',
47
-        'OCA\\TwoFactorBackupCodes\\Service\\BackupCodeStorage' => __DIR__ . '/..' . '/../lib/Service/BackupCodeStorage.php',
48
-        'OCA\\TwoFactorBackupCodes\\Settings\\Personal' => __DIR__ . '/..' . '/../lib/Settings/Personal.php',
23
+    public static $classMap = array(
24
+        'Composer\\InstalledVersions' => __DIR__.'/..'.'/composer/InstalledVersions.php',
25
+        'OCA\\TwoFactorBackupCodes\\Activity\\Provider' => __DIR__.'/..'.'/../lib/Activity/Provider.php',
26
+        'OCA\\TwoFactorBackupCodes\\AppInfo\\Application' => __DIR__.'/..'.'/../lib/AppInfo/Application.php',
27
+        'OCA\\TwoFactorBackupCodes\\BackgroundJob\\CheckBackupCodes' => __DIR__.'/..'.'/../lib/BackgroundJob/CheckBackupCodes.php',
28
+        'OCA\\TwoFactorBackupCodes\\BackgroundJob\\RememberBackupCodesJob' => __DIR__.'/..'.'/../lib/BackgroundJob/RememberBackupCodesJob.php',
29
+        'OCA\\TwoFactorBackupCodes\\Controller\\SettingsController' => __DIR__.'/..'.'/../lib/Controller/SettingsController.php',
30
+        'OCA\\TwoFactorBackupCodes\\Db\\BackupCode' => __DIR__.'/..'.'/../lib/Db/BackupCode.php',
31
+        'OCA\\TwoFactorBackupCodes\\Db\\BackupCodeMapper' => __DIR__.'/..'.'/../lib/Db/BackupCodeMapper.php',
32
+        'OCA\\TwoFactorBackupCodes\\Event\\CodesGenerated' => __DIR__.'/..'.'/../lib/Event/CodesGenerated.php',
33
+        'OCA\\TwoFactorBackupCodes\\Listener\\ActivityPublisher' => __DIR__.'/..'.'/../lib/Listener/ActivityPublisher.php',
34
+        'OCA\\TwoFactorBackupCodes\\Listener\\ClearNotifications' => __DIR__.'/..'.'/../lib/Listener/ClearNotifications.php',
35
+        'OCA\\TwoFactorBackupCodes\\Listener\\ProviderDisabled' => __DIR__.'/..'.'/../lib/Listener/ProviderDisabled.php',
36
+        'OCA\\TwoFactorBackupCodes\\Listener\\ProviderEnabled' => __DIR__.'/..'.'/../lib/Listener/ProviderEnabled.php',
37
+        'OCA\\TwoFactorBackupCodes\\Listener\\RegistryUpdater' => __DIR__.'/..'.'/../lib/Listener/RegistryUpdater.php',
38
+        'OCA\\TwoFactorBackupCodes\\Listener\\UserDeleted' => __DIR__.'/..'.'/../lib/Listener/UserDeleted.php',
39
+        'OCA\\TwoFactorBackupCodes\\Migration\\CheckBackupCodes' => __DIR__.'/..'.'/../lib/Migration/CheckBackupCodes.php',
40
+        'OCA\\TwoFactorBackupCodes\\Migration\\Version1002Date20170607104347' => __DIR__.'/..'.'/../lib/Migration/Version1002Date20170607104347.php',
41
+        'OCA\\TwoFactorBackupCodes\\Migration\\Version1002Date20170607113030' => __DIR__.'/..'.'/../lib/Migration/Version1002Date20170607113030.php',
42
+        'OCA\\TwoFactorBackupCodes\\Migration\\Version1002Date20170919123342' => __DIR__.'/..'.'/../lib/Migration/Version1002Date20170919123342.php',
43
+        'OCA\\TwoFactorBackupCodes\\Migration\\Version1002Date20170926101419' => __DIR__.'/..'.'/../lib/Migration/Version1002Date20170926101419.php',
44
+        'OCA\\TwoFactorBackupCodes\\Migration\\Version1002Date20180821043638' => __DIR__.'/..'.'/../lib/Migration/Version1002Date20180821043638.php',
45
+        'OCA\\TwoFactorBackupCodes\\Notifications\\Notifier' => __DIR__.'/..'.'/../lib/Notifications/Notifier.php',
46
+        'OCA\\TwoFactorBackupCodes\\Provider\\BackupCodesProvider' => __DIR__.'/..'.'/../lib/Provider/BackupCodesProvider.php',
47
+        'OCA\\TwoFactorBackupCodes\\Service\\BackupCodeStorage' => __DIR__.'/..'.'/../lib/Service/BackupCodeStorage.php',
48
+        'OCA\\TwoFactorBackupCodes\\Settings\\Personal' => __DIR__.'/..'.'/../lib/Settings/Personal.php',
49 49
     );
50 50
 
51 51
     public static function getInitializer(ClassLoader $loader)
52 52
     {
53
-        return \Closure::bind(function () use ($loader) {
53
+        return \Closure::bind(function() use ($loader) {
54 54
             $loader->prefixLengthsPsr4 = ComposerStaticInitTwoFactorBackupCodes::$prefixLengthsPsr4;
55 55
             $loader->prefixDirsPsr4 = ComposerStaticInitTwoFactorBackupCodes::$prefixDirsPsr4;
56 56
             $loader->classMap = ComposerStaticInitTwoFactorBackupCodes::$classMap;
Please login to merge, or discard this patch.
apps/twofactor_backupcodes/composer/composer/autoload_classmap.php 1 patch
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -6,29 +6,29 @@
 block discarded – undo
6 6
 $baseDir = $vendorDir;
7 7
 
8 8
 return array(
9
-    'Composer\\InstalledVersions' => $vendorDir . '/composer/InstalledVersions.php',
10
-    'OCA\\TwoFactorBackupCodes\\Activity\\Provider' => $baseDir . '/../lib/Activity/Provider.php',
11
-    'OCA\\TwoFactorBackupCodes\\AppInfo\\Application' => $baseDir . '/../lib/AppInfo/Application.php',
12
-    'OCA\\TwoFactorBackupCodes\\BackgroundJob\\CheckBackupCodes' => $baseDir . '/../lib/BackgroundJob/CheckBackupCodes.php',
13
-    'OCA\\TwoFactorBackupCodes\\BackgroundJob\\RememberBackupCodesJob' => $baseDir . '/../lib/BackgroundJob/RememberBackupCodesJob.php',
14
-    'OCA\\TwoFactorBackupCodes\\Controller\\SettingsController' => $baseDir . '/../lib/Controller/SettingsController.php',
15
-    'OCA\\TwoFactorBackupCodes\\Db\\BackupCode' => $baseDir . '/../lib/Db/BackupCode.php',
16
-    'OCA\\TwoFactorBackupCodes\\Db\\BackupCodeMapper' => $baseDir . '/../lib/Db/BackupCodeMapper.php',
17
-    'OCA\\TwoFactorBackupCodes\\Event\\CodesGenerated' => $baseDir . '/../lib/Event/CodesGenerated.php',
18
-    'OCA\\TwoFactorBackupCodes\\Listener\\ActivityPublisher' => $baseDir . '/../lib/Listener/ActivityPublisher.php',
19
-    'OCA\\TwoFactorBackupCodes\\Listener\\ClearNotifications' => $baseDir . '/../lib/Listener/ClearNotifications.php',
20
-    'OCA\\TwoFactorBackupCodes\\Listener\\ProviderDisabled' => $baseDir . '/../lib/Listener/ProviderDisabled.php',
21
-    'OCA\\TwoFactorBackupCodes\\Listener\\ProviderEnabled' => $baseDir . '/../lib/Listener/ProviderEnabled.php',
22
-    'OCA\\TwoFactorBackupCodes\\Listener\\RegistryUpdater' => $baseDir . '/../lib/Listener/RegistryUpdater.php',
23
-    'OCA\\TwoFactorBackupCodes\\Listener\\UserDeleted' => $baseDir . '/../lib/Listener/UserDeleted.php',
24
-    'OCA\\TwoFactorBackupCodes\\Migration\\CheckBackupCodes' => $baseDir . '/../lib/Migration/CheckBackupCodes.php',
25
-    'OCA\\TwoFactorBackupCodes\\Migration\\Version1002Date20170607104347' => $baseDir . '/../lib/Migration/Version1002Date20170607104347.php',
26
-    'OCA\\TwoFactorBackupCodes\\Migration\\Version1002Date20170607113030' => $baseDir . '/../lib/Migration/Version1002Date20170607113030.php',
27
-    'OCA\\TwoFactorBackupCodes\\Migration\\Version1002Date20170919123342' => $baseDir . '/../lib/Migration/Version1002Date20170919123342.php',
28
-    'OCA\\TwoFactorBackupCodes\\Migration\\Version1002Date20170926101419' => $baseDir . '/../lib/Migration/Version1002Date20170926101419.php',
29
-    'OCA\\TwoFactorBackupCodes\\Migration\\Version1002Date20180821043638' => $baseDir . '/../lib/Migration/Version1002Date20180821043638.php',
30
-    'OCA\\TwoFactorBackupCodes\\Notifications\\Notifier' => $baseDir . '/../lib/Notifications/Notifier.php',
31
-    'OCA\\TwoFactorBackupCodes\\Provider\\BackupCodesProvider' => $baseDir . '/../lib/Provider/BackupCodesProvider.php',
32
-    'OCA\\TwoFactorBackupCodes\\Service\\BackupCodeStorage' => $baseDir . '/../lib/Service/BackupCodeStorage.php',
33
-    'OCA\\TwoFactorBackupCodes\\Settings\\Personal' => $baseDir . '/../lib/Settings/Personal.php',
9
+    'Composer\\InstalledVersions' => $vendorDir.'/composer/InstalledVersions.php',
10
+    'OCA\\TwoFactorBackupCodes\\Activity\\Provider' => $baseDir.'/../lib/Activity/Provider.php',
11
+    'OCA\\TwoFactorBackupCodes\\AppInfo\\Application' => $baseDir.'/../lib/AppInfo/Application.php',
12
+    'OCA\\TwoFactorBackupCodes\\BackgroundJob\\CheckBackupCodes' => $baseDir.'/../lib/BackgroundJob/CheckBackupCodes.php',
13
+    'OCA\\TwoFactorBackupCodes\\BackgroundJob\\RememberBackupCodesJob' => $baseDir.'/../lib/BackgroundJob/RememberBackupCodesJob.php',
14
+    'OCA\\TwoFactorBackupCodes\\Controller\\SettingsController' => $baseDir.'/../lib/Controller/SettingsController.php',
15
+    'OCA\\TwoFactorBackupCodes\\Db\\BackupCode' => $baseDir.'/../lib/Db/BackupCode.php',
16
+    'OCA\\TwoFactorBackupCodes\\Db\\BackupCodeMapper' => $baseDir.'/../lib/Db/BackupCodeMapper.php',
17
+    'OCA\\TwoFactorBackupCodes\\Event\\CodesGenerated' => $baseDir.'/../lib/Event/CodesGenerated.php',
18
+    'OCA\\TwoFactorBackupCodes\\Listener\\ActivityPublisher' => $baseDir.'/../lib/Listener/ActivityPublisher.php',
19
+    'OCA\\TwoFactorBackupCodes\\Listener\\ClearNotifications' => $baseDir.'/../lib/Listener/ClearNotifications.php',
20
+    'OCA\\TwoFactorBackupCodes\\Listener\\ProviderDisabled' => $baseDir.'/../lib/Listener/ProviderDisabled.php',
21
+    'OCA\\TwoFactorBackupCodes\\Listener\\ProviderEnabled' => $baseDir.'/../lib/Listener/ProviderEnabled.php',
22
+    'OCA\\TwoFactorBackupCodes\\Listener\\RegistryUpdater' => $baseDir.'/../lib/Listener/RegistryUpdater.php',
23
+    'OCA\\TwoFactorBackupCodes\\Listener\\UserDeleted' => $baseDir.'/../lib/Listener/UserDeleted.php',
24
+    'OCA\\TwoFactorBackupCodes\\Migration\\CheckBackupCodes' => $baseDir.'/../lib/Migration/CheckBackupCodes.php',
25
+    'OCA\\TwoFactorBackupCodes\\Migration\\Version1002Date20170607104347' => $baseDir.'/../lib/Migration/Version1002Date20170607104347.php',
26
+    'OCA\\TwoFactorBackupCodes\\Migration\\Version1002Date20170607113030' => $baseDir.'/../lib/Migration/Version1002Date20170607113030.php',
27
+    'OCA\\TwoFactorBackupCodes\\Migration\\Version1002Date20170919123342' => $baseDir.'/../lib/Migration/Version1002Date20170919123342.php',
28
+    'OCA\\TwoFactorBackupCodes\\Migration\\Version1002Date20170926101419' => $baseDir.'/../lib/Migration/Version1002Date20170926101419.php',
29
+    'OCA\\TwoFactorBackupCodes\\Migration\\Version1002Date20180821043638' => $baseDir.'/../lib/Migration/Version1002Date20180821043638.php',
30
+    'OCA\\TwoFactorBackupCodes\\Notifications\\Notifier' => $baseDir.'/../lib/Notifications/Notifier.php',
31
+    'OCA\\TwoFactorBackupCodes\\Provider\\BackupCodesProvider' => $baseDir.'/../lib/Provider/BackupCodesProvider.php',
32
+    'OCA\\TwoFactorBackupCodes\\Service\\BackupCodeStorage' => $baseDir.'/../lib/Service/BackupCodeStorage.php',
33
+    'OCA\\TwoFactorBackupCodes\\Settings\\Personal' => $baseDir.'/../lib/Settings/Personal.php',
34 34
 );
Please login to merge, or discard this patch.
lib/private/Collaboration/Resources/ProviderManager.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -57,7 +57,7 @@
 block discarded – undo
57 57
 				try {
58 58
 					$this->providerInstances[] = $this->serverContainer->query($provider);
59 59
 				} catch (QueryException $e) {
60
-					$this->logger->error("Could not query resource provider $provider: " . $e->getMessage(), [
60
+					$this->logger->error("Could not query resource provider $provider: ".$e->getMessage(), [
61 61
 						'exception' => $e,
62 62
 					]);
63 63
 				}
Please login to merge, or discard this patch.
Indentation   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -15,36 +15,36 @@
 block discarded – undo
15 15
 use Psr\Log\LoggerInterface;
16 16
 
17 17
 class ProviderManager implements IProviderManager {
18
-	/** @var string[] */
19
-	protected array $providers = [];
20
-
21
-	/** @var IProvider[] */
22
-	protected array $providerInstances = [];
23
-
24
-	public function __construct(
25
-		protected IServerContainer $serverContainer,
26
-		protected LoggerInterface $logger,
27
-	) {
28
-	}
29
-
30
-	public function getResourceProviders(): array {
31
-		if ($this->providers !== []) {
32
-			foreach ($this->providers as $provider) {
33
-				try {
34
-					$this->providerInstances[] = $this->serverContainer->query($provider);
35
-				} catch (QueryException $e) {
36
-					$this->logger->error("Could not query resource provider $provider: " . $e->getMessage(), [
37
-						'exception' => $e,
38
-					]);
39
-				}
40
-			}
41
-			$this->providers = [];
42
-		}
43
-
44
-		return $this->providerInstances;
45
-	}
46
-
47
-	public function registerResourceProvider(string $provider): void {
48
-		$this->providers[] = $provider;
49
-	}
18
+    /** @var string[] */
19
+    protected array $providers = [];
20
+
21
+    /** @var IProvider[] */
22
+    protected array $providerInstances = [];
23
+
24
+    public function __construct(
25
+        protected IServerContainer $serverContainer,
26
+        protected LoggerInterface $logger,
27
+    ) {
28
+    }
29
+
30
+    public function getResourceProviders(): array {
31
+        if ($this->providers !== []) {
32
+            foreach ($this->providers as $provider) {
33
+                try {
34
+                    $this->providerInstances[] = $this->serverContainer->query($provider);
35
+                } catch (QueryException $e) {
36
+                    $this->logger->error("Could not query resource provider $provider: " . $e->getMessage(), [
37
+                        'exception' => $e,
38
+                    ]);
39
+                }
40
+            }
41
+            $this->providers = [];
42
+        }
43
+
44
+        return $this->providerInstances;
45
+    }
46
+
47
+    public function registerResourceProvider(string $provider): void {
48
+        $this->providers[] = $provider;
49
+    }
50 50
 }
Please login to merge, or discard this patch.
apps/dav/lib/Listener/CalendarDeletionDefaultUpdaterListener.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -78,7 +78,7 @@
 block discarded – undo
78 78
 			$this->logger->debug('Default user calendar reset');
79 79
 		} catch (Throwable $e) {
80 80
 			// Any error with activities shouldn't abort the calendar deletion, so we just log it
81
-			$this->logger->error('Error generating activities for a deleted calendar: ' . $e->getMessage(), [
81
+			$this->logger->error('Error generating activities for a deleted calendar: '.$e->getMessage(), [
82 82
 				'exception' => $e,
83 83
 			]);
84 84
 		}
Please login to merge, or discard this patch.
Indentation   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -20,43 +20,43 @@
 block discarded – undo
20 20
  */
21 21
 class CalendarDeletionDefaultUpdaterListener implements IEventListener {
22 22
 
23
-	public function __construct(
24
-		private IConfig $config,
25
-		private LoggerInterface $logger,
26
-	) {
27
-	}
28
-
29
-	/**
30
-	 * In case the user has set their default calendar to the deleted one
31
-	 */
32
-	public function handle(Event $event): void {
33
-		if (!($event instanceof CalendarDeletedEvent)) {
34
-			// Not what we subscribed to
35
-			return;
36
-		}
37
-
38
-		try {
39
-			$principalUri = $event->getCalendarData()['principaluri'];
40
-			if (!str_starts_with($principalUri, 'principals/users')) {
41
-				$this->logger->debug('Default calendar needs no update because the deleted calendar does not belong to a user principal');
42
-				return;
43
-			}
44
-
45
-			[, $uid] = \Sabre\Uri\split($principalUri);
46
-			$uri = $event->getCalendarData()['uri'];
47
-			if ($this->config->getUserValue($uid, 'dav', 'defaultCalendar') !== $uri) {
48
-				$this->logger->debug('Default calendar needs no update because the deleted calendar is no the user\'s default one');
49
-				return;
50
-			}
51
-
52
-			$this->config->deleteUserValue($uid, 'dav', 'defaultCalendar');
53
-
54
-			$this->logger->debug('Default user calendar reset');
55
-		} catch (Throwable $e) {
56
-			// Any error with activities shouldn't abort the calendar deletion, so we just log it
57
-			$this->logger->error('Error generating activities for a deleted calendar: ' . $e->getMessage(), [
58
-				'exception' => $e,
59
-			]);
60
-		}
61
-	}
23
+    public function __construct(
24
+        private IConfig $config,
25
+        private LoggerInterface $logger,
26
+    ) {
27
+    }
28
+
29
+    /**
30
+     * In case the user has set their default calendar to the deleted one
31
+     */
32
+    public function handle(Event $event): void {
33
+        if (!($event instanceof CalendarDeletedEvent)) {
34
+            // Not what we subscribed to
35
+            return;
36
+        }
37
+
38
+        try {
39
+            $principalUri = $event->getCalendarData()['principaluri'];
40
+            if (!str_starts_with($principalUri, 'principals/users')) {
41
+                $this->logger->debug('Default calendar needs no update because the deleted calendar does not belong to a user principal');
42
+                return;
43
+            }
44
+
45
+            [, $uid] = \Sabre\Uri\split($principalUri);
46
+            $uri = $event->getCalendarData()['uri'];
47
+            if ($this->config->getUserValue($uid, 'dav', 'defaultCalendar') !== $uri) {
48
+                $this->logger->debug('Default calendar needs no update because the deleted calendar is no the user\'s default one');
49
+                return;
50
+            }
51
+
52
+            $this->config->deleteUserValue($uid, 'dav', 'defaultCalendar');
53
+
54
+            $this->logger->debug('Default user calendar reset');
55
+        } catch (Throwable $e) {
56
+            // Any error with activities shouldn't abort the calendar deletion, so we just log it
57
+            $this->logger->error('Error generating activities for a deleted calendar: ' . $e->getMessage(), [
58
+                'exception' => $e,
59
+            ]);
60
+        }
61
+    }
62 62
 }
Please login to merge, or discard this patch.
apps/settings/lib/BackgroundJobs/VerifyUserData.php 2 patches
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
 	}
108 108
 
109 109
 	protected function run($argument) {
110
-		$try = (int)$argument['try'] + 1;
110
+		$try = (int) $argument['try'] + 1;
111 111
 
112 112
 		switch ($argument['type']) {
113 113
 			case IAccountManager::PROPERTY_WEBSITE:
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
 				break;
120 120
 			default:
121 121
 				// no valid type given, no need to retry
122
-				$this->logger->error($argument['type'] . ' is no valid type for user account data.');
122
+				$this->logger->error($argument['type'].' is no valid type for user account data.');
123 123
 				$result = true;
124 124
 		}
125 125
 
@@ -137,7 +137,7 @@  discard block
 block discarded – undo
137 137
 	protected function verifyWebsite(array $argument) {
138 138
 		$result = false;
139 139
 
140
-		$url = rtrim($argument['data'], '/') . '/.well-known/' . 'CloudIdVerificationCode.txt';
140
+		$url = rtrim($argument['data'], '/').'/.well-known/'.'CloudIdVerificationCode.txt';
141 141
 
142 142
 		$client = $this->httpClientService->newClient();
143 143
 		try {
@@ -154,7 +154,7 @@  discard block
 block discarded – undo
154 154
 			$user = $this->userManager->get($argument['uid']);
155 155
 			// we don't check a valid user -> give up
156 156
 			if ($user === null) {
157
-				$this->logger->error($argument['uid'] . ' doesn\'t exist, can\'t verify user data.');
157
+				$this->logger->error($argument['uid'].' doesn\'t exist, can\'t verify user data.');
158 158
 				return $result;
159 159
 			}
160 160
 			$userAccount = $this->accountManager->getAccount($user);
@@ -180,7 +180,7 @@  discard block
 block discarded – undo
180 180
 
181 181
 		// we don't check a valid user -> give up
182 182
 		if ($user === null) {
183
-			$this->logger->info($argument['uid'] . ' doesn\'t exist, can\'t verify user data.');
183
+			$this->logger->info($argument['uid'].' doesn\'t exist, can\'t verify user data.');
184 184
 			return true;
185 185
 		}
186 186
 
@@ -222,7 +222,7 @@  discard block
 block discarded – undo
222 222
 		try {
223 223
 			$client = $this->httpClientService->newClient();
224 224
 			$response = $client->get(
225
-				$this->lookupServerUrl . '/users?search=' . urlencode($cloudId) . '&exactCloudId=1',
225
+				$this->lookupServerUrl.'/users?search='.urlencode($cloudId).'&exactCloudId=1',
226 226
 				[
227 227
 					'timeout' => 10,
228 228
 					'connect_timeout' => 3,
@@ -254,7 +254,7 @@  discard block
 block discarded – undo
254 254
 				'data' => $argument['data'],
255 255
 				'type' => $argument['type'],
256 256
 				'uid' => $argument['uid'],
257
-				'try' => (int)$argument['try'] + 1,
257
+				'try' => (int) $argument['try'] + 1,
258 258
 				'lastRun' => time()
259 259
 			]
260 260
 		);
@@ -267,7 +267,7 @@  discard block
 block discarded – undo
267 267
 	 * @return bool
268 268
 	 */
269 269
 	protected function shouldRun(array $argument) {
270
-		$lastRun = (int)$argument['lastRun'];
270
+		$lastRun = (int) $argument['lastRun'];
271 271
 		return ((time() - $lastRun) > $this->interval);
272 272
 	}
273 273
 
Please login to merge, or discard this patch.
Indentation   +220 added lines, -220 removed lines patch added patch discarded remove patch
@@ -20,224 +20,224 @@
 block discarded – undo
20 20
 use Psr\Log\LoggerInterface;
21 21
 
22 22
 class VerifyUserData extends Job {
23
-	/** @var bool */
24
-	private bool $retainJob = true;
25
-
26
-	/** @var int max number of attempts to send the request */
27
-	private int $maxTry = 24;
28
-
29
-	/** @var int how much time should be between two tries (1 hour) */
30
-	private int $interval = 3600;
31
-	private string $lookupServerUrl;
32
-
33
-	public function __construct(
34
-		private IAccountManager $accountManager,
35
-		private IUserManager $userManager,
36
-		private IClientService $httpClientService,
37
-		private LoggerInterface $logger,
38
-		ITimeFactory $timeFactory,
39
-		private IConfig $config,
40
-	) {
41
-		parent::__construct($timeFactory);
42
-
43
-		$lookupServerUrl = $config->getSystemValue('lookup_server', 'https://lookup.nextcloud.com');
44
-		$this->lookupServerUrl = rtrim($lookupServerUrl, '/');
45
-	}
46
-
47
-	public function start(IJobList $jobList): void {
48
-		if ($this->shouldRun($this->argument)) {
49
-			parent::start($jobList);
50
-			$jobList->remove($this, $this->argument);
51
-			if ($this->retainJob) {
52
-				$this->reAddJob($jobList, $this->argument);
53
-			} else {
54
-				$this->resetVerificationState();
55
-			}
56
-		}
57
-	}
58
-
59
-	protected function run($argument) {
60
-		$try = (int)$argument['try'] + 1;
61
-
62
-		switch ($argument['type']) {
63
-			case IAccountManager::PROPERTY_WEBSITE:
64
-				$result = $this->verifyWebsite($argument);
65
-				break;
66
-			case IAccountManager::PROPERTY_TWITTER:
67
-			case IAccountManager::PROPERTY_EMAIL:
68
-				$result = $this->verifyViaLookupServer($argument, $argument['type']);
69
-				break;
70
-			default:
71
-				// no valid type given, no need to retry
72
-				$this->logger->error($argument['type'] . ' is no valid type for user account data.');
73
-				$result = true;
74
-		}
75
-
76
-		if ($result === true || $try > $this->maxTry) {
77
-			$this->retainJob = false;
78
-		}
79
-	}
80
-
81
-	/**
82
-	 * verify web page
83
-	 *
84
-	 * @param array $argument
85
-	 * @return bool true if we could check the verification code, otherwise false
86
-	 */
87
-	protected function verifyWebsite(array $argument) {
88
-		$result = false;
89
-
90
-		$url = rtrim($argument['data'], '/') . '/.well-known/' . 'CloudIdVerificationCode.txt';
91
-
92
-		$client = $this->httpClientService->newClient();
93
-		try {
94
-			$response = $client->get($url);
95
-		} catch (\Exception $e) {
96
-			return false;
97
-		}
98
-
99
-		if ($response->getStatusCode() === Http::STATUS_OK) {
100
-			$result = true;
101
-			$publishedCode = $response->getBody();
102
-			// remove new lines and spaces
103
-			$publishedCodeSanitized = trim(preg_replace('/\s\s+/', ' ', $publishedCode));
104
-			$user = $this->userManager->get($argument['uid']);
105
-			// we don't check a valid user -> give up
106
-			if ($user === null) {
107
-				$this->logger->error($argument['uid'] . ' doesn\'t exist, can\'t verify user data.');
108
-				return $result;
109
-			}
110
-			$userAccount = $this->accountManager->getAccount($user);
111
-			$websiteProp = $userAccount->getProperty(IAccountManager::PROPERTY_WEBSITE);
112
-			$websiteProp->setVerified($publishedCodeSanitized === $argument['verificationCode']
113
-				? IAccountManager::VERIFIED
114
-				: IAccountManager::NOT_VERIFIED
115
-			);
116
-			$this->accountManager->updateAccount($userAccount);
117
-		}
118
-
119
-		return $result;
120
-	}
121
-
122
-	protected function verifyViaLookupServer(array $argument, string $dataType): bool {
123
-		// TODO: Consider to enable for non-global-scale setups by checking 'files_sharing', 'lookupServerUploadEnabled'
124
-		if (!$this->config->getSystemValueBool('gs.enabled', false)
125
-			|| empty($this->lookupServerUrl)
126
-			|| $this->config->getSystemValue('has_internet_connection', true) === false
127
-		) {
128
-			return true;
129
-		}
130
-
131
-		$user = $this->userManager->get($argument['uid']);
132
-
133
-		// we don't check a valid user -> give up
134
-		if ($user === null) {
135
-			$this->logger->info($argument['uid'] . ' doesn\'t exist, can\'t verify user data.');
136
-			return true;
137
-		}
138
-
139
-		$cloudId = $user->getCloudId();
140
-		$lookupServerData = $this->queryLookupServer($cloudId);
141
-
142
-		// for some reasons we couldn't read any data from the lookup server, try again later
143
-		if (empty($lookupServerData) || empty($lookupServerData[$dataType])) {
144
-			return false;
145
-		}
146
-
147
-		// lookup server has verification data for wrong user data (e.g. email address), try again later
148
-		if ($lookupServerData[$dataType]['value'] !== $argument['data']) {
149
-			return false;
150
-		}
151
-
152
-		// lookup server hasn't verified the email address so far, try again later
153
-		if ($lookupServerData[$dataType]['verified'] === IAccountManager::NOT_VERIFIED) {
154
-			return false;
155
-		}
156
-
157
-		try {
158
-			$userAccount = $this->accountManager->getAccount($user);
159
-			$property = $userAccount->getProperty($dataType);
160
-			$property->setVerified(IAccountManager::VERIFIED);
161
-			$this->accountManager->updateAccount($userAccount);
162
-		} catch (PropertyDoesNotExistException $e) {
163
-			return false;
164
-		}
165
-
166
-		return true;
167
-	}
168
-
169
-	/**
170
-	 * @param string $cloudId
171
-	 * @return array
172
-	 */
173
-	protected function queryLookupServer($cloudId) {
174
-		try {
175
-			$client = $this->httpClientService->newClient();
176
-			$response = $client->get(
177
-				$this->lookupServerUrl . '/users?search=' . urlencode($cloudId) . '&exactCloudId=1',
178
-				[
179
-					'timeout' => 10,
180
-					'connect_timeout' => 3,
181
-				]
182
-			);
183
-
184
-			$body = json_decode($response->getBody(), true);
185
-
186
-			if (is_array($body) && isset($body['federationId']) && $body['federationId'] === $cloudId) {
187
-				return $body;
188
-			}
189
-		} catch (\Exception $e) {
190
-			// do nothing, we will just re-try later
191
-		}
192
-
193
-		return [];
194
-	}
195
-
196
-	/**
197
-	 * re-add background job with new arguments
198
-	 *
199
-	 * @param IJobList $jobList
200
-	 * @param array $argument
201
-	 */
202
-	protected function reAddJob(IJobList $jobList, array $argument) {
203
-		$jobList->add(VerifyUserData::class,
204
-			[
205
-				'verificationCode' => $argument['verificationCode'],
206
-				'data' => $argument['data'],
207
-				'type' => $argument['type'],
208
-				'uid' => $argument['uid'],
209
-				'try' => (int)$argument['try'] + 1,
210
-				'lastRun' => time()
211
-			]
212
-		);
213
-	}
214
-
215
-	/**
216
-	 * test if it is time for the next run
217
-	 *
218
-	 * @param array $argument
219
-	 * @return bool
220
-	 */
221
-	protected function shouldRun(array $argument) {
222
-		$lastRun = (int)$argument['lastRun'];
223
-		return ((time() - $lastRun) > $this->interval);
224
-	}
225
-
226
-
227
-	/**
228
-	 * reset verification state after max tries are reached
229
-	 */
230
-	protected function resetVerificationState(): void {
231
-		$user = $this->userManager->get($this->argument['uid']);
232
-		if ($user !== null) {
233
-			$userAccount = $this->accountManager->getAccount($user);
234
-			try {
235
-				$property = $userAccount->getProperty($this->argument['type']);
236
-				$property->setVerified(IAccountManager::NOT_VERIFIED);
237
-				$this->accountManager->updateAccount($userAccount);
238
-			} catch (PropertyDoesNotExistException $e) {
239
-				return;
240
-			}
241
-		}
242
-	}
23
+    /** @var bool */
24
+    private bool $retainJob = true;
25
+
26
+    /** @var int max number of attempts to send the request */
27
+    private int $maxTry = 24;
28
+
29
+    /** @var int how much time should be between two tries (1 hour) */
30
+    private int $interval = 3600;
31
+    private string $lookupServerUrl;
32
+
33
+    public function __construct(
34
+        private IAccountManager $accountManager,
35
+        private IUserManager $userManager,
36
+        private IClientService $httpClientService,
37
+        private LoggerInterface $logger,
38
+        ITimeFactory $timeFactory,
39
+        private IConfig $config,
40
+    ) {
41
+        parent::__construct($timeFactory);
42
+
43
+        $lookupServerUrl = $config->getSystemValue('lookup_server', 'https://lookup.nextcloud.com');
44
+        $this->lookupServerUrl = rtrim($lookupServerUrl, '/');
45
+    }
46
+
47
+    public function start(IJobList $jobList): void {
48
+        if ($this->shouldRun($this->argument)) {
49
+            parent::start($jobList);
50
+            $jobList->remove($this, $this->argument);
51
+            if ($this->retainJob) {
52
+                $this->reAddJob($jobList, $this->argument);
53
+            } else {
54
+                $this->resetVerificationState();
55
+            }
56
+        }
57
+    }
58
+
59
+    protected function run($argument) {
60
+        $try = (int)$argument['try'] + 1;
61
+
62
+        switch ($argument['type']) {
63
+            case IAccountManager::PROPERTY_WEBSITE:
64
+                $result = $this->verifyWebsite($argument);
65
+                break;
66
+            case IAccountManager::PROPERTY_TWITTER:
67
+            case IAccountManager::PROPERTY_EMAIL:
68
+                $result = $this->verifyViaLookupServer($argument, $argument['type']);
69
+                break;
70
+            default:
71
+                // no valid type given, no need to retry
72
+                $this->logger->error($argument['type'] . ' is no valid type for user account data.');
73
+                $result = true;
74
+        }
75
+
76
+        if ($result === true || $try > $this->maxTry) {
77
+            $this->retainJob = false;
78
+        }
79
+    }
80
+
81
+    /**
82
+     * verify web page
83
+     *
84
+     * @param array $argument
85
+     * @return bool true if we could check the verification code, otherwise false
86
+     */
87
+    protected function verifyWebsite(array $argument) {
88
+        $result = false;
89
+
90
+        $url = rtrim($argument['data'], '/') . '/.well-known/' . 'CloudIdVerificationCode.txt';
91
+
92
+        $client = $this->httpClientService->newClient();
93
+        try {
94
+            $response = $client->get($url);
95
+        } catch (\Exception $e) {
96
+            return false;
97
+        }
98
+
99
+        if ($response->getStatusCode() === Http::STATUS_OK) {
100
+            $result = true;
101
+            $publishedCode = $response->getBody();
102
+            // remove new lines and spaces
103
+            $publishedCodeSanitized = trim(preg_replace('/\s\s+/', ' ', $publishedCode));
104
+            $user = $this->userManager->get($argument['uid']);
105
+            // we don't check a valid user -> give up
106
+            if ($user === null) {
107
+                $this->logger->error($argument['uid'] . ' doesn\'t exist, can\'t verify user data.');
108
+                return $result;
109
+            }
110
+            $userAccount = $this->accountManager->getAccount($user);
111
+            $websiteProp = $userAccount->getProperty(IAccountManager::PROPERTY_WEBSITE);
112
+            $websiteProp->setVerified($publishedCodeSanitized === $argument['verificationCode']
113
+                ? IAccountManager::VERIFIED
114
+                : IAccountManager::NOT_VERIFIED
115
+            );
116
+            $this->accountManager->updateAccount($userAccount);
117
+        }
118
+
119
+        return $result;
120
+    }
121
+
122
+    protected function verifyViaLookupServer(array $argument, string $dataType): bool {
123
+        // TODO: Consider to enable for non-global-scale setups by checking 'files_sharing', 'lookupServerUploadEnabled'
124
+        if (!$this->config->getSystemValueBool('gs.enabled', false)
125
+            || empty($this->lookupServerUrl)
126
+            || $this->config->getSystemValue('has_internet_connection', true) === false
127
+        ) {
128
+            return true;
129
+        }
130
+
131
+        $user = $this->userManager->get($argument['uid']);
132
+
133
+        // we don't check a valid user -> give up
134
+        if ($user === null) {
135
+            $this->logger->info($argument['uid'] . ' doesn\'t exist, can\'t verify user data.');
136
+            return true;
137
+        }
138
+
139
+        $cloudId = $user->getCloudId();
140
+        $lookupServerData = $this->queryLookupServer($cloudId);
141
+
142
+        // for some reasons we couldn't read any data from the lookup server, try again later
143
+        if (empty($lookupServerData) || empty($lookupServerData[$dataType])) {
144
+            return false;
145
+        }
146
+
147
+        // lookup server has verification data for wrong user data (e.g. email address), try again later
148
+        if ($lookupServerData[$dataType]['value'] !== $argument['data']) {
149
+            return false;
150
+        }
151
+
152
+        // lookup server hasn't verified the email address so far, try again later
153
+        if ($lookupServerData[$dataType]['verified'] === IAccountManager::NOT_VERIFIED) {
154
+            return false;
155
+        }
156
+
157
+        try {
158
+            $userAccount = $this->accountManager->getAccount($user);
159
+            $property = $userAccount->getProperty($dataType);
160
+            $property->setVerified(IAccountManager::VERIFIED);
161
+            $this->accountManager->updateAccount($userAccount);
162
+        } catch (PropertyDoesNotExistException $e) {
163
+            return false;
164
+        }
165
+
166
+        return true;
167
+    }
168
+
169
+    /**
170
+     * @param string $cloudId
171
+     * @return array
172
+     */
173
+    protected function queryLookupServer($cloudId) {
174
+        try {
175
+            $client = $this->httpClientService->newClient();
176
+            $response = $client->get(
177
+                $this->lookupServerUrl . '/users?search=' . urlencode($cloudId) . '&exactCloudId=1',
178
+                [
179
+                    'timeout' => 10,
180
+                    'connect_timeout' => 3,
181
+                ]
182
+            );
183
+
184
+            $body = json_decode($response->getBody(), true);
185
+
186
+            if (is_array($body) && isset($body['federationId']) && $body['federationId'] === $cloudId) {
187
+                return $body;
188
+            }
189
+        } catch (\Exception $e) {
190
+            // do nothing, we will just re-try later
191
+        }
192
+
193
+        return [];
194
+    }
195
+
196
+    /**
197
+     * re-add background job with new arguments
198
+     *
199
+     * @param IJobList $jobList
200
+     * @param array $argument
201
+     */
202
+    protected function reAddJob(IJobList $jobList, array $argument) {
203
+        $jobList->add(VerifyUserData::class,
204
+            [
205
+                'verificationCode' => $argument['verificationCode'],
206
+                'data' => $argument['data'],
207
+                'type' => $argument['type'],
208
+                'uid' => $argument['uid'],
209
+                'try' => (int)$argument['try'] + 1,
210
+                'lastRun' => time()
211
+            ]
212
+        );
213
+    }
214
+
215
+    /**
216
+     * test if it is time for the next run
217
+     *
218
+     * @param array $argument
219
+     * @return bool
220
+     */
221
+    protected function shouldRun(array $argument) {
222
+        $lastRun = (int)$argument['lastRun'];
223
+        return ((time() - $lastRun) > $this->interval);
224
+    }
225
+
226
+
227
+    /**
228
+     * reset verification state after max tries are reached
229
+     */
230
+    protected function resetVerificationState(): void {
231
+        $user = $this->userManager->get($this->argument['uid']);
232
+        if ($user !== null) {
233
+            $userAccount = $this->accountManager->getAccount($user);
234
+            try {
235
+                $property = $userAccount->getProperty($this->argument['type']);
236
+                $property->setVerified(IAccountManager::NOT_VERIFIED);
237
+                $this->accountManager->updateAccount($userAccount);
238
+            } catch (PropertyDoesNotExistException $e) {
239
+                return;
240
+            }
241
+        }
242
+    }
243 243
 }
Please login to merge, or discard this patch.