mirror of
https://github.com/immich-app/immich.git
synced 2025-06-23 15:34:03 -04:00
* rename albums_shared_users_users to album_permissions and add readonly column * disable synchronize on the original join table * remove unnecessary FK names * set readonly=true as default for new album shares * separate and implement album READ and WRITE permission * expose albumPermissions on the API, deprecate sharedUsers * generate openapi * create readonly view on frontend * ??? move slideshow button out from ellipsis menu so that non-owners can have access too * correct sharedUsers joins * add album permission repository * remove a log * fix assetCount getting reset when adding users * fix lint * add set permission endpoint and UI * sort users * remove log * Revert "??? move slideshow button out from ellipsis menu so that non-owners can have access too" This reverts commit 1343bfa31125f7136f81db28f7aa4c5ef0204847. * rename stuff * fix db schema annotations * sql generate * change readonly default to follow migration * fix deprecation notice * change readonly boolean to role enum * fix joincolumn as primary key * rename albumUserRepository in album service * clean up userId and albumId * add write access to shared link * fix existing tests * switch to vitest * format and fix tests on web * add new test * fix one e2e test * rename new API field to albumUsers * capitalize serverside enum * remove unused ReadWrite type * missed rename from previous commit * rename to albumUsers in album entity as well * remove outdated Equals calls * unnecessary relation * rename to updateUser in album service * minor renamery * move sorting to backend * rename and separate ALBUM_WRITE as ADD_ASSET and REMOVE_ASSET * fix tests * fix "should migrate single moving picture" test failing on European system timezone * generated changes after merge * lint fix * fix correct page to open after removing user from album * fix e2e tests and some bugs * rename updateAlbumUser rest endpoint * add new e2e tests for updateAlbumUser endpoint * small optimizations * refactor album e2e test, add new album shared with viewer * add new test to check if viewer can see the album * add new e2e tests for readonly share * failing test: User delete doesn't cascade to UserAlbum entity * fix: handle deleted users * use lodash for sort * add role to addUsersToAlbum endpoint * add UI for adding editors * lint fixes * change role back to editor as DB default * fix server tests * redesign user selection modal editor selector * style tweaks * fix type error * Revert "style tweaks" This reverts commit ab604f4c8f3a6f12ab0b5fe2dd2ede723aa68775. * Revert "redesign user selection modal editor selector" This reverts commit e6f344856c6c05e4eb5c78f0dffb9f52498795f4. * chore: cleanup and improve add user modal * chore: open api * small styling --------- Co-authored-by: mgabor <> Co-authored-by: Jason Rasmussen <jrasm91@gmail.com> Co-authored-by: Alex Tran <alex.tran1502@gmail.com>
273 lines
7.2 KiB
SQL
273 lines
7.2 KiB
SQL
-- NOTE: This file is auto generated by ./sql-generator
|
|
|
|
-- AccessRepository.activity.checkOwnerAccess
|
|
SELECT
|
|
"ActivityEntity"."id" AS "ActivityEntity_id"
|
|
FROM
|
|
"activity" "ActivityEntity"
|
|
WHERE
|
|
(
|
|
("ActivityEntity"."id" IN ($1))
|
|
AND ("ActivityEntity"."userId" = $2)
|
|
)
|
|
|
|
-- AccessRepository.activity.checkAlbumOwnerAccess
|
|
SELECT
|
|
"ActivityEntity"."id" AS "ActivityEntity_id"
|
|
FROM
|
|
"activity" "ActivityEntity"
|
|
LEFT JOIN "albums" "ActivityEntity__ActivityEntity_album" ON "ActivityEntity__ActivityEntity_album"."id" = "ActivityEntity"."albumId"
|
|
AND (
|
|
"ActivityEntity__ActivityEntity_album"."deletedAt" IS NULL
|
|
)
|
|
WHERE
|
|
(
|
|
("ActivityEntity"."id" IN ($1))
|
|
AND (
|
|
(
|
|
(
|
|
"ActivityEntity__ActivityEntity_album"."ownerId" = $2
|
|
)
|
|
)
|
|
)
|
|
)
|
|
|
|
-- AccessRepository.activity.checkCreateAccess
|
|
SELECT
|
|
"album"."id" AS "album_id"
|
|
FROM
|
|
"albums" "album"
|
|
LEFT JOIN "albums_shared_users_users" "album_albumUsers_users" ON "album_albumUsers_users"."albumsId" = "album"."id"
|
|
LEFT JOIN "users" "albumUsers" ON "albumUsers"."id" = "album_albumUsers_users"."usersId"
|
|
AND ("albumUsers"."deletedAt" IS NULL)
|
|
WHERE
|
|
(
|
|
"album"."id" IN ($1)
|
|
AND "album"."isActivityEnabled" = true
|
|
AND (
|
|
"album"."ownerId" = $2
|
|
OR "albumUsers"."id" = $2
|
|
)
|
|
)
|
|
AND ("album"."deletedAt" IS NULL)
|
|
|
|
-- AccessRepository.album.checkOwnerAccess
|
|
SELECT
|
|
"AlbumEntity"."id" AS "AlbumEntity_id"
|
|
FROM
|
|
"albums" "AlbumEntity"
|
|
WHERE
|
|
(
|
|
(
|
|
("AlbumEntity"."id" IN ($1))
|
|
AND ("AlbumEntity"."ownerId" = $2)
|
|
)
|
|
)
|
|
AND ("AlbumEntity"."deletedAt" IS NULL)
|
|
|
|
-- AccessRepository.album.checkSharedAlbumAccess
|
|
SELECT
|
|
"AlbumEntity"."id" AS "AlbumEntity_id"
|
|
FROM
|
|
"albums" "AlbumEntity"
|
|
LEFT JOIN "albums_shared_users_users" "AlbumEntity__AlbumEntity_albumUsers" ON "AlbumEntity__AlbumEntity_albumUsers"."albumsId" = "AlbumEntity"."id"
|
|
LEFT JOIN "users" "a641d58cf46d4a391ba060ac4dc337665c69ffea" ON "a641d58cf46d4a391ba060ac4dc337665c69ffea"."id" = "AlbumEntity__AlbumEntity_albumUsers"."usersId"
|
|
AND (
|
|
"a641d58cf46d4a391ba060ac4dc337665c69ffea"."deletedAt" IS NULL
|
|
)
|
|
WHERE
|
|
(
|
|
(
|
|
("AlbumEntity"."id" IN ($1))
|
|
AND (
|
|
(
|
|
(
|
|
(
|
|
(
|
|
"a641d58cf46d4a391ba060ac4dc337665c69ffea"."id" = $2
|
|
)
|
|
)
|
|
)
|
|
AND (
|
|
"AlbumEntity__AlbumEntity_albumUsers"."role" IN ($3, $4)
|
|
)
|
|
)
|
|
)
|
|
)
|
|
)
|
|
AND ("AlbumEntity"."deletedAt" IS NULL)
|
|
|
|
-- AccessRepository.album.checkSharedLinkAccess
|
|
SELECT
|
|
"SharedLinkEntity"."albumId" AS "SharedLinkEntity_albumId",
|
|
"SharedLinkEntity"."id" AS "SharedLinkEntity_id"
|
|
FROM
|
|
"shared_links" "SharedLinkEntity"
|
|
WHERE
|
|
(
|
|
("SharedLinkEntity"."id" = $1)
|
|
AND ("SharedLinkEntity"."albumId" IN ($2))
|
|
)
|
|
|
|
-- AccessRepository.asset.checkAlbumAccess
|
|
SELECT
|
|
"asset"."id" AS "assetId",
|
|
"asset"."livePhotoVideoId" AS "livePhotoVideoId"
|
|
FROM
|
|
"albums" "album"
|
|
INNER JOIN "albums_assets_assets" "album_asset" ON "album_asset"."albumsId" = "album"."id"
|
|
INNER JOIN "assets" "asset" ON "asset"."id" = "album_asset"."assetsId"
|
|
AND ("asset"."deletedAt" IS NULL)
|
|
LEFT JOIN "albums_shared_users_users" "album_albumUsers_users" ON "album_albumUsers_users"."albumsId" = "album"."id"
|
|
LEFT JOIN "users" "albumUsers" ON "albumUsers"."id" = "album_albumUsers_users"."usersId"
|
|
AND ("albumUsers"."deletedAt" IS NULL)
|
|
WHERE
|
|
(
|
|
array["asset"."id", "asset"."livePhotoVideoId"] && array[$1]::uuid []
|
|
AND (
|
|
"album"."ownerId" = $2
|
|
OR "albumUsers"."id" = $2
|
|
)
|
|
)
|
|
AND ("album"."deletedAt" IS NULL)
|
|
|
|
-- AccessRepository.asset.checkOwnerAccess
|
|
SELECT
|
|
"AssetEntity"."id" AS "AssetEntity_id"
|
|
FROM
|
|
"assets" "AssetEntity"
|
|
WHERE
|
|
(
|
|
("AssetEntity"."id" IN ($1))
|
|
AND ("AssetEntity"."ownerId" = $2)
|
|
)
|
|
|
|
-- AccessRepository.asset.checkPartnerAccess
|
|
SELECT
|
|
"asset"."id" AS "assetId"
|
|
FROM
|
|
"partners" "partner"
|
|
INNER JOIN "users" "sharedBy" ON "sharedBy"."id" = "partner"."sharedById"
|
|
AND ("sharedBy"."deletedAt" IS NULL)
|
|
INNER JOIN "assets" "asset" ON "asset"."ownerId" = "sharedBy"."id"
|
|
AND ("asset"."deletedAt" IS NULL)
|
|
WHERE
|
|
"partner"."sharedWithId" = $1
|
|
AND "asset"."id" IN ($2)
|
|
|
|
-- AccessRepository.asset.checkSharedLinkAccess
|
|
SELECT
|
|
"assets"."id" AS "assetId",
|
|
"assets"."livePhotoVideoId" AS "assetLivePhotoVideoId",
|
|
"albumAssets"."id" AS "albumAssetId",
|
|
"albumAssets"."livePhotoVideoId" AS "albumAssetLivePhotoVideoId"
|
|
FROM
|
|
"shared_links" "sharedLink"
|
|
LEFT JOIN "albums" "album" ON "album"."id" = "sharedLink"."albumId"
|
|
AND ("album"."deletedAt" IS NULL)
|
|
LEFT JOIN "shared_link__asset" "assets_sharedLink" ON "assets_sharedLink"."sharedLinksId" = "sharedLink"."id"
|
|
LEFT JOIN "assets" "assets" ON "assets"."id" = "assets_sharedLink"."assetsId"
|
|
AND ("assets"."deletedAt" IS NULL)
|
|
LEFT JOIN "albums_assets_assets" "album_albumAssets" ON "album_albumAssets"."albumsId" = "album"."id"
|
|
LEFT JOIN "assets" "albumAssets" ON "albumAssets"."id" = "album_albumAssets"."assetsId"
|
|
AND ("albumAssets"."deletedAt" IS NULL)
|
|
WHERE
|
|
"sharedLink"."id" = $1
|
|
AND array[
|
|
"assets"."id",
|
|
"assets"."livePhotoVideoId",
|
|
"albumAssets"."id",
|
|
"albumAssets"."livePhotoVideoId"
|
|
] && array[$2]::uuid []
|
|
|
|
-- AccessRepository.authDevice.checkOwnerAccess
|
|
SELECT
|
|
"SessionEntity"."id" AS "SessionEntity_id"
|
|
FROM
|
|
"sessions" "SessionEntity"
|
|
WHERE
|
|
(
|
|
("SessionEntity"."userId" = $1)
|
|
AND ("SessionEntity"."id" IN ($2))
|
|
)
|
|
|
|
-- AccessRepository.library.checkOwnerAccess
|
|
SELECT
|
|
"LibraryEntity"."id" AS "LibraryEntity_id"
|
|
FROM
|
|
"libraries" "LibraryEntity"
|
|
WHERE
|
|
(
|
|
(
|
|
("LibraryEntity"."id" IN ($1))
|
|
AND ("LibraryEntity"."ownerId" = $2)
|
|
)
|
|
)
|
|
AND ("LibraryEntity"."deletedAt" IS NULL)
|
|
|
|
-- AccessRepository.memory.checkOwnerAccess
|
|
SELECT
|
|
"MemoryEntity"."id" AS "MemoryEntity_id"
|
|
FROM
|
|
"memories" "MemoryEntity"
|
|
WHERE
|
|
(
|
|
(
|
|
("MemoryEntity"."id" IN ($1))
|
|
AND ("MemoryEntity"."ownerId" = $2)
|
|
)
|
|
)
|
|
AND ("MemoryEntity"."deletedAt" IS NULL)
|
|
|
|
-- AccessRepository.person.checkOwnerAccess
|
|
SELECT
|
|
"PersonEntity"."id" AS "PersonEntity_id"
|
|
FROM
|
|
"person" "PersonEntity"
|
|
WHERE
|
|
(
|
|
("PersonEntity"."id" IN ($1))
|
|
AND ("PersonEntity"."ownerId" = $2)
|
|
)
|
|
|
|
-- AccessRepository.person.checkFaceOwnerAccess
|
|
SELECT
|
|
"AssetFaceEntity"."id" AS "AssetFaceEntity_id"
|
|
FROM
|
|
"asset_faces" "AssetFaceEntity"
|
|
LEFT JOIN "assets" "AssetFaceEntity__AssetFaceEntity_asset" ON "AssetFaceEntity__AssetFaceEntity_asset"."id" = "AssetFaceEntity"."assetId"
|
|
AND (
|
|
"AssetFaceEntity__AssetFaceEntity_asset"."deletedAt" IS NULL
|
|
)
|
|
WHERE
|
|
(
|
|
("AssetFaceEntity"."id" IN ($1))
|
|
AND (
|
|
(
|
|
(
|
|
"AssetFaceEntity__AssetFaceEntity_asset"."ownerId" = $2
|
|
)
|
|
)
|
|
)
|
|
)
|
|
|
|
-- AccessRepository.partner.checkUpdateAccess
|
|
SELECT
|
|
"partner"."sharedById" AS "partner_sharedById",
|
|
"partner"."sharedWithId" AS "partner_sharedWithId"
|
|
FROM
|
|
"partners" "partner"
|
|
WHERE
|
|
"partner"."sharedById" IN ($1)
|
|
AND "partner"."sharedWithId" = $2
|
|
|
|
-- AccessRepository.timeline.checkPartnerAccess
|
|
SELECT
|
|
"partner"."sharedById" AS "partner_sharedById",
|
|
"partner"."sharedWithId" AS "partner_sharedWithId"
|
|
FROM
|
|
"partners" "partner"
|
|
WHERE
|
|
"partner"."sharedById" IN ($1)
|
|
AND "partner"."sharedWithId" = $2
|