mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-24 03:57:06 -04:00
refactor(note-metadata): 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
96ed5f3cc8
commit
08f97209ec
5 changed files with 8 additions and 11 deletions
|
@ -77,10 +77,10 @@ export class NoteMetadataDto {
|
|||
/**
|
||||
* User that last edited the note
|
||||
*/
|
||||
@ValidateNested()
|
||||
@ApiPropertyOptional({ type: UserInfoDto })
|
||||
@IsString()
|
||||
@ApiPropertyOptional()
|
||||
@IsOptional()
|
||||
updateUser: UserInfoDto | null;
|
||||
updateUsername: string | null;
|
||||
|
||||
/**
|
||||
* Counts how many times the published note has been viewed
|
||||
|
|
|
@ -790,7 +790,7 @@ describe('NotesService', () => {
|
|||
expect(metadataDto.tags).toHaveLength(1);
|
||||
expect(metadataDto.tags[0]).toEqual((await note.tags)[0].name);
|
||||
expect(metadataDto.updatedAt).toEqual(revisions[0].createdAt);
|
||||
expect(metadataDto.updateUser.username).toEqual(user.username);
|
||||
expect(metadataDto.updateUsername).toEqual(user.username);
|
||||
expect(metadataDto.viewCount).toEqual(note.viewCount);
|
||||
});
|
||||
});
|
||||
|
@ -896,7 +896,7 @@ describe('NotesService', () => {
|
|||
expect(noteDto.metadata.tags).toHaveLength(1);
|
||||
expect(noteDto.metadata.tags[0]).toEqual((await note.tags)[0].name);
|
||||
expect(noteDto.metadata.updatedAt).toEqual(revisions[0].createdAt);
|
||||
expect(noteDto.metadata.updateUser.username).toEqual(user.username);
|
||||
expect(noteDto.metadata.updateUsername).toEqual(user.username);
|
||||
expect(noteDto.metadata.viewCount).toEqual(note.viewCount);
|
||||
expect(noteDto.content).toEqual(content);
|
||||
});
|
||||
|
|
|
@ -406,7 +406,7 @@ export class NotesService {
|
|||
permissions: await this.toNotePermissionsDto(note),
|
||||
tags: await this.toTagList(note),
|
||||
updatedAt: (await this.getLatestRevision(note)).createdAt,
|
||||
updateUser: updateUser ? this.usersService.toUserDto(updateUser) : null,
|
||||
updateUsername: updateUser ? updateUser.username : null,
|
||||
viewCount: note.viewCount,
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue