mirror of
https://github.com/immich-app/immich.git
synced 2026-05-18 03:10:24 +03:00
refactor: database column names (#23356)
This commit is contained in:
@@ -402,16 +402,16 @@ describe(AlbumService.name, () => {
|
||||
mocks.album.update.mockResolvedValue(albumStub.sharedWithAdmin);
|
||||
mocks.user.get.mockResolvedValue(userStub.user2);
|
||||
mocks.albumUser.create.mockResolvedValue({
|
||||
usersId: userStub.user2.id,
|
||||
albumsId: albumStub.sharedWithAdmin.id,
|
||||
userId: userStub.user2.id,
|
||||
albumId: albumStub.sharedWithAdmin.id,
|
||||
role: AlbumUserRole.Editor,
|
||||
});
|
||||
await sut.addUsers(authStub.user1, albumStub.sharedWithAdmin.id, {
|
||||
albumUsers: [{ userId: authStub.user2.user.id }],
|
||||
});
|
||||
expect(mocks.albumUser.create).toHaveBeenCalledWith({
|
||||
usersId: authStub.user2.user.id,
|
||||
albumsId: albumStub.sharedWithAdmin.id,
|
||||
userId: authStub.user2.user.id,
|
||||
albumId: albumStub.sharedWithAdmin.id,
|
||||
});
|
||||
expect(mocks.event.emit).toHaveBeenCalledWith('AlbumInvite', {
|
||||
id: albumStub.sharedWithAdmin.id,
|
||||
@@ -439,8 +439,8 @@ describe(AlbumService.name, () => {
|
||||
|
||||
expect(mocks.albumUser.delete).toHaveBeenCalledTimes(1);
|
||||
expect(mocks.albumUser.delete).toHaveBeenCalledWith({
|
||||
albumsId: albumStub.sharedWithUser.id,
|
||||
usersId: userStub.user1.id,
|
||||
albumId: albumStub.sharedWithUser.id,
|
||||
userId: userStub.user1.id,
|
||||
});
|
||||
expect(mocks.album.getById).toHaveBeenCalledWith(albumStub.sharedWithUser.id, { withAssets: false });
|
||||
});
|
||||
@@ -467,8 +467,8 @@ describe(AlbumService.name, () => {
|
||||
|
||||
expect(mocks.albumUser.delete).toHaveBeenCalledTimes(1);
|
||||
expect(mocks.albumUser.delete).toHaveBeenCalledWith({
|
||||
albumsId: albumStub.sharedWithUser.id,
|
||||
usersId: authStub.user1.user.id,
|
||||
albumId: albumStub.sharedWithUser.id,
|
||||
userId: authStub.user1.user.id,
|
||||
});
|
||||
});
|
||||
|
||||
@@ -480,8 +480,8 @@ describe(AlbumService.name, () => {
|
||||
|
||||
expect(mocks.albumUser.delete).toHaveBeenCalledTimes(1);
|
||||
expect(mocks.albumUser.delete).toHaveBeenCalledWith({
|
||||
albumsId: albumStub.sharedWithUser.id,
|
||||
usersId: authStub.user1.user.id,
|
||||
albumId: albumStub.sharedWithUser.id,
|
||||
userId: authStub.user1.user.id,
|
||||
});
|
||||
});
|
||||
|
||||
@@ -515,7 +515,7 @@ describe(AlbumService.name, () => {
|
||||
role: AlbumUserRole.Editor,
|
||||
});
|
||||
expect(mocks.albumUser.update).toHaveBeenCalledWith(
|
||||
{ albumsId: albumStub.sharedWithAdmin.id, usersId: userStub.admin.id },
|
||||
{ albumId: albumStub.sharedWithAdmin.id, userId: userStub.admin.id },
|
||||
{ role: AlbumUserRole.Editor },
|
||||
);
|
||||
});
|
||||
@@ -804,12 +804,12 @@ describe(AlbumService.name, () => {
|
||||
albumThumbnailAssetId: 'asset-1',
|
||||
});
|
||||
expect(mocks.album.addAssetIdsToAlbums).toHaveBeenCalledWith([
|
||||
{ albumsId: 'album-123', assetsId: 'asset-1' },
|
||||
{ albumsId: 'album-123', assetsId: 'asset-2' },
|
||||
{ albumsId: 'album-123', assetsId: 'asset-3' },
|
||||
{ albumsId: 'album-321', assetsId: 'asset-1' },
|
||||
{ albumsId: 'album-321', assetsId: 'asset-2' },
|
||||
{ albumsId: 'album-321', assetsId: 'asset-3' },
|
||||
{ albumId: 'album-123', assetId: 'asset-1' },
|
||||
{ albumId: 'album-123', assetId: 'asset-2' },
|
||||
{ albumId: 'album-123', assetId: 'asset-3' },
|
||||
{ albumId: 'album-321', assetId: 'asset-1' },
|
||||
{ albumId: 'album-321', assetId: 'asset-2' },
|
||||
{ albumId: 'album-321', assetId: 'asset-3' },
|
||||
]);
|
||||
});
|
||||
|
||||
@@ -840,12 +840,12 @@ describe(AlbumService.name, () => {
|
||||
albumThumbnailAssetId: 'asset-id',
|
||||
});
|
||||
expect(mocks.album.addAssetIdsToAlbums).toHaveBeenCalledWith([
|
||||
{ albumsId: 'album-123', assetsId: 'asset-1' },
|
||||
{ albumsId: 'album-123', assetsId: 'asset-2' },
|
||||
{ albumsId: 'album-123', assetsId: 'asset-3' },
|
||||
{ albumsId: 'album-321', assetsId: 'asset-1' },
|
||||
{ albumsId: 'album-321', assetsId: 'asset-2' },
|
||||
{ albumsId: 'album-321', assetsId: 'asset-3' },
|
||||
{ albumId: 'album-123', assetId: 'asset-1' },
|
||||
{ albumId: 'album-123', assetId: 'asset-2' },
|
||||
{ albumId: 'album-123', assetId: 'asset-3' },
|
||||
{ albumId: 'album-321', assetId: 'asset-1' },
|
||||
{ albumId: 'album-321', assetId: 'asset-2' },
|
||||
{ albumId: 'album-321', assetId: 'asset-3' },
|
||||
]);
|
||||
});
|
||||
|
||||
@@ -876,12 +876,12 @@ describe(AlbumService.name, () => {
|
||||
albumThumbnailAssetId: 'asset-1',
|
||||
});
|
||||
expect(mocks.album.addAssetIdsToAlbums).toHaveBeenCalledWith([
|
||||
{ albumsId: 'album-123', assetsId: 'asset-1' },
|
||||
{ albumsId: 'album-123', assetsId: 'asset-2' },
|
||||
{ albumsId: 'album-123', assetsId: 'asset-3' },
|
||||
{ albumsId: 'album-321', assetsId: 'asset-1' },
|
||||
{ albumsId: 'album-321', assetsId: 'asset-2' },
|
||||
{ albumsId: 'album-321', assetsId: 'asset-3' },
|
||||
{ albumId: 'album-123', assetId: 'asset-1' },
|
||||
{ albumId: 'album-123', assetId: 'asset-2' },
|
||||
{ albumId: 'album-123', assetId: 'asset-3' },
|
||||
{ albumId: 'album-321', assetId: 'asset-1' },
|
||||
{ albumId: 'album-321', assetId: 'asset-2' },
|
||||
{ albumId: 'album-321', assetId: 'asset-3' },
|
||||
]);
|
||||
expect(mocks.event.emit).toHaveBeenCalledWith('AlbumUpdate', {
|
||||
id: 'album-123',
|
||||
@@ -936,9 +936,9 @@ describe(AlbumService.name, () => {
|
||||
albumThumbnailAssetId: 'asset-1',
|
||||
});
|
||||
expect(mocks.album.addAssetIdsToAlbums).toHaveBeenCalledWith([
|
||||
{ albumsId: 'album-123', assetsId: 'asset-1' },
|
||||
{ albumsId: 'album-123', assetsId: 'asset-2' },
|
||||
{ albumsId: 'album-123', assetsId: 'asset-3' },
|
||||
{ albumId: 'album-123', assetId: 'asset-1' },
|
||||
{ albumId: 'album-123', assetId: 'asset-2' },
|
||||
{ albumId: 'album-123', assetId: 'asset-3' },
|
||||
]);
|
||||
expect(mocks.event.emit).toHaveBeenCalledWith('AlbumUpdate', {
|
||||
id: 'album-123',
|
||||
@@ -977,12 +977,12 @@ describe(AlbumService.name, () => {
|
||||
albumThumbnailAssetId: 'asset-1',
|
||||
});
|
||||
expect(mocks.album.addAssetIdsToAlbums).toHaveBeenCalledWith([
|
||||
{ albumsId: 'album-123', assetsId: 'asset-1' },
|
||||
{ albumsId: 'album-123', assetsId: 'asset-2' },
|
||||
{ albumsId: 'album-123', assetsId: 'asset-3' },
|
||||
{ albumsId: 'album-321', assetsId: 'asset-1' },
|
||||
{ albumsId: 'album-321', assetsId: 'asset-2' },
|
||||
{ albumsId: 'album-321', assetsId: 'asset-3' },
|
||||
{ albumId: 'album-123', assetId: 'asset-1' },
|
||||
{ albumId: 'album-123', assetId: 'asset-2' },
|
||||
{ albumId: 'album-123', assetId: 'asset-3' },
|
||||
{ albumId: 'album-321', assetId: 'asset-1' },
|
||||
{ albumId: 'album-321', assetId: 'asset-2' },
|
||||
{ albumId: 'album-321', assetId: 'asset-3' },
|
||||
]);
|
||||
expect(mocks.access.asset.checkPartnerAccess).toHaveBeenCalledWith(
|
||||
authStub.admin.user.id,
|
||||
@@ -1014,9 +1014,9 @@ describe(AlbumService.name, () => {
|
||||
albumThumbnailAssetId: 'asset-1',
|
||||
});
|
||||
expect(mocks.album.addAssetIdsToAlbums).toHaveBeenCalledWith([
|
||||
{ albumsId: 'album-321', assetsId: 'asset-1' },
|
||||
{ albumsId: 'album-321', assetsId: 'asset-2' },
|
||||
{ albumsId: 'album-321', assetsId: 'asset-3' },
|
||||
{ albumId: 'album-321', assetId: 'asset-1' },
|
||||
{ albumId: 'album-321', assetId: 'asset-2' },
|
||||
{ albumId: 'album-321', assetId: 'asset-3' },
|
||||
]);
|
||||
});
|
||||
|
||||
|
||||
@@ -215,7 +215,7 @@ export class AlbumService extends BaseService {
|
||||
return results;
|
||||
}
|
||||
|
||||
const albumAssetValues: { albumsId: string; assetsId: string }[] = [];
|
||||
const albumAssetValues: { albumId: string; assetId: string }[] = [];
|
||||
const events: { id: string; recipients: string[] }[] = [];
|
||||
for (const albumId of allowedAlbumIds) {
|
||||
const existingAssetIds = await this.albumRepository.getAssetIds(albumId, [...allowedAssetIds]);
|
||||
@@ -228,7 +228,7 @@ export class AlbumService extends BaseService {
|
||||
results.success = true;
|
||||
|
||||
for (const assetId of notPresentAssetIds) {
|
||||
albumAssetValues.push({ albumsId: albumId, assetsId: assetId });
|
||||
albumAssetValues.push({ albumId, assetId });
|
||||
}
|
||||
await this.albumRepository.update(albumId, {
|
||||
id: albumId,
|
||||
@@ -289,7 +289,7 @@ export class AlbumService extends BaseService {
|
||||
throw new BadRequestException('User not found');
|
||||
}
|
||||
|
||||
await this.albumUserRepository.create({ usersId: userId, albumsId: id, role });
|
||||
await this.albumUserRepository.create({ userId, albumId: id, role });
|
||||
await this.eventRepository.emit('AlbumInvite', { id, userId });
|
||||
}
|
||||
|
||||
@@ -317,12 +317,12 @@ export class AlbumService extends BaseService {
|
||||
await this.requireAccess({ auth, permission: Permission.AlbumShare, ids: [id] });
|
||||
}
|
||||
|
||||
await this.albumUserRepository.delete({ albumsId: id, usersId: userId });
|
||||
await this.albumUserRepository.delete({ albumId: id, userId });
|
||||
}
|
||||
|
||||
async updateUser(auth: AuthDto, id: string, userId: string, dto: UpdateAlbumUserDto): Promise<void> {
|
||||
await this.requireAccess({ auth, permission: Permission.AlbumShare, ids: [id] });
|
||||
await this.albumUserRepository.update({ albumsId: id, usersId: userId }, { role: dto.role });
|
||||
await this.albumUserRepository.update({ albumId: id, userId }, { role: dto.role });
|
||||
}
|
||||
|
||||
private async findOrFail(id: string, options: AlbumInfoOptions) {
|
||||
|
||||
@@ -192,12 +192,12 @@ describe(TagService.name, () => {
|
||||
mocks.access.tag.checkOwnerAccess.mockResolvedValue(new Set(['tag-1', 'tag-2']));
|
||||
mocks.access.asset.checkOwnerAccess.mockResolvedValue(new Set(['asset-1', 'asset-2', 'asset-3']));
|
||||
mocks.tag.upsertAssetIds.mockResolvedValue([
|
||||
{ tagsId: 'tag-1', assetsId: 'asset-1' },
|
||||
{ tagsId: 'tag-1', assetsId: 'asset-2' },
|
||||
{ tagsId: 'tag-1', assetsId: 'asset-3' },
|
||||
{ tagsId: 'tag-2', assetsId: 'asset-1' },
|
||||
{ tagsId: 'tag-2', assetsId: 'asset-2' },
|
||||
{ tagsId: 'tag-2', assetsId: 'asset-3' },
|
||||
{ tagId: 'tag-1', assetId: 'asset-1' },
|
||||
{ tagId: 'tag-1', assetId: 'asset-2' },
|
||||
{ tagId: 'tag-1', assetId: 'asset-3' },
|
||||
{ tagId: 'tag-2', assetId: 'asset-1' },
|
||||
{ tagId: 'tag-2', assetId: 'asset-2' },
|
||||
{ tagId: 'tag-2', assetId: 'asset-3' },
|
||||
]);
|
||||
await expect(
|
||||
sut.bulkTagAssets(authStub.admin, { tagIds: ['tag-1', 'tag-2'], assetIds: ['asset-1', 'asset-2', 'asset-3'] }),
|
||||
@@ -205,12 +205,12 @@ describe(TagService.name, () => {
|
||||
count: 6,
|
||||
});
|
||||
expect(mocks.tag.upsertAssetIds).toHaveBeenCalledWith([
|
||||
{ tagsId: 'tag-1', assetsId: 'asset-1' },
|
||||
{ tagsId: 'tag-1', assetsId: 'asset-2' },
|
||||
{ tagsId: 'tag-1', assetsId: 'asset-3' },
|
||||
{ tagsId: 'tag-2', assetsId: 'asset-1' },
|
||||
{ tagsId: 'tag-2', assetsId: 'asset-2' },
|
||||
{ tagsId: 'tag-2', assetsId: 'asset-3' },
|
||||
{ tagId: 'tag-1', assetId: 'asset-1' },
|
||||
{ tagId: 'tag-1', assetId: 'asset-2' },
|
||||
{ tagId: 'tag-1', assetId: 'asset-3' },
|
||||
{ tagId: 'tag-2', assetId: 'asset-1' },
|
||||
{ tagId: 'tag-2', assetId: 'asset-2' },
|
||||
{ tagId: 'tag-2', assetId: 'asset-3' },
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -82,14 +82,14 @@ export class TagService extends BaseService {
|
||||
]);
|
||||
|
||||
const items: Insertable<TagAssetTable>[] = [];
|
||||
for (const tagsId of tagIds) {
|
||||
for (const assetsId of assetIds) {
|
||||
items.push({ tagsId, assetsId });
|
||||
for (const tagId of tagIds) {
|
||||
for (const assetId of assetIds) {
|
||||
items.push({ tagId, assetId });
|
||||
}
|
||||
}
|
||||
|
||||
const results = await this.tagRepository.upsertAssetIds(items);
|
||||
for (const assetId of new Set(results.map((item) => item.assetsId))) {
|
||||
for (const assetId of new Set(results.map((item) => item.assetId))) {
|
||||
await this.eventRepository.emit('AssetTag', { assetId });
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user