Commit graph

69 commits

Author SHA1 Message Date
David Mehren
6ffeb2e9c9
ESLint: Enable @typescript-eslint/return-await rule
This ensures stack traces are helpful at the cost of a slightly
lower performance (one more tick in the event loop).

Fixes #838

Signed-off-by: David Mehren <git@herrmehren.de>
2021-02-26 12:10:51 +01:00
David Mehren
3fabf2596a
Merge pull request #943 from hedgedoc/refactor/getNoteContent 2021-02-23 21:05:25 +01:00
Yannick Bungers
b7e188cec2 Rename viewcount to viewCount for compliance
Signed-off-by: Yannick Bungers <git@innay.de>
2021-02-22 23:36:44 +01:00
Yannick Bungers
e081bd196b Rename getNoteContentByNote to getNoteContent
Signed-off-by: Yannick Bungers <git@innay.de>
2021-02-22 22:34:18 +01:00
Yannick Bungers
15a1a138ee Remove unused getNoteContentByIdOrAlias
Signed-off-by: Yannick Bungers <git@innay.de>
2021-02-22 22:32:00 +01:00
Philip Molares
5f49cb8d48 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>
2021-02-20 19:51:27 +01:00
Philip Molares
93d859647d NotesService: Add unit tests
Fixed toUserDto method of UsersService: If a user has no email an empty string should be returned (like with the photoUrl) instead of null.

Signed-off-by: Philip Molares <philip.molares@udo.edu>
2021-02-20 19:51:24 +01:00
Philip Molares
4332b039d6 NotesService: Finished hardcoded functions
Signed-off-by: Philip Molares <philip.molares@udo.edu>
2021-02-20 19:45:16 +01:00
Philip Molares
34087561e7 GroupsService: Create new GroupsService
This service is necessary as we plan to have functions to create and manipulate groups in the future.
The GroupInfoDto was moved from the file note-permissions.dto.ts to mimic the UserInfoDto.

Signed-off-by: Philip Molares <philip.molares@udo.edu>
2021-02-20 16:52:18 +01:00
Philip Molares
353384435e NotesService: Add JsDoc strings to all functions
Signed-off-by: Philip Molares <philip.molares@udo.edu>
2021-02-20 11:28:19 +01:00
Philip Molares
336117cef5 NotesService: Rename getCurrentContent to getNoteContentByNote
The new name should better explain what this functions does.

Signed-off-by: Philip Molares <philip.molares@udo.edu>
2021-02-19 13:36:01 +01:00
Yannick Bungers
f8e07f6940 Add relation between User and Group
This represents the users which are members of this group

Signed-off-by: Yannick Bungers <git@innay.de>
2021-02-18 22:25:52 +01:00
David Mehren
8b62b7d93c
Add missing logging context at various places
Our custom logger supports providing the name of the function that
calls the logger, this commit adds this context string where it
was previously missing.

Signed-off-by: David Mehren <git@herrmehren.de>
2021-02-05 22:30:22 +01:00
Philip Molares
7f1afc30c9 History: Add history service and usage
Add history service to allow for CRUD operations.
Use history service in controllers to:
  1. Allow manipulating of history entries
  2. Guaranty the correct existence of history entries

Signed-off-by: Philip Molares <philip.molares@udo.edu>
2021-02-04 21:50:19 +01:00
Philip Molares
b76fa91a3c History: Add HistoryEntry
With this the backend now can hold a history entry.
Also included in this commit are some minor changes to tests and services so they can still work.

Signed-off-by: Philip Molares <philip.molares@udo.edu>
2021-02-04 21:50:14 +01:00
Yannick Bungers
c2b6c6fe49 Reformat code by yarn format
Signed-off-by: Yannick Bungers <git@innay.de>
2021-01-31 00:12:00 +01:00
Yannick Bungers
b07d6d478c Refactoring of controllers and service interfaces
DTO should only be used for sending information to and from user.
Services now have methods which return normal internal objects and
methods which convert them to DTOs. This conversion is done in the
controlers

