Commit graph

419 commits

Author SHA1 Message Date
Philip Molares
478e25e77c UsersService: Polish methods
Add test to createUser method to ensure an already used username triggers a AlreadyInDBError.
Add debug entry if user is deleted.
Add changeDisplayName method.

Signed-off-by: Philip Molares <philip.molares@udo.edu>
2021-04-18 22:49:24 +02:00
Philip Molares
c65ef80dd5 UsersService: Add JSDoc to all methods
Signed-off-by: Philip Molares <philip.molares@udo.edu>
2021-04-18 22:49:24 +02:00
Philip Molares
e591a65945 UserEntity: Make userName unique
Each username should only be given once.

Signed-off-by: Philip Molares <philip.molares@udo.edu>
2021-04-18 22:49:24 +02:00
Yannick Bungers
eaa5254418
Merge pull request #1039 from hedgedoc/fix/permissionsCreationAndFinding 2021-04-18 22:45:24 +02:00
David Mehren
1785190f75
Merge pull request #1135 from hedgedoc/publicApi/swaggerUpload
PublicAPI: Add file upload dialog to openapi docs
2021-04-18 22:44:01 +02:00
Philip Molares
1aa9b5f915 NotesService: Get user and group of the permission
This also fetches to user and group of permissions and not only the `canEdit` property.

Signed-off-by: Philip Molares <philip.molares@udo.edu>
2021-04-18 22:35:28 +02:00
Philip Molares
85ed00e2c2 NotesService: Set Permissions
Set the necessary information for the permissions to be correctly inserted into the db.

Signed-off-by: Philip Molares <philip.molares@udo.edu>
2021-04-18 22:35:28 +02:00
Philip Molares
029dc0d7d6 Permissions: Add cascade
This makes it possible to create permissions by setting them in the note entity and delete them when either the user or note is deleted.

Signed-off-by: Philip Molares <philip.molares@udo.edu>
2021-04-18 22:35:25 +02:00
David Mehren
6699e4b0c8
Merge pull request #1131 from hedgedoc/improve/logging 2021-04-18 22:28:11 +02:00
David Mehren
32d9f21630
Merge pull request #1141 from hedgedoc/mediaBackend/webDAV 2021-04-18 22:22:28 +02:00
Philip Molares
6cc406281c MediaBackend: Add WebdavBackend
Signed-off-by: Philip Molares <philip.molares@udo.edu>
2021-04-18 21:54:37 +02:00
Philip Molares
b490fe3ffc PublicAPI: Add file upload dialog to swagger api
This makes it possible to truly upload a file with swagger api documentation.

Signed-off-by: Philip Molares <philip.molares@udo.edu>
2021-04-18 21:02:06 +02:00
Philip Molares
6c1cda2c9a Config: Add WebDAV to media config
Signed-off-by: Philip Molares <philip.molares@udo.edu>
2021-04-18 20:45:39 +02:00
Philip Molares
0ef9a338f3 UnitTests: Add appConfigMock
This is necessary as the Logger needs this config for the loglevel.

Signed-off-by: Philip Molares <philip.molares@udo.edu>
2021-04-18 18:50:57 +02:00
Philip Molares
a87408009d Logging: Handle calls with 'undefined' context
Signed-off-by: Philip Molares <philip.molares@udo.edu>
2021-04-18 18:50:57 +02:00
Philip Molares
327206d60c Logging: Add LogLevels to ConsoleLoggerService
Signed-off-by: Philip Molares <philip.molares@udo.edu>
2021-04-18 18:50:57 +02:00
Philip Molares
a039b85ff4 Utils: Add needToLog function
This functions makes it possible to make a partial order of the Loglevel enum. This simplifies the if statements in ConsoleLogger.
This is done, because the Loglevel enum already has a string backing for easy conversion from the config environmental variables and therefore can't also have a ordinal number assigned…

Signed-off-by: Philip Molares <philip.molares@udo.edu>
2021-04-18 18:50:55 +02:00
David Mehren
0e5ce048a3
Merge pull request #1127 from hedgedoc/history/entryRename 2021-04-17 19:23:19 +02:00
David Mehren
ff27e988a6
Merge pull request #1136 from hedgedoc/fix/getServerVersion
Utils: Fix getServerVersionFromPackageJson
2021-04-17 16:03:52 +02:00
Philip Molares
51f1da7083 Tests: Fix eslint errors
Signed-off-by: Philip Molares <philip.molares@udo.edu>
2021-04-16 10:14:05 +02:00
Philip Molares
434bc55bab Tests: Removed all eslint-disable lines
As we now disable what we don't need in the eslint config, we don't need this anymore.

Signed-off-by: Philip Molares <philip.molares@udo.edu>
2021-04-16 10:14:05 +02:00
Philip Molares
dff5a635e0 Utils: Fix getServerVersionFromPackageJson
The cache is never null, because it defaults to undefined, and therefore this function always returns undefined.

Signed-off-by: Philip Molares <philip.molares@udo.edu>
2021-04-15 18:39:41 +02:00
Philip Molares
0269b5e87a Logging: Remove NestConsoleLoggerService
This is not necessary anymore, because we can inject ConsoleLoggerService directly.

Signed-off-by: Philip Molares <philip.molares@udo.edu>
2021-04-13 23:58:17 +02:00
Philip Molares
adffd68e68 PrivateAPI: Add lastVisited to HistoryEntryImportDto
As the DTO is only for importing an existing history the lastVisited of those entries should also be posted.

Signed-off-by: Philip Molares <philip.molares@udo.edu>
2021-04-11 12:37:47 +02:00
Philip Molares
4f858c51d2 PrivateAPI: Add pinStatus to HistoryEntryImportDto
As the DTO is only for importing an existing history the pinStatus of those entries should also be posted.

Signed-off-by: Philip Molares <philip.molares@udo.edu>
2021-04-11 12:37:38 +02:00
Philip Molares
085241999b PrivateAPI: Rename HistoryEntryCreationDto to HistoryEntryImportDto
As the DTO is used to import a whole list of history entries rather than creating a single history entry (there is no way of doing that at the moment)

Signed-off-by: Philip Molares <philip.molares@udo.edu>
2021-04-10 23:26:58 +02:00
Philip Molares
31b0d797f3 Logging: Add OpenAPI log messages
Let the user know where the OpenAPI docs can be found.

Signed-off-by: Philip Molares <philip.molares@udo.edu>
2021-04-02 17:40:44 +02:00
Philip Molares
3493a7a26f Logging: Improve mediabackend filesystem log message.
Signed-off-by: Philip Molares <philip.molares@udo.edu>
2021-04-02 17:38:22 +02:00
Philip Molares
4fb7623225 FileMediaBackend: Fix generated urls
All urls should be of the form `uploads/<filename>.<extension>` regardless of what the uploadDirectory is, because the backend proxies all locally uploaded files.

Signed-off-by: Philip Molares <philip.molares@udo.edu>
2021-04-01 00:28:13 +02:00
Philip Molares
354db0c1a2 MediaConfigMock: Change upload path
This changes the upload path in all test to 'test_uploads' to ensure no real uploads are lost.

Signed-off-by: Philip Molares <philip.molares@udo.edu>
2021-04-01 00:28:13 +02:00
Philip Molares
ff7fbcaf0e PrivateAPI: Add media controller
Signed-off-by: Philip Molares <philip.molares@udo.edu>
2021-03-25 22:26:41 +01:00
Philip Molares
b60fa155dd PrivateAPI: Add notes controller
Signed-off-by: Philip Molares <philip.molares@udo.edu>
2021-03-25 20:36:18 +01:00
Philip Molares
dd7ca87337 PrivateApi: Add config controller
Signed-off-by: Philip Molares <philip.molares@udo.edu>
2021-03-21 20:08:13 +01:00
Philip Molares
e471342497 FrontendConfig: Add new service
This service handles the config for the frontend.

Signed-off-by: Philip Molares <philip.molares@udo.edu>
2021-03-21 20:08:13 +01:00
Philip Molares
c4161cec98 Config: Add rendererOrigin and maxDocumentLength to AppConfig
These are used in the /config private API call.

Signed-off-by: Philip Molares <philip.molares@udo.edu>
2021-03-21 20:08:13 +01:00
Philip Molares
f63d37dbf7 Config: Add identifier to all multi auth provider to AuthConfig
These are used in the /config private API call and needed to distinguish with which of the multiple auth providers a login should occur.
This also fixes the types of the multiple auth provider arrays to something that works, as `[{}]` specifics exactly on object in an array.

Signed-off-by: Philip Molares <philip.molares@udo.edu>
2021-03-21 20:08:13 +01:00
Philip Molares
de82b72b62 Config: Create new config mocks for tests
Signed-off-by: Philip Molares <philip.molares@udo.edu>
2021-03-21 20:08:09 +01:00
Philip Molares
e8339e0976 Config: Add two new Subconfigs
CustomizationConfig holds all possible customization configs.
ExternalConfig holds external services that may be configured.

Signed-off-by: Philip Molares <philip.molares@udo.edu>
2021-03-21 19:59:07 +01:00
Philip Molares
19318ae518 Config: Extend AppConfig mock
This is now more in line what you would get from the regular config code

Signed-off-by: Philip Molares <philip.molares@udo.edu>
2021-03-21 19:59:07 +01:00
Philip Molares
381718f0eb Config: Move config mocks in own folder
To clean up the config folder, all mocks are now in it's own folder.

Signed-off-by: Philip Molares <philip.molares@udo.edu>
2021-03-21 19:59:05 +01:00
Philip Molares
942cb44e05 Utils: Extract getServerVersionFromPackageJson into own file
We need this function in at least on other part of the application so extracting it into an util file was only logical.

Signed-off-by: Philip Molares <philip.molares@udo.edu>
2021-03-21 19:58:37 +01:00
Philip Molares
37fa75fc91 PublicApi: Add GET /api/v2/notes/{note}/media
Signed-off-by: Philip Molares <philip.molares@udo.edu>
2021-03-21 19:18:40 +01:00
Philip Molares
3ef2fce067 MediaService: Add listUploadsByNote method
Signed-off-by: Philip Molares <philip.molares@udo.edu>
2021-03-21 19:18:40 +01:00
David Mehren
6d8780de4b
Merge pull request #1047 from hedgedoc/docs/apidocs 2021-03-21 19:07:14 +01:00
David Mehren
d3e7be491a
Merge pull request #981 from hedgedoc/privateApi/history
PrivateAPI: history
2021-03-21 19:00:21 +01:00
Philip Molares
168d85778c Docs: Add more documentation to the public api
Signed-off-by: Philip Molares <philip.molares@udo.edu>
2021-03-20 10:18:44 +01:00
Philip Molares
cb5c135cb7 Docs: Add description for common http codes
These are the descriptions for all 401, 403, 404 and 204 HTTP responses in HedgeDoc.

Signed-off-by: Philip Molares <philip.molares@udo.edu>
2021-03-20 10:18:42 +01:00
Philip Molares
3620416ed6 Docs: Add ApiProperty to all Dtos
This makes it possible for the autogenerated openapi file to contain all the dtos instead of nothing.

Signed-off-by: Philip Molares <philip.molares@udo.edu>
2021-03-19 12:08:34 +01:00
Philip Molares
7f399735f6 PrivateAPI: Add history controller
Signed-off-by: Philip Molares <philip.molares@udo.edu>
2021-03-18 21:56:35 +01:00
Philip Molares
b5575bbebe MediaService: Remove allowedMimeType application/pdf
Uploading PDFs does not work with imgur and therefore HedgeDoc should not offer that.

See #533

Signed-off-by: Philip Molares <philip.molares@udo.edu>
2021-03-15 22:41:40 +01:00
Philip Molares
9e55af1247 HistoryService: Add deleteHistory method
This method deletes all history entries of a user.

Signed-off-by: Philip Molares <philip.molares@udo.edu>
2021-03-15 21:14:56 +01:00
Yannick Bungers
7183d1fabb
Merge pull request #1021 from hedgedoc/publicApi/listMediaUpload
PublicAPI: Add GET /me/media
2021-03-15 20:26:59 +01:00
Philip Molares
c77773c247 AppConfig: Fix bug in the schema of forbiddenNoteIds
Signed-off-by: Philip Molares <philip.molares@udo.edu>
2021-03-14 17:54:50 +01:00
Yannick Bungers
ef352a1313 Add GET /me/media
Returns all media files uploaded by the authenticated user.

Signed-off-by: Yannick Bungers <git@innay.de>
2021-03-14 17:47:16 +01:00
David Mehren
b67ec817e6
Merge pull request #993 from hedgedoc/publicApi/me 2021-03-14 16:28:49 +01:00
David Mehren
99439af25e
Merge pull request #937 from hedgedoc/feature/forbiddenNoteIds 2021-03-14 16:06:48 +01:00
Philip Molares
d4b2dc9e4a PublicAPI: Add /me/history/:note
Signed-off-by: Philip Molares <philip.molares@udo.edu>
2021-03-06 17:55:48 +01:00
Philip Molares
de098cf68e HistoryService: Add unit test for getEntryByNoteIdOrAlias
Also add extra test to deleteHistoryEntry

Signed-off-by: Philip Molares <philip.molares@udo.edu>
2021-03-06 17:55:24 +01:00
Philip Molares
4034fa6495 NotesService: Add unit tests for forbidden note alias
Signed-off-by: Philip Molares <philip.molares@udo.edu>
2021-03-06 17:49:33 +01:00
Philip Molares
9b25f401f7 NotesService: Check if note alias is forbidden
If the note alias is forbidden return a BadRequest.

Signed-off-by: Philip Molares <philip.molares@udo.edu>
2021-03-06 17:49:25 +01:00
Philip Molares
df2f14ffbf HistoryService: Add JSDocs for all methods
Signed-off-by: Philip Molares <philip.molares@udo.edu>
2021-03-05 11:59:07 +01:00
David Mehren
8de1e4b938
Merge pull request #970 from hedgedoc/typeOrm/synchronizeToDo
AppModule: Add reminder to remove synchronize
2021-02-27 23:09:52 +01:00
Philip Molares
cbc88fd315 Errors: Add ForbiddenIdError
Signed-off-by: Philip Molares <philip.molares@udo.edu>
2021-02-27 23:04:52 +01:00
Philip Molares
2f028a4aae Config: Add forbiddenNoteIds to AppConfig
Signed-off-by: Philip Molares <philip.molares@udo.edu>
2021-02-27 23:04:49 +01:00
Philip Molares
1042954e98 AppModule: Add reminder to remove synchronize
This auto creates schema on startup and is not intended for production use
See https://typeorm.io/#/connection-options/common-connection-options

Signed-off-by: Philip Molares <philip.molares@udo.edu>
2021-02-27 22:58:34 +01:00
Philip Molares
2d98e2f8b4 S3Backend: Add S3 MediaBackend
Add minio dependency

Signed-off-by: Philip Molares <philip.molares@udo.edu>
2021-02-27 22:40:56 +01:00
Philip Molares
cf6c08e3d6 MediaConfig: Change s3 config
remove region as this is specified by endPoint now
add bucket in schema and actual assignment

Signed-off-by: Philip Molares <philip.molares@udo.edu>
2021-02-27 22:34:27 +01:00
Philip Molares
942360ea22 MediaConfig: Fix Joi schema alternatives
'...use' tries to go up one level and grab the value of 'use' there and not the same level 'use' as we want here

Signed-off-by: Philip Molares <philip.molares@udo.edu>
2021-02-27 22:34:27 +01:00
Philip Molares
dde74f37ff AzureBackend: Add Azure MediaBackend
Add @azure/storage-blob dependency
This is the relevant part of the official azure sdk.

Signed-off-by: Philip Molares <philip.molares@udo.edu>
2021-02-27 22:18:24 +01:00
Philip Molares
eb7e6b55eb DBSchema: Add fileUrl to media_upload table
Signed-off-by: Philip Molares <philip.molares@udo.edu>
2021-02-27 22:03:09 +01:00
Philip Molares
e2b2059bde ImgurBackend: Add Imgur MediaBackend
Add node-fetch dependency.
This was chosen as other libs we use already use node-fetch.

Signed-off-by: Philip Molares <philip.molares@udo.edu>
2021-02-27 21:29:14 +01:00
Philip Molares
165bb7602b MediaUploadEntity: Add fileUrl
Save the fileUrl, returned to the user on creation, in the DB.

Signed-off-by: Philip Molares <philip.molares@udo.edu>
2021-02-27 21:29:14 +01:00
Yannick Bungers
a92096034d
Merge pull request #936 from hedgedoc/maint/stronger_lint_checks 2021-02-27 21:24:35 +01:00
David Mehren
609b1cf3a3
Refactor server version object into own interface
This makes the type of getServerVersionFromPackageJson() way easier
to read.

Signed-off-by: David Mehren <git@herrmehren.de>
2021-02-27 21:21:41 +01:00
David Mehren
235d7efa19
Refactor config utils to use functions instead of consts
Signed-off-by: David Mehren <git@herrmehren.de>
2021-02-27 17:45:44 +01:00
David Mehren
9fcc3c6cee
Enforce explicit function return types
This re-enables the `@typescript-eslint/explicit-module-boundary-types`
check and also enables the
`@typescript-eslint/explicit-function-return-type` check.

Signed-off-by: David Mehren <git@herrmehren.de>
2021-02-27 17:41:32 +01:00
David Mehren
73db821649
FilesystemBackend: Fix ESLint errors
Signed-off-by: David Mehren <git@herrmehren.de>
2021-02-27 16:11:27 +01:00
David Mehren
0a23538389
NotesController: Fix ESLint errors
Signed-off-by: David Mehren <git@herrmehren.de>
2021-02-27 16:11:27 +01:00
David Mehren
38b787fe25
MeController: Fix ESLint errors
Signed-off-by: David Mehren <git@herrmehren.de>
2021-02-27 16:11:27 +01:00
David Mehren
b22d641406
ConsoleLoggerService: Fix ESLint errors
We now use @types/cli-color to provide type information

Signed-off-by: David Mehren <git@herrmehren.de>
2021-02-27 16:11:27 +01:00
David Mehren
a0ffa3be04
NoteEntity: Fix ESLint errors
We now use @types/shortid to provide type information

Signed-off-by: David Mehren <git@herrmehren.de>
2021-02-27 16:11:27 +01:00
David Mehren
2c841ae578
Fix ESLint errors in main.ts
Signed-off-by: David Mehren <git@herrmehren.de>
2021-02-27 16:11:27 +01:00
David Mehren
1cc86a728a
Fix various ESLint errors in services
Signed-off-by: David Mehren <git@herrmehren.de>
2021-02-27 16:11:27 +01:00
David Mehren
8c3bf66469
Fix various ESLint errors in unit tests
Signed-off-by: David Mehren <git@herrmehren.de>
2021-02-27 16:11:27 +01:00
David Mehren
c5fb87de05
Fix various ESLint errors in configs
Signed-off-by: David Mehren <git@herrmehren.de>
2021-02-27 16:11:27 +01:00
David Mehren
b37b2d1047
HistoryService: toHistoryEntryDto does not need to be async
Signed-off-by: David Mehren <git@herrmehren.de>
2021-02-27 16:11:27 +01:00
David Mehren
d8d105ed75
NotesService: toNotePermissionsDto does not need to be async
Signed-off-by: David Mehren <git@herrmehren.de>
2021-02-27 16:11:27 +01:00
David Mehren
b5281991ef
AuthService: randomString does not need to by async
Signed-off-by: David Mehren <git@herrmehren.de>
2021-02-27 16:11:27 +01:00
David Mehren
ba4825a99f
Add explicit Request type
Signed-off-by: David Mehren <git@herrmehren.de>
2021-02-27 16:11:27 +01:00
David Mehren
b78c94c3a1
Use Req decorator instead of Request
This avoids a clash with the Request type from express

Signed-off-by: David Mehren <git@herrmehren.de>
2021-02-27 16:11:27 +01:00
David Mehren
2b14ad92cd
Don't await non-Promises
Signed-off-by: David Mehren <git@herrmehren.de>
2021-02-27 16:11:27 +01:00
Philip Molares
7f9c310e58 MediaBackendInterface: Correct JSDoc of deleteFile
Signed-off-by: Philip Molares <philip.molares@udo.edu>
2021-02-27 12:24:02 +01:00
Philip Molares
062104f64b FilesystemBackend: Remove getFileURL
Signed-off-by: Philip Molares <philip.molares@udo.edu>
2021-02-27 11:38:50 +01:00
Philip Molares
d83e0004b7 MediaBackendInterface: Remove getFileURL
closes #957

Signed-off-by: Philip Molares <philip.molares@udo.edu>
2021-02-27 00:28:17 +01:00
David Mehren
3626ce9dff
ESLint: Enable @typescript-eslint/naming-convention rule
This check enforces consistent variable naming.

Signed-off-by: David Mehren <git@herrmehren.de>
2021-02-26 12:10:53 +01:00
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
6a6dc7ea21
ESLint: Re-enable @typescript-eslint/no-explicit-any rule
Signed-off-by: David Mehren <git@herrmehren.de>
2021-02-26 12:10:05 +01:00
Yannick Bungers
75be4611d3
Merge pull request #953 from hedgedoc/mediaBackendErrors 2021-02-25 22:23:11 +01:00
Philip Molares
31f7c76697 MediaController: Handle MediaBackendErrors
Signed-off-by: Philip Molares <philip.molares@udo.edu>
2021-02-25 13:59:32 +01:00
Philip Molares
8365132a39 FilesystemBackend: Throw MediaBackendError where appropriate
Signed-off-by: Philip Molares <philip.molares@udo.edu>
2021-02-25 13:52:50 +01:00