fix(server): include album owner for album shared links (#31990)

fix(server): include album owner for album shared links (#31837)

(cherry picked from commit fd97f3e5a62a4af1a8e17d2e766eb952eefae24a)

Co-authored-by: Mees Frensel <33722705+meesfrensel@users.noreply.github.com>
This commit is contained in:
immich-push-o-matic[bot]
2026-10-01 17:06:45 +00:00
committed by GitHub
co-authored by Mees Frensel
parent 882da7cab8
commit 843051f0f5
3 changed files with 87 additions and 69 deletions
@@ -1,6 +1,6 @@
import { Kysely } from 'kysely';
import { randomBytes } from 'node:crypto';
import { SharedLinkType } from 'src/enum.js';
import { AlbumUserRole, SharedLinkType } from 'src/enum.js';
import { AccessRepository } from 'src/repositories/access.repository.js';
import { DatabaseRepository } from 'src/repositories/database.repository.js';
import { LoggingRepository } from 'src/repositories/logging.repository.js';
@@ -236,12 +236,14 @@ describe(SharedLinkService.name, () => {
expect(result[0].id).toBe(link1.id);
});
it('should return album shared links with album data', async () => {
it('should return album shared links with album data and (only) the owner', async () => {
const { sut, ctx } = setup();
const { user } = await ctx.newUser();
const { user: albumContributor } = await ctx.newUser();
const auth = factory.auth({ user });
const { album } = await ctx.newAlbum({ ownerId: user.id });
await ctx.newAlbumUser({ albumId: album.id, userId: albumContributor.id, role: AlbumUserRole.Editor });
const sharedLinkRepo = ctx.get(SharedLinkRepository);
@@ -258,6 +260,9 @@ describe(SharedLinkService.name, () => {
expect(result).toHaveLength(1);
expect(result[0].album).toBeDefined();
expect(result[0].album!.id).toBe(album.id);
expect(result[0].album!.albumUsers.length).toBe(1);
expect(result[0].album!.albumUsers[0].role).toBe(AlbumUserRole.Owner);
expect(result[0].album!.albumUsers[0].user.id).toBe(user.id);
});
it('should return multiple album shared links without sql error from json group by', async () => {