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
Philip Molares
bee2333f77
MediaService: Add MediaBackendError
...
This get's thrown when the backend can't perform the required action.
Signed-off-by: Philip Molares <philip.molares@udo.edu>
2021-02-25 13:51:54 +01:00
Philip Molares
ca064526a7
ConsoleLogger: Add typing to localeStringOptions
...
This is necessary as typescript is unable to determine that `year` in this object is of type "numeric" and not string.
Signed-off-by: Philip Molares <philip.molares@udo.edu>
2021-02-24 10:30:20 +01:00
David Mehren
0dd1f80db4
Merge pull request #948 from hedgedoc/fix/unusedImports
...
PermissionsModule: Remove unused imports
2021-02-23 21:09:26 +01:00
David Mehren
3fabf2596a
Merge pull request #943 from hedgedoc/refactor/getNoteContent
2021-02-23 21:05:25 +01:00
Philip Molares
0e6cc0b971
PermissionsModule: Remove unused imports
...
Signed-off-by: Philip Molares <philip.molares@udo.edu>
2021-02-23 19:13:41 +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
c9b05b3c44
NotesController: Handle new errors
...
Handle the AlreadyInDB and PermissionsUpdateInconsistent errors and correctly show them to the api user as BadRequest errors.
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
8b29e32e45
Errors: Add AlreadyInDB and PermissionsUpdateInconsistent error
...
Signed-off-by: Philip Molares <philip.molares@udo.edu>
2021-02-20 16:54:08 +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
577811be29
NotePermissions: Remove default constructors
...
As discussed in #835 we don't want to have default constructors and prefer .create methods.
Because the created NoteGroupPermission and NoteUserPermission are not saved to the DB by themselves, but are saved via a change to the Note using a Pick<Class, attributes>-style return type is not helpful here as every single time the .create functions are called a full object is required.
The mock calls in the PermissionService test are not needed and break the .create calls so they got removed.
Signed-off-by: Philip Molares <philip.molares@udo.edu>
2021-02-20 11:38:50 +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
Philip Molares
1aa821460f
NotesController: Catch NotInDBErrors from permission checks
...
The permission check also tries to get the note and a non existing note needs to be handled there too.
Signed-off-by: Philip Molares <philip.molares@udo.edu>
2021-02-18 22:25:55 +01:00
Yannick Bungers
0fc9c11a41
Add test for permission service
...
Many tests are generated and not static like in other files.
Signed-off-by: Yannick Bungers <git@innay.de>
2021-02-18 22:25:55 +01:00
Yannick Bungers
0ea7991e36
Add guest permission mock and checking
...
mocked by attribute of permission service
Signed-off-by: Yannick Bungers <git@innay.de>
2021-02-18 22:25:55 +01:00
Yannick Bungers
a694d71fff
Add permission checks for notes routes
...
Signed-off-by: Yannick Bungers <git@innay.de>
2021-02-18 22:25:55 +01:00
Yannick Bungers
f40ed5db2a
Add permissions Service
...
Checks if the given user has sufficient rights on the given resource.
Signed-off-by: Yannick Bungers <git@innay.de>
2021-02-18 22:25:55 +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
669688c12f
Merge pull request #847 from hedgedoc/test/authServiceUnitRewrite
...
Tests: Rewrote AuthService unit test
2021-02-16 22:29:14 +01:00
Philip Molares
680ca4188f
Tests: Rewrote AuthService unit test
...
The unit test now uses per test mocking of the necessary functions instead of one mock in the beforeEach call.
Also some tests got expanded to cover more error cases.
Signed-off-by: Philip Molares <philip.molares@udo.edu>
2021-02-16 22:25:37 +01:00
David Mehren
2367e3c31b
Merge pull request #912 from hedgedoc/feature/serverUploads
...
StaticServe: Fix serving images under uploads/
2021-02-16 21:50:35 +01:00
David Mehren
77f00d961a
Merge pull request #916 from hedgedoc/feature/prefixPublicApi
...
PublicApi: Add correct prefix
2021-02-16 21:49:54 +01:00
Philip Molares
e6c1cc7810
MediaService: Add unit tests
...
The file test.zip is used to fail the saveFile test with 'MIME Type not supported'
Signed-off-by: Philip Molares <philip.molares@udo.edu>
2021-02-16 21:12:23 +01:00
Philip Molares
3120d2dfb9
MediaService: Add JS-Docs to media service
...
Signed-off-by: Philip Molares <philip.molares@udo.edu>
2021-02-16 20:25:33 +01:00
Philip Molares
05ac7dc4ae
StaticServe: Fix serving images under uploads/
...
This did not work until now, because path and prefix were swapped.
Signed-off-by: Philip Molares <philip.molares@udo.edu>
2021-02-16 20:22:49 +01:00
Philip Molares
73113dc361
PublicApi: Add correct prefix
...
Using nest-router for this purpose as it is a rather easy addition to our structure. As we don't add the Router to any e2e tests we don't need to change them.
fixes #523
Signed-off-by: Philip Molares <philip.molares@udo.edu>
2021-02-16 20:19:45 +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
88ed1ec8ba
Docs: Add api tags to group controller
...
For a better structure of the autogenerated apidoc website tags are used. Each Controller get it's own tag and will be put in a separate section.
See https://docs.nestjs.com/openapi/operations#tags
Signed-off-by: Philip Molares <philip.molares@udo.edu>
2021-02-05 14:13:34 +01:00
Philip Molares
1becc9b3d2
Tests: Fix Mock Auth
...
This makes it possible to create the user before the mock auth guard does it's magic. This is necessary for some test, where we need the user object before the api is called.
Signed-off-by: Philip Molares <philip.molares@udo.edu>
2021-02-04 21:50:19 +01:00
Philip Molares
10ef4fcee1
History: Add unit and e2e test
...
Add unit tests for history service
Adapt relevant me e2e tests to work
Signed-off-by: Philip Molares <philip.molares@udo.edu>
2021-02-04 21:50:19 +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