Commit graph

375 commits

Author SHA1 Message Date
David Mehren
43f887b4c1
EditDto: Clarify that the username can be null
If the edit was made by a anonymous user, we don't have a username.

Signed-off-by: David Mehren <git@herrmehren.de>
2021-05-31 22:04:59 +02:00
David Mehren
1b1e232476
Rename NoteAuthorshipDto to EditDto
After Authorship was renamed to Edit, the DTO should follow.
The file is also moved to the revisions folder, where the entity
already is.

Signed-off-by: David Mehren <git@herrmehren.de>
2021-05-31 22:02:32 +02:00
David Mehren
b2d37abf6c
Rename Authorship entity to Edit
As we now have a separate Author entity, which holds information
about an author (the color), the Authorship name became confusing.
Edit seems to be a better name, as the entity saves information
about a change in a note.

Signed-off-by: David Mehren <git@herrmehren.de>
2021-05-31 21:46:41 +02:00
David Mehren
5846ca75a9
NotesService: Implement getAuthorUsers
This reimplements logic to get all Users that ever edited a note
and fixes the empty `editedBy` property of `toNoteMetadataDto`
introduced in 81cc092e.

Signed-off-by: David Mehren <git@herrmehren.de>
2021-05-24 21:58:44 +02:00
David Mehren
6abcb686ca
Seed: Generate multiple notes and authorships
Signed-off-by: David Mehren <git@herrmehren.de>
2021-05-19 21:09:15 +02:00
David Mehren
f6d430c23f
Adjust tests to new Session and Author entities
Signed-off-by: David Mehren <git@herrmehren.de>
2021-05-17 22:28:35 +02:00
David Mehren
3d07c5e443
AuthorshipEntity: Adjust to DB schema
This commit replaces the user property with a author property,
in accordance with the DB schema updated in 0d6c3002.

It also adjusts the NoteService accordingly.

Signed-off-by: David Mehren <git@herrmehren.de>
2021-05-19 22:12:25 +02:00
David Mehren
8040f47d00
Add Author property to Session & User
The DB schema was updated in 0d6c3002,
this adds the new author property to
the Session and User entities.

Signed-off-by: David Mehren <git@herrmehren.de>
2021-05-31 18:39:33 +02:00
David Mehren
1dc6db24a9
AuthorEntity: Add create method
Signed-off-by: David Mehren <git@herrmehren.de>
2021-05-19 22:12:00 +02:00
David Mehren
4e14053f8f
AuthorEntity: Add missing properties
This adds the missing properties according to the DB PlantUML schema

Signed-off-by: David Mehren <git@herrmehren.de>
2021-05-31 18:11:48 +02:00
David Mehren
59a4c72299
UsersModule: Add Session to TypeORM module
This seems to have been missed in
db026d6a57, where the Session entity
was added.

Signed-off-by: David Mehren <git@herrmehren.de>
2021-05-31 18:15:10 +02:00
David Mehren
283ec673cf
Remove AuthorColor entity
It will be replaced with the Author entity,
that will save the color

Signed-off-by: David Mehren <git@herrmehren.de>
2021-05-17 21:08:13 +02:00
David Mehren
9e5d95657d
Move publicID creation to Note.create
Before this commit, `Note.create()` did not return a complete object,
as the `publicId` property was missing.
This adds the generation of the property to the `create` method and
moves the actual generation code from the `NotesService`
to a utility method.

Signed-off-by: David Mehren <git@herrmehren.de>
2021-05-19 21:19:08 +02:00
Philip Molares
0f58757858
chore(test): Change test to work with publicId
Signed-off-by: Philip Molares <philip.molares@udo.edu>
2021-05-16 22:46:02 +02:00
Philip Molares
b7e52f8166
feat(notes): Use publicId in notes service
Signed-off-by: Philip Molares <philip.molares@udo.edu>
2021-05-16 22:44:43 +02:00
Philip Molares
ce132f2432
feat(note): Add publicId field
This field is a randomly generated 128-bit value encoded with base32-encode using the crockford variant and converted to lowercase.

Signed-off-by: Philip Molares <philip.molares@udo.edu>
2021-05-16 22:43:42 +02:00
Philip Molares
875e848b80
refactor: Remove randomString function
This was done because it was only a wrapper for a nodejs function to check if the given parameter is a positive number.

