mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-15 07:34:42 -04:00
NotesService: Replace noteByIdOrAlias with note as parameter
As the NotesController has the note already, because it checked with it if the user has the permission to perform the action, it's not necessary to get the note from the DB again, instead we should just provide the note to the functions directly. Signed-off-by: Philip Molares <philip.molares@udo.edu>
This commit is contained in:
parent
e538056252
commit
4d89ffd474
5 changed files with 50 additions and 107 deletions
|
@ -12,6 +12,7 @@ import { NotesService } from '../notes/notes.service';
|
|||
import { RevisionMetadataDto } from './revision-metadata.dto';
|
||||
import { RevisionDto } from './revision.dto';
|
||||
import { Revision } from './revision.entity';
|
||||
import { Note } from '../notes/note.entity';
|
||||
|
||||
@Injectable()
|
||||
export class RevisionsService {
|
||||
|
@ -24,8 +25,7 @@ export class RevisionsService {
|
|||
this.logger.setContext(RevisionsService.name);
|
||||
}
|
||||
|
||||
async getAllRevisions(noteIdOrAlias: string): Promise<Revision[]> {
|
||||
const note = await this.notesService.getNoteByIdOrAlias(noteIdOrAlias);
|
||||
async getAllRevisions(note: Note): Promise<Revision[]> {
|
||||
return await this.revisionRepository.find({
|
||||
where: {
|
||||
note: note,
|
||||
|
@ -33,11 +33,7 @@ export class RevisionsService {
|
|||
});
|
||||
}
|
||||
|
||||
async getRevision(
|
||||
noteIdOrAlias: string,
|
||||
revisionId: number,
|
||||
): Promise<Revision> {
|
||||
const note = await this.notesService.getNoteByIdOrAlias(noteIdOrAlias);
|
||||
async getRevision(note: Note, revisionId: number): Promise<Revision> {
|
||||
return await this.revisionRepository.findOne({
|
||||
where: {
|
||||
id: revisionId,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue