capitalize serverside enum
This commit is contained in:
@@ -226,7 +226,7 @@ export class AccessCore {
|
|||||||
const isShared = await this.repository.album.checkSharedAlbumAccess(
|
const isShared = await this.repository.album.checkSharedAlbumAccess(
|
||||||
auth.user.id,
|
auth.user.id,
|
||||||
setDifference(ids, isOwner),
|
setDifference(ids, isOwner),
|
||||||
AlbumUserRole.Viewer,
|
AlbumUserRole.VIEWER,
|
||||||
);
|
);
|
||||||
return setUnion(isOwner, isShared);
|
return setUnion(isOwner, isShared);
|
||||||
}
|
}
|
||||||
@@ -236,7 +236,7 @@ export class AccessCore {
|
|||||||
const isShared = await this.repository.album.checkSharedAlbumAccess(
|
const isShared = await this.repository.album.checkSharedAlbumAccess(
|
||||||
auth.user.id,
|
auth.user.id,
|
||||||
setDifference(ids, isOwner),
|
setDifference(ids, isOwner),
|
||||||
AlbumUserRole.Editor,
|
AlbumUserRole.EDITOR,
|
||||||
);
|
);
|
||||||
return setUnion(isOwner, isShared);
|
return setUnion(isOwner, isShared);
|
||||||
}
|
}
|
||||||
@@ -258,7 +258,7 @@ export class AccessCore {
|
|||||||
const isShared = await this.repository.album.checkSharedAlbumAccess(
|
const isShared = await this.repository.album.checkSharedAlbumAccess(
|
||||||
auth.user.id,
|
auth.user.id,
|
||||||
setDifference(ids, isOwner),
|
setDifference(ids, isOwner),
|
||||||
AlbumUserRole.Viewer,
|
AlbumUserRole.VIEWER,
|
||||||
);
|
);
|
||||||
return setUnion(isOwner, isShared);
|
return setUnion(isOwner, isShared);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,8 +3,8 @@ import { UserEntity } from 'src/entities/user.entity';
|
|||||||
import { Column, Entity, Index, JoinColumn, ManyToOne, PrimaryColumn } from 'typeorm';
|
import { Column, Entity, Index, JoinColumn, ManyToOne, PrimaryColumn } from 'typeorm';
|
||||||
|
|
||||||
export enum AlbumUserRole {
|
export enum AlbumUserRole {
|
||||||
Editor = 'editor',
|
EDITOR = 'editor',
|
||||||
Viewer = 'viewer',
|
VIEWER = 'viewer',
|
||||||
}
|
}
|
||||||
|
|
||||||
@Entity('albums_shared_users_users')
|
@Entity('albums_shared_users_users')
|
||||||
|
|||||||
@@ -137,7 +137,7 @@ class AlbumAccess implements IAlbumAccess {
|
|||||||
user: { id: userId },
|
user: { id: userId },
|
||||||
// If editor access is needed we check for it, otherwise both are accepted
|
// If editor access is needed we check for it, otherwise both are accepted
|
||||||
role:
|
role:
|
||||||
access === AlbumUserRole.Editor ? AlbumUserRole.Editor : In([AlbumUserRole.Editor, AlbumUserRole.Viewer]),
|
access === AlbumUserRole.EDITOR ? AlbumUserRole.EDITOR : In([AlbumUserRole.EDITOR, AlbumUserRole.VIEWER]),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -366,7 +366,7 @@ describe(AlbumService.name, () => {
|
|||||||
user: userStub.user2,
|
user: userStub.user2,
|
||||||
albumId: albumStub.sharedWithAdmin.id,
|
albumId: albumStub.sharedWithAdmin.id,
|
||||||
album: albumStub.sharedWithAdmin,
|
album: albumStub.sharedWithAdmin,
|
||||||
role: AlbumUserRole.Editor,
|
role: AlbumUserRole.EDITOR,
|
||||||
});
|
});
|
||||||
await sut.addUsers(authStub.user1, albumStub.sharedWithAdmin.id, { sharedUserIds: [authStub.user2.user.id] });
|
await sut.addUsers(authStub.user1, albumStub.sharedWithAdmin.id, { sharedUserIds: [authStub.user2.user.id] });
|
||||||
expect(albumUserMock.create).toHaveBeenCalledWith({
|
expect(albumUserMock.create).toHaveBeenCalledWith({
|
||||||
@@ -520,7 +520,7 @@ describe(AlbumService.name, () => {
|
|||||||
expect(accessMock.album.checkSharedAlbumAccess).toHaveBeenCalledWith(
|
expect(accessMock.album.checkSharedAlbumAccess).toHaveBeenCalledWith(
|
||||||
authStub.user1.user.id,
|
authStub.user1.user.id,
|
||||||
new Set(['album-123']),
|
new Set(['album-123']),
|
||||||
AlbumUserRole.Viewer,
|
AlbumUserRole.VIEWER,
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -531,7 +531,7 @@ describe(AlbumService.name, () => {
|
|||||||
expect(accessMock.album.checkSharedAlbumAccess).toHaveBeenCalledWith(
|
expect(accessMock.album.checkSharedAlbumAccess).toHaveBeenCalledWith(
|
||||||
authStub.admin.user.id,
|
authStub.admin.user.id,
|
||||||
new Set(['album-123']),
|
new Set(['album-123']),
|
||||||
AlbumUserRole.Viewer,
|
AlbumUserRole.VIEWER,
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Vendored
+4
-4
@@ -39,7 +39,7 @@ export const albumStub = {
|
|||||||
{
|
{
|
||||||
user: userStub.user1,
|
user: userStub.user1,
|
||||||
album: undefined as unknown as AlbumEntity,
|
album: undefined as unknown as AlbumEntity,
|
||||||
role: AlbumUserRole.Editor,
|
role: AlbumUserRole.EDITOR,
|
||||||
userId: userStub.user1.id,
|
userId: userStub.user1.id,
|
||||||
albumId: 'album-2',
|
albumId: 'album-2',
|
||||||
},
|
},
|
||||||
@@ -64,14 +64,14 @@ export const albumStub = {
|
|||||||
{
|
{
|
||||||
user: userStub.user1,
|
user: userStub.user1,
|
||||||
album: undefined as unknown as AlbumEntity,
|
album: undefined as unknown as AlbumEntity,
|
||||||
role: AlbumUserRole.Editor,
|
role: AlbumUserRole.EDITOR,
|
||||||
userId: userStub.user1.id,
|
userId: userStub.user1.id,
|
||||||
albumId: 'album-3',
|
albumId: 'album-3',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
user: userStub.user2,
|
user: userStub.user2,
|
||||||
album: undefined as unknown as AlbumEntity,
|
album: undefined as unknown as AlbumEntity,
|
||||||
role: AlbumUserRole.Editor,
|
role: AlbumUserRole.EDITOR,
|
||||||
userId: userStub.user2.id,
|
userId: userStub.user2.id,
|
||||||
albumId: 'album-3',
|
albumId: 'album-3',
|
||||||
},
|
},
|
||||||
@@ -96,7 +96,7 @@ export const albumStub = {
|
|||||||
{
|
{
|
||||||
user: userStub.admin,
|
user: userStub.admin,
|
||||||
album: undefined as unknown as AlbumEntity,
|
album: undefined as unknown as AlbumEntity,
|
||||||
role: AlbumUserRole.Editor,
|
role: AlbumUserRole.EDITOR,
|
||||||
userId: userStub.admin.id,
|
userId: userStub.admin.id,
|
||||||
albumId: 'album-3',
|
albumId: 'album-3',
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user