Skip to content

Commit

Permalink
fix: Use user uid to compare in PhotosPicker
Browse files Browse the repository at this point in the history
Signed-off-by: Louis Chemineau <[email protected]>

Signed-off-by: nextcloud-command <[email protected]>
  • Loading branch information
artonge authored and nextcloud-command committed Sep 26, 2024
1 parent ae6a6eb commit e536555
Show file tree
Hide file tree
Showing 16 changed files with 44 additions and 19 deletions.
4 changes: 2 additions & 2 deletions js/photos-main.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/photos-main.js.map

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions js/photos-public.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/photos-public.js.map

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions js/photos-src_views_AlbumContent_vue.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/photos-src_views_AlbumContent_vue.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions js/photos-src_views_Folders_vue.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/photos-src_views_Folders_vue.js.map

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions lib/Controller/PageController.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,13 @@ public function index(): TemplateResponse {
$this->eventDispatcher->dispatch(LoadSidebar::class, new LoadSidebar());
$this->eventDispatcher->dispatch(LoadViewer::class, new LoadViewer());

$userFolder = $this->rootFolder->getUserFolder($user->getUid());
try {
$photosFolder = $userFolder->get($this->userConfig->getUserConfig('photosLocation'));
} catch (NotFoundException $e) {
$photosFolder = $userFolder->newFolder($this->userConfig->getUserConfig('photosLocation'));
}

$this->initialState->provideInitialState('image-mimes', Application::IMAGE_MIMES);
$this->initialState->provideInitialState('video-mimes', Application::VIDEO_MIMES);
$this->initialState->provideInitialState('maps', $this->appManager->isEnabledForUser('maps') === true);
Expand Down
5 changes: 5 additions & 0 deletions lib/Sabre/Album/AlbumRoot.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
use OCA\Photos\Album\AlbumWithFiles;
use OCA\Photos\Service\UserConfigService;
use OCP\Files\Folder;
use OCP\Files\InvalidDirectoryException;
use OCP\Files\IRootFolder;
use OCP\Files\NotFoundException;
use Sabre\DAV\Exception\Conflict;
Expand Down Expand Up @@ -106,6 +107,10 @@ public function createFile($name, $data = null) {
throw new Conflict('The destination exists and is not a folder');
}

if ($photosFolder->isShared()) {
throw new InvalidDirectoryException('The destination is a received share');
}

// Check for conflict and rename the file accordingly
$newName = \basename(\OC_Helper::buildNotExistingFileName($photosLocation, $name));

Expand Down
14 changes: 13 additions & 1 deletion src/components/FilesPicker.vue
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@

<script>
import { mapGetters } from 'vuex'
import { NcButton, NcLoadingIcon } from '@nextcloud/vue'
import { NcButton, NcLoadingIcon, NcNoteCard } from '@nextcloud/vue'
import { getCurrentUser } from '@nextcloud/auth'
import { UploadPicker } from '@nextcloud/upload'
import moment from '@nextcloud/moment'

Expand All @@ -105,6 +106,7 @@ export default {
ImagePlus,
NcButton,
NcLoadingIcon,
NcNoteCard,

Check failure on line 109 in src/components/FilesPicker.vue

View workflow job for this annotation

GitHub Actions / eslint

The "NcNoteCard" component has been registered but not used
UploadPicker,
},

Expand Down Expand Up @@ -150,6 +152,7 @@ export default {
uploadContext: {
route: 'albumpicker',
},
currentUser: getCurrentUser().uid,
}
},

Expand Down Expand Up @@ -263,9 +266,18 @@ export default {

&__actions {
display: flex;
flex-direction: column;
justify-content: space-between;
justify-items: center;
padding-top: 16px;
flex-grow: 1;

&__buttons {
display: flex;
align-items: center;
justify-content: end;
gap: 16px;
}
}
}
</style>
1 change: 1 addition & 0 deletions src/mixins/UserConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export default {
? croppedLayoutLocalStorage === 'true'
: loadState('photos', 'croppedLayout', 'false') === 'true',
photosLocation: loadState('photos', 'photosLocation', ''),
photosLocationOwner: loadState('photos', 'photosLocationOwner', ''),
}
},

Expand Down

0 comments on commit e536555

Please sign in to comment.