Commit graph

68 commits

Author SHA1 Message Date
David Mehren
776c230877
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
ab4ecf6a8f
UsersService: Merge if-statements and add null to return type in toUserDto
Signed-off-by: David Mehren <git@herrmehren.de>
2020-09-26 16:00:17 +02:00
David Mehren
5bd1259949
RevisionsService: Asynchronously inject NotesService to resolve circular dependency while testing
Signed-off-by: David Mehren <git@herrmehren.de>
2020-09-25 20:42:35 +02:00
David Mehren
b9b5af8b7f
Add various missing imports and provider overrides to fix unit tests.
Signed-off-by: David Mehren <git@herrmehren.de>
2020-09-22 21:59:09 +02:00
David Mehren
4cf31c1bcb
NotesService: Implement getNoteContent and getNoteMetdata
Signed-off-by: David Mehren <git@herrmehren.de>
2020-09-22 21:45:20 +02:00
David Mehren
bc1c8448df
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-22 21:44:53 +02:00
David Mehren
446d6dec06
RevisionsService: Get note revision from database
Signed-off-by: David Mehren <git@herrmehren.de>
2020-09-22 21:42:17 +02:00
David Mehren
05a62b31ee
RevisionService: Implement getNoteRevisionMetadatas
Signed-off-by: David Mehren <git@herrmehren.de>
2020-09-22 21:09:14 +02:00
David Mehren
3d4e9a9b92
NotesController: revisionId is a number
Signed-off-by: David Mehren <git@herrmehren.de>
2020-09-22 21:08:14 +02:00
David Mehren
2140faab07
RevisionMetadataDto: Rename attribute updatedAt to createdAt
Signed-off-by: David Mehren <git@herrmehren.de>
2020-09-22 21:04:55 +02:00
David Mehren
cf88cde551
NotesService: Use the database for delete and update actions.
Signed-off-by: David Mehren <git@herrmehren.de>
2020-09-22 20:07:36 +02:00
David Mehren
05f25b92aa
NotesController: Get text from request body when updating and deleting a note.
Signed-off-by: David Mehren <git@herrmehren.de>
2020-09-22 20:06:56 +02:00
David Mehren
d462a571d8
RevisionEntity: Change primary key type from UUID to number
The precision of sqlites datetime() timestamp is only one second (see https://www.sqlite.org/lang_datefunc.html). Therefore we could not order revisions of one note that were created in the same second. To remedy this, the primary key was changed to a monotonically increasing number, which solves the ordering problem.

Signed-off-by: David Mehren <git@herrmehren.de>
2020-09-22 20:06:16 +02:00
David Mehren
1abb472621
NotesController: Get text from request body when creating a named note.
Signed-off-by: David Mehren <git@herrmehren.de>
2020-09-22 18:31:20 +02:00
David Mehren
5d1cc6c339
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-22 17:34:33 +02:00
David Mehren
21f4cda27c
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-22 17:32:35 +02:00
David Mehren
b1cb8025a5
RevisionsService: Implement getLatestRevision and createRevision methods
Signed-off-by: David Mehren <git@herrmehren.de>
2020-09-22 17:29:59 +02:00
David Mehren
615bd6496b
UsersService: Add null check to toUserDto() converter
Signed-off-by: David Mehren <git@herrmehren.de>
2020-09-22 17:28:57 +02:00
David Mehren
9cae7e34dc
NotesService: Get more note metadata from the database
Some previously hardcoded metadata-values are now retrieved from the database.

Signed-off-by: David Mehren <git@herrmehren.de>
2020-09-19 17:40:50 +02:00
David Mehren
30a0b25094
UsersService: Add toUserDto() converter
This conversion function makes sure that a photo URL exists.

Signed-off-by: David Mehren <git@herrmehren.de>
2020-09-19 17:33:29 +02:00
David Mehren
eee8668317
NoteUtils: Add methods to parse note metadata
These methods are intended to parse metadata details from YAML tags, but not implemented for now.

Signed-off-by: David Mehren <git@herrmehren.de>
2020-09-19 17:32:08 +02:00
David Mehren
243fcabcaf
NoteEntity: Always initialize arrays
The `create()` function did not initialize all arrays, which caused them to be `undefined` instead of empty.

Signed-off-by: David Mehren <git@herrmehren.de>
2020-09-19 17:30:58 +02:00
David Mehren
58e2932c1a
RevisionEntity: Add create() method
Signed-off-by: David Mehren <git@herrmehren.de>
2020-09-19 16:04:30 +02:00
David Mehren
32a6396a50
NotesService: createNote() now saves new notes to the database
Signed-off-by: David Mehren <git@herrmehren.de>
2020-09-19 16:01:32 +02:00
David Mehren
2261b81139
NoteEntity: Move constructor-code to create() method
TypeORM does not like having application code in the constructor (https://github.com/typeorm/typeorm/issues/1772#issuecomment-514787854), therefore that is moved into a new `create() static method. Additionally, the constructor is now `private`, which enforces the use of the new method.

Signed-off-by: David Mehren <git@herrmehren.de>
2020-09-19 16:00:29 +02:00
David Mehren
bb9e60d5f6
NoteEntity: Formatting fixes
Signed-off-by: David Mehren <git@herrmehren.de>
2020-09-19 15:57:57 +02:00
David Mehren
85fa30b27c
NoteEntity: Enable CASCADE for revision column
This makes creating new Notes easier, as the first Revision is automatically created in the database.

Signed-off-by: David Mehren <git@herrmehren.de>
2020-09-19 15:57:34 +02:00
David Mehren
56817c3f91
NoteController: Do not use text/markdown as response content-type for createNote
Signed-off-by: David Mehren <git@herrmehren.de>
2020-09-19 15:50:58 +02:00
David Mehren
c6787ef233
NoteDto: Rename attribute metdata to metadata
Signed-off-by: David Mehren <git@herrmehren.de>
2020-09-19 14:54:08 +02:00
David Mehren
93cf9c2c56
NotesController: Use custom logic to access raw markdown
NestJS does not support content-types other than application/json.
Therefore we need to directly access the request object to get the raw body content.

Signed-off-by: David Mehren <git@herrmehren.de>
2020-09-19 14:51:12 +02:00
David Mehren
f007b8539c
NotesController: Add missing mock repositories for testing
Signed-off-by: David Mehren <git@herrmehren.de>
2020-08-20 19:57:56 +02:00
David Mehren
7f81a57634
MeController: Add missing mock repositories for testing
Signed-off-by: David Mehren <git@herrmehren.de>
2020-08-20 19:57:47 +02:00
David Mehren
2654f1fa36
Implement User entity.
This commit implements the User entity according to the database schema and adds the Identity and AuthToken entities.

Signed-off-by: David Mehren <git@herrmehren.de>
2020-08-13 20:26:47 +02:00
David Mehren
6bee3b16cf
Add Session entity
This entity implements the Session interface from connect-typeorm, which we will later use to store session data from express-session.

Signed-off-by: David Mehren <git@herrmehren.de>
2020-08-13 20:25:43 +02:00
David Mehren
ef92ab73f9
Update Note entity
We now use the new permissions split in users and groups. Also the note now knows the colors of its authors.

Signed-off-by: David Mehren <git@herrmehren.de>
2020-08-13 20:24:45 +02:00
David Mehren
ba9d7a6572
Add AuthorColor entity
Signed-off-by: David Mehren <git@herrmehren.de>
2020-08-13 20:22:30 +02:00
David Mehren
40034a4a84
Initialize TypeORM for Group entity
Signed-off-by: David Mehren <git@herrmehren.de>
2020-08-13 20:22:04 +02:00
David Mehren
68a0852691
Update revision entity according to the current database scheme.
Signed-off-by: David Mehren <git@herrmehren.de>
2020-08-12 20:52:26 +02:00
David Mehren
0a33d8ef8d
Add authorship entity.
It stores which parts of a revision were edited by a particular user.

Signed-off-by: David Mehren <git@herrmehren.de>
2020-08-12 20:51:49 +02:00
David Mehren
637b16abda
Add PermissionModule and GroupsModule
Both currently contain only the database entities, taken from the schema.

Signed-off-by: David Mehren <git@herrmehren.de>
2020-08-12 20:24:43 +02:00
David Mehren
97cc2085af
Update NotesService and HistoryService to use the new permission model.
We now have separate sharedTo attributes for users and groups.

Signed-off-by: David Mehren <git@herrmehren.de>
2020-08-12 20:23:48 +02:00
David Mehren
a5ffbb6e7f
Add 'special' property to GroupInfoDto and rename 'id' to 'name'
Signed-off-by: David Mehren <git@herrmehren.de>
2020-07-27 22:38:46 +02:00
David Mehren
d1bd35007e
Adapt permission DTOs for group permissions
Signed-off-by: David Mehren <git@herrmehren.de>
2020-07-26 22:34:04 +02:00
David Mehren
34d0578c0d
Implement routes in MonitoringController
Signed-off-by: David Mehren <git@herrmehren.de>
2020-07-26 21:36:54 +02:00
David Mehren
6617977a7e
Add monitoring module
Signed-off-by: David Mehren <git@herrmehren.de>
2020-07-26 21:36:28 +02:00
David Mehren
99614f8f3a
Add media upload route to MediaController
Signed-off-by: David Mehren <git@herrmehren.de>
2020-07-26 21:20:49 +02:00
David Mehren
4851e2c31c
RevisionsService: Add hardcoded-data warnings.
Signed-off-by: David Mehren <git@herrmehren.de>
2020-07-26 21:02:15 +02:00
David Mehren
387e4c3b99
NotesService: Add hardcoded-data warnings.
Signed-off-by: David Mehren <git@herrmehren.de>
2020-07-26 21:01:30 +02:00
David Mehren
82f03152a8
Implement /notes API routes
This adds all currently specified routes under /notes.

Signed-off-by: David Mehren <git@herrmehren.de>
2020-07-26 21:00:18 +02:00
David Mehren
4cd574306e
Add more features to NotesService
Signed-off-by: David Mehren <git@herrmehren.de>
2020-07-26 20:59:12 +02:00