mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-13 14:44:43 -04:00
feat(note-metadata): replace primaryAlias with primaryAddress
The primary address is never null. If no alias is set, the id is returned. To still easily get the primary alias, the complete Alias DTOs are now included in the metadata. Signed-off-by: David Mehren <git@herrmehren.de>
This commit is contained in:
parent
64b16c831e
commit
342efcd7b7
9 changed files with 50 additions and 21 deletions
|
@ -25,6 +25,7 @@ import { User } from '../users/user.entity';
|
|||
import { UsersService } from '../users/users.service';
|
||||
import { checkArrayForDuplicates } from '../utils/arrayDuplicatCheck';
|
||||
import { Alias } from './alias.entity';
|
||||
import { AliasService } from './alias.service';
|
||||
import { NoteMetadataDto } from './note-metadata.dto';
|
||||
import {
|
||||
NotePermissionsDto,
|
||||
|
@ -49,6 +50,7 @@ export class NotesService {
|
|||
private revisionsService: RevisionsService,
|
||||
@Inject(noteConfiguration.KEY)
|
||||
private noteConfig: NoteConfig,
|
||||
@Inject(forwardRef(() => AliasService)) private aliasService: AliasService,
|
||||
) {
|
||||
this.logger.setContext(NotesService.name);
|
||||
}
|
||||
|
@ -397,9 +399,11 @@ export class NotesService {
|
|||
return {
|
||||
id: note.publicId,
|
||||
aliases: await Promise.all(
|
||||
(await note.aliases).map((alias) => alias.name),
|
||||
(
|
||||
await note.aliases
|
||||
).map((alias) => this.aliasService.toAliasDto(alias, note)),
|
||||
),
|
||||
primaryAlias: (await getPrimaryAlias(note)) ?? null,
|
||||
primaryAddress: (await getPrimaryAlias(note)) ?? note.id,
|
||||
title: note.title ?? '',
|
||||
createdAt: (await this.getFirstRevision(note)).createdAt,
|
||||
description: note.description ?? '',
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue