mirror of
https://github.com/immich-app/immich.git
synced 2025-07-09 03:04:16 -04:00
fix: and same results as other methods
This commit is contained in:
parent
cb70c79546
commit
068d6b3f2f
@ -529,12 +529,11 @@ FROM
|
|||||||
LEFT JOIN "users" "owner" ON "owner"."id" = "album"."ownerId"
|
LEFT JOIN "users" "owner" ON "owner"."id" = "album"."ownerId"
|
||||||
AND ("owner"."deletedAt" IS NULL)
|
AND ("owner"."deletedAt" IS NULL)
|
||||||
LEFT JOIN "albums_shared_users_users" "album_users" ON "album_users"."albumsId" = "album"."id"
|
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
|
WHERE
|
||||||
(
|
(
|
||||||
(
|
("album"."ownerId" = $1)
|
||||||
"album"."ownerId" = $1
|
|
||||||
OR "album_users"."usersId" = $1
|
|
||||||
)
|
|
||||||
AND (
|
AND (
|
||||||
LOWER("album"."albumName") LIKE $2
|
LOWER("album"."albumName") LIKE $2
|
||||||
OR LOWER("album"."albumName") LIKE $3
|
OR LOWER("album"."albumName") LIKE $3
|
||||||
@ -566,18 +565,35 @@ SELECT
|
|||||||
"owner"."updatedAt" AS "owner_updatedAt",
|
"owner"."updatedAt" AS "owner_updatedAt",
|
||||||
"owner"."quotaSizeInBytes" AS "owner_quotaSizeInBytes",
|
"owner"."quotaSizeInBytes" AS "owner_quotaSizeInBytes",
|
||||||
"owner"."quotaUsageInBytes" AS "owner_quotaUsageInBytes",
|
"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
|
FROM
|
||||||
"albums" "album"
|
"albums" "album"
|
||||||
LEFT JOIN "users" "owner" ON "owner"."id" = "album"."ownerId"
|
LEFT JOIN "users" "owner" ON "owner"."id" = "album"."ownerId"
|
||||||
AND ("owner"."deletedAt" IS NULL)
|
AND ("owner"."deletedAt" IS NULL)
|
||||||
LEFT JOIN "albums_shared_users_users" "album_users" ON "album_users"."albumsId" = "album"."id"
|
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
|
WHERE
|
||||||
(
|
(
|
||||||
(
|
("album"."ownerId" = $1)
|
||||||
"album"."ownerId" = $1
|
|
||||||
OR "album_users"."usersId" = $1
|
|
||||||
)
|
|
||||||
AND (
|
AND (
|
||||||
LOWER("album"."albumName") LIKE $2
|
LOWER("album"."albumName") LIKE $2
|
||||||
OR LOWER("album"."albumName") LIKE $3
|
OR LOWER("album"."albumName") LIKE $3
|
||||||
|
@ -315,7 +315,11 @@ export class AlbumRepository implements IAlbumRepository {
|
|||||||
const getAlbumSharedOptions = () => {
|
const getAlbumSharedOptions = () => {
|
||||||
switch (shared) {
|
switch (shared) {
|
||||||
case true: {
|
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: {
|
case false: {
|
||||||
return {
|
return {
|
||||||
@ -324,7 +328,7 @@ export class AlbumRepository implements IAlbumRepository {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
case undefined: {
|
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
|
let queryBuilder = this.repository
|
||||||
.createQueryBuilder('album')
|
.createQueryBuilder('album')
|
||||||
.leftJoinAndSelect('album.owner', 'owner')
|
.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');
|
queryBuilder = queryBuilder.leftJoin('shared_links', 'shared_links', 'shared_links.albumId = album.id');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user