Signed-off-by: Yannick Bungers <git@innay.de>
2021-01-30 00:15:05 +01:00
David Mehren
5f71e779ef
NoteDto: Add doc comments
Signed-off-by: David Mehren <git@herrmehren.de>
2021-01-25 22:48:39 +01:00
David Mehren
be2dc0e4d6
NoteAuthorshipDto: Add doc comments
Signed-off-by: David Mehren <git@herrmehren.de>
2021-01-25 22:48:39 +01:00
David Mehren
e4f0c5c064
NoteMetadata DTOs: Add doc comments
Signed-off-by: David Mehren <git@herrmehren.de>
2021-01-25 22:48:38 +01:00
David Mehren
a83a7c7a66
NotePermission DTOs: Add doc comments
Signed-off-by: David Mehren <git@herrmehren.de>
2021-01-25 22:48:38 +01:00
Philip Molares
84ec528d14 auth: Add tests for AuthService
Move AuthTokens to auth folder

Signed-off-by: Philip Molares <philip.molares@udo.edu>
2021-01-25 21:30:02 +01:00
Yannick Bungers
17ceb9c31f Removed special table name in Note object
and changed table names in plantuml file

Signed-off-by: Yannick Bungers <git@innay.de>
2021-01-23 22:26:49 +01:00
Yannick Bungers
0d95c29df2
Merge pull request #709 from hedgedoc/fix/api-notes-metadata 2021-01-15 22:47:52 +01:00
David Mehren
6301a264dd
NotesService: updateNoteByIdOrAlias should return the new note
Fixes #702

Signed-off-by: David Mehren <git@herrmehren.de>
2021-01-10 20:31:56 +01:00
David Mehren
65c76d0998
NotesService: Get note creation time from database
Signed-off-by: David Mehren <git@herrmehren.de>
2021-01-10 20:12:39 +01:00
David Mehren
32feb5ee10
NotesService: rename getLastRevision to getLatestRevision
This fixes an inconsistency with `RevisionsService`

Signed-off-by: David Mehren <git@herrmehren.de>
2021-01-10 20:12:39 +01:00
David Mehren
f81e67a3a1
Format with Prettier 2
Signed-off-by: David Mehren <git@herrmehren.de>
2021-01-06 23:49:45 +01:00
Tilman Vatteroth
0c56466dc1
Change year in copyright to 2021
Signed-off-by: Tilman Vatteroth <tilman.vatteroth@tu-dortmund.de>
2021-01-06 22:10:19 +01:00
Philip Molares
6896daa62a added reuse information
Signed-off-by: Philip Molares <philip.molares@udo.edu>
2021-01-05 22:12:38 +01:00
David Mehren
85ee6780ad
Remove PUT /notes/{note}/metadata and corresponding service code
Signed-off-by: David Mehren <git@herrmehren.de>
Co-authored-by: Yannick Bungers <git@innay.de>
2020-10-24 22:21:45 +02:00
David Mehren
6a1da64cf6
Remove NoteUtils class, as the planned parsing logic is not needed anymore
Signed-off-by: David Mehren <git@herrmehren.de>
Co-authored-by: Yannick Bungers <git@innay.de>
2020-10-24 22:21:45 +02:00
David Mehren
b2085efb1d
Add missing TagRepository provider in unit tests
Signed-off-by: David Mehren <git@herrmehren.de>
Co-authored-by: Yannick Bungers <git@innay.de>
2020-10-24 22:21:44 +02:00
David Mehren
3726b27849
NotesService: Implement updateNoteMetadata
Signed-off-by: David Mehren <git@herrmehren.de>
Co-authored-by: Yannick Bungers <git@innay.de>
2020-10-24 22:21:43 +02:00
David Mehren
943c8b4bab
NoteEntity: Enable eager loading and cascades for tags
Signed-off-by: David Mehren <git@herrmehren.de>
Co-authored-by: Yannick Bungers <git@innay.de>
2020-10-24 22:21:43 +02:00
David Mehren
b349d25bd7
NotesService: Get metadata from database
Signed-off-by: David Mehren <git@herrmehren.de>
Co-authored-by: Yannick Bungers <git@innay.de>
2020-10-24 22:21:43 +02:00
David Mehren
f1f57eca54
Add note metadata properties and Tag entity.
These were planned to be parsed at runtime from the note-content in the database, but having to run a markdown parser in the backend was found to be a bad idea. Now the frontend (that already implements the parsing logic) has to set title, description and tags.

