Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(server): for individual shares not showing thumbnails #15895

Merged
merged 3 commits into from
Feb 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions e2e/src/api/specs/shared-link.e2e-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ describe('/shared-links', () => {
await deleteUserAdmin({ id: user2.userId, userAdminDeleteDto: {} }, { headers: asBearerAuth(admin.accessToken) });
});

describe('GET /share/${key}', () => {
describe('GET /share/:key', () => {
it('should have correct asset count in meta tag for non-empty album', async () => {
const resp = await request(shareUrl).get(`/${linkWithMetadata.key}`);
expect(resp.status).toBe(200);
Expand Down Expand Up @@ -139,7 +139,10 @@ describe('/shared-links', () => {
expect(body).toEqual(
expect.arrayContaining([
expect.objectContaining({ id: linkWithAlbum.id }),
expect.objectContaining({ id: linkWithAssets.id }),
expect.objectContaining({
id: linkWithAssets.id,
assets: expect.arrayContaining([expect.objectContaining({ id: asset1.id })]),
}),
expect.objectContaining({ id: linkWithPassword.id }),
expect.objectContaining({ id: linkWithMetadata.id }),
expect.objectContaining({ id: linkWithoutMetadata.id }),
Expand Down
3 changes: 2 additions & 1 deletion server/src/queries/shared.link.repository.sql
Original file line number Diff line number Diff line change
Expand Up @@ -100,13 +100,14 @@ order by
-- SharedLinkRepository.getAll
select distinct
on ("shared_links"."createdAt") "shared_links".*,
to_json("assets") as "assets",
to_json("album") as "album"
from
"shared_links"
left join "shared_link__asset" on "shared_link__asset"."sharedLinksId" = "shared_links"."id"
left join lateral (
select
"assets".*
json_agg("assets") as "assets"
from
"assets"
where
Expand Down
3 changes: 2 additions & 1 deletion server/src/repositories/shared-link.repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,12 +103,13 @@ export class SharedLinkRepository implements ISharedLinkRepository {
(eb) =>
eb
.selectFrom('assets')
.select((eb) => eb.fn.jsonAgg('assets').as('assets'))
.whereRef('assets.id', '=', 'shared_link__asset.assetsId')
.where('assets.deletedAt', 'is', null)
.selectAll('assets')
.as('assets'),
(join) => join.onTrue(),
)
.select((eb) => eb.fn.toJson('assets').as('assets'))
.leftJoinLateral(
(eb) =>
eb
Expand Down
Loading