mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2024-11-27 12:08:02 -05:00
NotesService: Get note creation time from database
Signed-off-by: David Mehren <git@herrmehren.de>
This commit is contained in:
parent
32feb5ee10
commit
65c76d0998
2 changed files with 17 additions and 3 deletions
|
@ -13,7 +13,7 @@ import { Revision } from '../revisions/revision.entity';
|
||||||
import { RevisionsService } from '../revisions/revisions.service';
|
import { RevisionsService } from '../revisions/revisions.service';
|
||||||
import { User } from '../users/user.entity';
|
import { User } from '../users/user.entity';
|
||||||
import { UsersService } from '../users/users.service';
|
import { UsersService } from '../users/users.service';
|
||||||
import { NoteMetadataDto, NoteMetadataUpdateDto } from './note-metadata.dto';
|
import { NoteMetadataDto } from './note-metadata.dto';
|
||||||
import {
|
import {
|
||||||
NotePermissionsDto,
|
NotePermissionsDto,
|
||||||
NotePermissionsUpdateDto,
|
NotePermissionsUpdateDto,
|
||||||
|
@ -104,14 +104,17 @@ export class NotesService {
|
||||||
return this.revisionsService.getLatestRevision(note.id);
|
return this.revisionsService.getLatestRevision(note.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async getFirstRevision(note: Note): Promise<Revision> {
|
||||||
|
return this.revisionsService.getFirstRevision(note.id);
|
||||||
|
}
|
||||||
|
|
||||||
async getMetadata(note: Note): Promise<NoteMetadataDto> {
|
async getMetadata(note: Note): Promise<NoteMetadataDto> {
|
||||||
return {
|
return {
|
||||||
// TODO: Convert DB UUID to base64
|
// TODO: Convert DB UUID to base64
|
||||||
id: note.id,
|
id: note.id,
|
||||||
alias: note.alias,
|
alias: note.alias,
|
||||||
title: note.title,
|
title: note.title,
|
||||||
// TODO: Get actual createTime
|
createTime: (await this.getFirstRevision(note)).createdAt,
|
||||||
createTime: new Date(),
|
|
||||||
description: note.description,
|
description: note.description,
|
||||||
editedBy: note.authorColors.map(
|
editedBy: note.authorColors.map(
|
||||||
(authorColor) => authorColor.user.userName,
|
(authorColor) => authorColor.user.userName,
|
||||||
|
|
|
@ -62,6 +62,17 @@ export class RevisionsService {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getFirstRevision(noteId: string): Promise<Revision> {
|
||||||
|
return this.revisionRepository.findOne({
|
||||||
|
where: {
|
||||||
|
note: noteId,
|
||||||
|
},
|
||||||
|
order: {
|
||||||
|
createdAt: 'ASC',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
toMetadataDto(revision: Revision): RevisionMetadataDto {
|
toMetadataDto(revision: Revision): RevisionMetadataDto {
|
||||||
return {
|
return {
|
||||||
id: revision.id,
|
id: revision.id,
|
||||||
|
|
Loading…
Reference in a new issue