Signed-off-by: Philip Molares <philip.molares@udo.edu>
2021-05-16 22:41:01 +02:00
Thomas Snowden
7087135ea4
Add API decorator to reduce clutter
Signed-off-by: Thomas Snowden <zapperchamp1@gmail.com>
2021-04-24 19:10:16 -04:00
David Mehren
eaf1852fe5
Format with Prettier 2.3
Signed-off-by: David Mehren <git@herrmehren.de>
2021-05-15 21:13:44 +02:00
Philip Molares
f739687b00
Refactor(note): Remove shortid from note
This is a 1.x relict and isn't used anymore in 2.x. All 1.x shortids will be converted to aliases on migration of 1.x to 2.x.

Signed-off-by: Philip Molares <philip.molares@udo.edu>
2021-05-11 22:37:52 +02:00
Philip Molares
f5039791ed
Linting: Fixed wrong logger contexts
Signed-off-by: Philip Molares <philip.molares@udo.edu>
2021-05-02 21:53:28 +02:00
David Mehren
375cb4eae9
AuthTokenEntity: Make validUntil not nullable
As all tokens are valid for a maximum of 2 years, the
validUntil attribute is always populated.

This updates the database schema and the DTO to reflect that.

Fixes #1256

Signed-off-by: David Mehren <git@herrmehren.de>
2021-05-09 22:05:47 +02:00
David Mehren
6ddaa59e8c
Remove superfluous overrideProvider statements
Fixes #1254

Signed-off-by: David Mehren <git@herrmehren.de>
2021-05-09 21:34:43 +02:00
David Mehren
076c9c502d
Add error handling in seed.ts
Signed-off-by: David Mehren <git@herrmehren.de>
2021-05-02 18:35:38 +02:00
David Mehren
6471ba92ef
Fix nullable property types in Note DTOs
Signed-off-by: David Mehren <git@herrmehren.de>
2021-05-02 18:33:07 +02:00
David Mehren
73997d4693
MediaUploadDto: Make noteId optional
Signed-off-by: David Mehren <git@herrmehren.de>
2021-04-29 16:59:40 +02:00
David Mehren
d4495a0a62
GroupsService: Remove test obsoleted by strict mode
Signed-off-by: David Mehren <git@herrmehren.de>
2021-04-29 21:53:05 +02:00
David Mehren
8388edcd53
UsersService: Remove test obsoleted by strict mode
Signed-off-by: David Mehren <git@herrmehren.de>
2021-04-29 21:52:20 +02:00
David Mehren
0944f07834
Ensure optional properties of AuthTokenDto are initialized
Signed-off-by: David Mehren <git@herrmehren.de>
2021-04-29 21:14:09 +02:00
David Mehren
246d053b68
Add explicit type annotations to nullable columns
TypeORM can't correctly infer the data type on properties with a `| null` type.
This commit adds explicit type annotations.

See also https://github.com/typeorm/typeorm/issues/2567#issuecomment-408599335

Signed-off-by: David Mehren <git@herrmehren.de>
2021-04-29 19:08:59 +02:00
David Mehren
80d8ce901b
NotesService.toNoteMetadataDto: Handle undefined updateUser
Signed-off-by: David Mehren <git@herrmehren.de>
2021-04-29 18:30:48 +02:00
David Mehren
772263317d
NotesService: Fix type errors
Signed-off-by: David Mehren <git@herrmehren.de>
2021-04-29 18:30:17 +02:00
David Mehren
e217b30d26
Consistently type properties as optional
Signed-off-by: David Mehren <git@herrmehren.de>
2021-04-29 18:29:12 +02:00
David Mehren
bc08493f89
GroupsService: Remove null from toGroupDto return type
toGroupDto won't return null, as TS's strict mode
prevents group from being nullish

Signed-off-by: David Mehren <git@herrmehren.de>
2021-04-29 18:28:32 +02:00
David Mehren
b962e8390a
NotesController: Double-check that req.user is defined
TokenAuthGuard ensures that req.user is always
defined, but thanks to strict mode we have to check again.