Signed-off-by: David Mehren <git@herrmehren.de>
Co-authored-by: Yannick Bungers <git@innay.de>
2020-10-24 22:21:42 +02:00
David Mehren
be5b6dcf0e
NoteMetadataDto: Rename permission to permissions
Signed-off-by: David Mehren <git@herrmehren.de>
Co-authored-by: Yannick Bungers <git@innay.de>
2020-10-24 22:19:14 +02:00
David Mehren
61014f1bc4
Update NotePermissionsUpdate DTOs to be aware of groups
The NotePermissionsUpdateDto was not updated when group permissions were introduced.

Signed-off-by: David Mehren <git@herrmehren.de>
Co-authored-by: Yannick Bungers <git@innay.de>
2020-10-24 22:19:12 +02:00
David Mehren
5f13c34a07
UsersService: Improve logging in getNoteByIdOrAlias
Signed-off-by: David Mehren <git@herrmehren.de>
2020-10-24 11:34:16 +02:00
David Mehren
ec8cf6d33e
NotesService: Throw NotInDBError when the note wasn't found
Signed-off-by: David Mehren <git@herrmehren.de>
2020-10-17 20:23:28 +02:00
David Mehren
d7f407da2d
Switch to using the new custom logger
Signed-off-by: David Mehren <git@herrmehren.de>
2020-09-27 21:48:42 +02:00
David Mehren
a0740ffdf7
NotesService: Add TODO that createNote still needs to calculate a proper patch
Signed-off-by: David Mehren <git@herrmehren.de>
2020-09-26 16:01:01 +02:00
David Mehren
2ce87f3d64
Add various missing imports and provider overrides to fix unit tests.
Signed-off-by: David Mehren <git@herrmehren.de>
2020-09-25 21:37:40 +02:00
David Mehren
6e4893d179
NotesService: Implement getNoteContent and getNoteMetdata
Signed-off-by: David Mehren <git@herrmehren.de>
2020-09-25 21:37:40 +02:00
David Mehren
8b9a45b738
NotesService: Let createNote create an actual Note and introduce createNoteDto to create & convert in one step.
It might be handy to have access to the original `Note` after creating one, so the creation and conversion to a `NoteDto` is now split.

Signed-off-by: David Mehren <git@herrmehren.de>
2020-09-25 21:37:39 +02:00
David Mehren
51aec1ea54
RevisionService: Implement getNoteRevisionMetadatas
Signed-off-by: David Mehren <git@herrmehren.de>
2020-09-25 21:37:39 +02:00
David Mehren
47bf8c9c17
NotesService: Use the database for delete and update actions.
Signed-off-by: David Mehren <git@herrmehren.de>
2020-09-25 21:37:39 +02:00
David Mehren
a2a9ad224f
NotesService: Find note by ID or alias in database
This commit also introduces the `getNoteDtoByIdOrAlias` method, that converts a `Note` entity to a `NoteDto`

Signed-off-by: David Mehren <git@herrmehren.de>
2020-09-25 21:37:39 +02:00
David Mehren
e97f9fe174
NoteEntity: Lazy-load revisions relation
Using a `Promise` type in a TypeORM entity automatically enables lazy-loading of that relation.
See https://typeorm.io/#/eager-and-lazy-relations/lazy-relations

Signed-off-by: David Mehren <git@herrmehren.de>
2020-09-25 21:37:39 +02:00