mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2024-11-25 11:16:31 -05:00
refactor(note-user-permission-entry-dto): do not embed User objects
This is part of an effort to consistently not embed User objects in API responses. Usernames are returned instead. Signed-off-by: David Mehren <git@herrmehren.de>
This commit is contained in:
parent
b955faa983
commit
13284b26cb
3 changed files with 10 additions and 10 deletions
|
@ -17,11 +17,11 @@ import { UserInfoDto } from '../users/user-info.dto';
|
|||
|
||||
export class NoteUserPermissionEntryDto {
|
||||
/**
|
||||
* User this permission applies to
|
||||
* Username of the User this permission applies to
|
||||
*/
|
||||
@ValidateNested()
|
||||
@ApiProperty({ type: UserInfoDto })
|
||||
user: UserInfoDto;
|
||||
@IsString()
|
||||
@ApiProperty()
|
||||
username: string;
|
||||
|
||||
/**
|
||||
* True if the user is allowed to edit the note
|
||||
|
|
|
@ -688,7 +688,7 @@ describe('NotesService', () => {
|
|||
const permissions = await service.toNotePermissionsDto(note);
|
||||
expect(permissions.owner).toEqual(user.username);
|
||||
expect(permissions.sharedToUsers).toHaveLength(1);
|
||||
expect(permissions.sharedToUsers[0].user.username).toEqual(user.username);
|
||||
expect(permissions.sharedToUsers[0].username).toEqual(user.username);
|
||||
expect(permissions.sharedToUsers[0].canEdit).toEqual(true);
|
||||
expect(permissions.sharedToGroups).toHaveLength(1);
|
||||
expect(permissions.sharedToGroups[0].group.displayName).toEqual(
|
||||
|
@ -778,7 +778,7 @@ describe('NotesService', () => {
|
|||
expect(metadataDto.editedBy[0]).toEqual(user.username);
|
||||
expect(metadataDto.permissions.owner).toEqual(user.username);
|
||||
expect(metadataDto.permissions.sharedToUsers).toHaveLength(1);
|
||||
expect(metadataDto.permissions.sharedToUsers[0].user.username).toEqual(
|
||||
expect(metadataDto.permissions.sharedToUsers[0].username).toEqual(
|
||||
user.username,
|
||||
);
|
||||
expect(metadataDto.permissions.sharedToUsers[0].canEdit).toEqual(true);
|
||||
|
@ -880,9 +880,9 @@ describe('NotesService', () => {
|
|||
expect(noteDto.metadata.editedBy[0]).toEqual(user.username);
|
||||
expect(noteDto.metadata.permissions.owner).toEqual(user.username);
|
||||
expect(noteDto.metadata.permissions.sharedToUsers).toHaveLength(1);
|
||||
expect(
|
||||
noteDto.metadata.permissions.sharedToUsers[0].user.username,
|
||||
).toEqual(user.username);
|
||||
expect(noteDto.metadata.permissions.sharedToUsers[0].username).toEqual(
|
||||
user.username,
|
||||
);
|
||||
expect(noteDto.metadata.permissions.sharedToUsers[0].canEdit).toEqual(
|
||||
true,
|
||||
);
|
||||
|
|
|
@ -375,7 +375,7 @@ export class NotesService {
|
|||
return {
|
||||
owner: owner ? owner.username : null,
|
||||
sharedToUsers: userPermissions.map((noteUserPermission) => ({
|
||||
user: this.usersService.toUserDto(noteUserPermission.user),
|
||||
username: noteUserPermission.user.username,
|
||||
canEdit: noteUserPermission.canEdit,
|
||||
})),
|
||||
sharedToGroups: groupPermissions.map((noteGroupPermission) => ({
|
||||
|
|
Loading…
Reference in a new issue