In the future, we may add a custom Request type and
a custom param decorator to centralize the check.

Signed-off-by: David Mehren <git@herrmehren.de>
2021-04-29 18:12:20 +02:00
David Mehren
0a8dd454ab
NoteEntity: Allow anonymous notes
Notes created by anonymous users don't have an owner.
This commit updates the entity accordingly.

Signed-off-by: David Mehren <git@herrmehren.de>
2021-04-29 18:09:22 +02:00
David Mehren
bd56d17663
MediaUploadDto: Make noteId optional
Signed-off-by: David Mehren <git@herrmehren.de>
2021-04-29 16:59:40 +02:00
David Mehren
3b0bbe8b00
MediaService: Handle unexpected backend type
Signed-off-by: David Mehren <git@herrmehren.de>
2021-04-29 16:59:18 +02:00
David Mehren
22702b3390
Correctly type nullable columns
TypeORM columns with `nullable: true` can be `null` at runtime.
This commit ensures that the types of the corresponding properties reflect that.

Signed-off-by: David Mehren <git@herrmehren.de>
2021-04-29 16:54:57 +02:00
David Mehren
d63f581a42
MediaController: Double-check that req.user is defined
TokenAuthGuard ensures that req.user is always
defined, but thanks to strict mode we have to check again.

In the future, we may add a custom Request type and
a custom param decorator to centralize the check.

Signed-off-by: David Mehren <git@herrmehren.de>
2021-04-29 16:44:27 +02:00
David Mehren
90038cf116
MeController: Double-check that req.user is defined
TokenAuthGuard ensures that req.user is always
defined, but thanks to strict mode we have to check again.

In the future, we may add a custom Request type and
a custom param decorator to centralize the check.

Signed-off-by: David Mehren <git@herrmehren.de>
2021-04-29 16:43:16 +02:00
David Mehren
87eb099d34
UsersService: Remove null from toUserDto return type
toUserDto won't return null, as TS's strict mode
prevents user from being nullish

Signed-off-by: David Mehren <git@herrmehren.de>
2021-04-29 16:40:13 +02:00
David Mehren
a453344205
MarkdownBody: Handle error in getOwnPropertyDescriptor
Signed-off-by: David Mehren <git@herrmehren.de>
2021-04-29 16:27:15 +02:00
David Mehren
4959be739a
Handle config initialisation error on app bootstrap
Signed-off-by: David Mehren <git@herrmehren.de>
2021-04-29 16:22:01 +02:00
David Mehren
8357f3072c
HistoryService: Throw NotInDBError on empty DB result
This adds error handling to getEntryByNote, so it throws a
NotInDBError instead of (illegally, according to the type) returning
null.

Signed-off-by: David Mehren <git@herrmehren.de>
2021-04-29 16:16:30 +02:00
David Mehren
1a72e3c727
FrontendConfig DTOs: Make properties consistently optional
Some properties already have a IsOptional decorator,
this makes the properties themselves also optional

Signed-off-by: David Mehren <git@herrmehren.de>
2021-04-29 16:13:54 +02:00
David Mehren
56ce66bc8b
ConsoleLoggerService: Fix type of context properties
Nullish values of functionContext and classContext are handled correctly,
so the type can be adjusted

Signed-off-by: David Mehren <git@herrmehren.de>
2021-04-29 16:10:46 +02:00
David Mehren
52bb44a561
AuthService: Fix type of toAuthTokenWithSecretDto
toAuthTokenDto does not return nor accept a nullish value anymore,
so the types can be adjusted.

Signed-off-by: David Mehren <git@herrmehren.de>
2021-04-29 16:07:58 +02:00
David Mehren
327f36af94
AuthService.randomString: Throw Error instead of returning null
A string with a negative length is invalid, so we should throw here
instead of complicating the type with a possible null return value.

Signed-off-by: David Mehren <git@herrmehren.de>
2021-04-29 16:06:59 +02:00
David Mehren
5ee9b2a7e8
AuthTokenDto: Make properties consistently optional
validUntil and lastUsed already have a IsOptional decorator,
this makes the properties themselves also optional

Signed-off-by: David Mehren <git@herrmehren.de>
2021-04-29 15:55:11 +02:00