Skip to content

Commit 09a669f

Browse files
authored
Merge pull request #2577 from nextcloud/backport/2568/stable32
[stable32] refactor: clarify fileCreate() condition by making the specific case explicit
2 parents f9ce8a6 + 2e37adf commit 09a669f

2 files changed

Lines changed: 5 additions & 3 deletions

File tree

lib/FilesHooks.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,10 @@ public function fileCreate($path) {
8282
return;
8383
}
8484

85-
if ($this->currentUser->getUserIdentifier() !== '' || !$this->currentUser->isPublicShareToken()) {
86-
$this->addNotificationsForFileAction($path, Files::TYPE_SHARE_CREATED, 'created_self', 'created_by');
87-
} else {
85+
if ($this->currentUser->getUserIdentifier() === '' && $this->currentUser->isPublicShareToken()) {
8886
$this->addNotificationsForFileAction($path, Files_Sharing::TYPE_PUBLIC_UPLOAD, '', 'created_public');
87+
} else {
88+
$this->addNotificationsForFileAction($path, Files::TYPE_SHARE_CREATED, 'created_self', 'created_by');
8989
}
9090
}
9191

tests/FilesHooksTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,8 @@ public static function dataFileCreate(): array {
179179
['user', false, 'created_self', 'created_by', Files::TYPE_SHARE_CREATED],
180180
['', true, '', 'created_public', Files_Sharing::TYPE_PUBLIC_UPLOAD],
181181
['', false, 'created_self', 'created_by', Files::TYPE_SHARE_CREATED],
182+
// logged-in user uploading to a public share link → treated as regular upload
183+
['user', true, 'created_self', 'created_by', Files::TYPE_SHARE_CREATED],
182184
];
183185
}
184186

0 commit comments

Comments
 (0)