mirror of
https://github.com/immich-app/immich.git
synced 2025-03-25 02:41:37 -05:00
fix: and same results as other methods
This commit is contained in:
parent
cb70c79546
commit
068d6b3f2f
2 changed files with 34 additions and 13 deletions
|
@ -529,12 +529,11 @@ FROM
|
|||
LEFT JOIN "users" "owner" ON "owner"."id" = "album"."ownerId"
|
||||
AND ("owner"."deletedAt" IS NULL)
|
||||
LEFT JOIN "albums_shared_users_users" "album_users" ON "album_users"."albumsId" = "album"."id"
|
||||
LEFT JOIN "users" "user" ON "user"."id" = "album_users"."usersId"
|
||||
AND ("user"."deletedAt" IS NULL)
|
||||
WHERE
|
||||
(
|
||||
(
|
||||
"album"."ownerId" = $1
|
||||
OR "album_users"."usersId" = $1
|
||||
)
|
||||
("album"."ownerId" = $1)
|
||||
AND (
|
||||
LOWER("album"."albumName") LIKE $2
|
||||
OR LOWER("album"."albumName") LIKE $3
|
||||
|
@ -566,18 +565,35 @@ SELECT
|
|||
"owner"."updatedAt" AS "owner_updatedAt",
|
||||
"owner"."quotaSizeInBytes" AS "owner_quotaSizeInBytes",
|
||||
"owner"."quotaUsageInBytes" AS "owner_quotaUsageInBytes",
|
||||
"owner"."profileChangedAt" AS "owner_profileChangedAt"
|
||||
"owner"."profileChangedAt" AS "owner_profileChangedAt",
|
||||
"album_users"."albumsId" AS "album_users_albumsId",
|
||||
"album_users"."usersId" AS "album_users_usersId",
|
||||
"album_users"."role" AS "album_users_role",
|
||||
"user"."id" AS "user_id",
|
||||
"user"."name" AS "user_name",
|
||||
"user"."isAdmin" AS "user_isAdmin",
|
||||
"user"."email" AS "user_email",
|
||||
"user"."storageLabel" AS "user_storageLabel",
|
||||
"user"."oauthId" AS "user_oauthId",
|
||||
"user"."profileImagePath" AS "user_profileImagePath",
|
||||
"user"."shouldChangePassword" AS "user_shouldChangePassword",
|
||||
"user"."createdAt" AS "user_createdAt",
|
||||
"user"."deletedAt" AS "user_deletedAt",
|
||||
"user"."status" AS "user_status",
|
||||
"user"."updatedAt" AS "user_updatedAt",
|
||||
"user"."quotaSizeInBytes" AS "user_quotaSizeInBytes",
|
||||
"user"."quotaUsageInBytes" AS "user_quotaUsageInBytes",
|
||||
"user"."profileChangedAt" AS "user_profileChangedAt"
|
||||
FROM
|
||||
"albums" "album"
|
||||
LEFT JOIN "users" "owner" ON "owner"."id" = "album"."ownerId"
|
||||
AND ("owner"."deletedAt" IS NULL)
|
||||
LEFT JOIN "albums_shared_users_users" "album_users" ON "album_users"."albumsId" = "album"."id"
|
||||
LEFT JOIN "users" "user" ON "user"."id" = "album_users"."usersId"
|
||||
AND ("user"."deletedAt" IS NULL)
|
||||
WHERE
|
||||
(
|
||||
(
|
||||
"album"."ownerId" = $1
|
||||
OR "album_users"."usersId" = $1
|
||||
)
|
||||
("album"."ownerId" = $1)
|
||||
AND (
|
||||
LOWER("album"."albumName") LIKE $2
|
||||
OR LOWER("album"."albumName") LIKE $3
|
||||
|
|
|
@ -315,7 +315,11 @@ export class AlbumRepository implements IAlbumRepository {
|
|||
const getAlbumSharedOptions = () => {
|
||||
switch (shared) {
|
||||
case true: {
|
||||
return { owner: '(album_users.usersId = :userId)', options: '' };
|
||||
return {
|
||||
owner:
|
||||
'(album_users.usersId = :userId OR shared_links.userId = :userId OR (album.ownerId = :userId AND album_users.usersId IS NOT NULL))',
|
||||
options: '',
|
||||
};
|
||||
}
|
||||
case false: {
|
||||
return {
|
||||
|
@ -324,7 +328,7 @@ export class AlbumRepository implements IAlbumRepository {
|
|||
};
|
||||
}
|
||||
case undefined: {
|
||||
return { owner: '(album.ownerId = :userId OR album_users.usersId = :userId)', options: '' };
|
||||
return { owner: '(album.ownerId = :userId)', options: '' };
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -334,9 +338,10 @@ export class AlbumRepository implements IAlbumRepository {
|
|||
let queryBuilder = this.repository
|
||||
.createQueryBuilder('album')
|
||||
.leftJoinAndSelect('album.owner', 'owner')
|
||||
.leftJoin('albums_shared_users_users', 'album_users', 'album_users.albumsId = album.id');
|
||||
.leftJoinAndSelect('album.albumUsers', 'album_users')
|
||||
.leftJoinAndSelect('album_users.user', 'user');
|
||||
|
||||
if (shared === false) {
|
||||
if (shared !== undefined) {
|
||||
queryBuilder = queryBuilder.leftJoin('shared_links', 'shared_links', 'shared_links.albumId = album.id');
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue