Commit graph

341 commits

Author SHA1 Message Date
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