Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(contentUserData): add feature to save and retrieve contentUserdata (closes #1014) #1886

Merged
merged 103 commits into from
Jun 10, 2022

Conversation

JPSchellenberg
Copy link
Member

This PR will introduce the feature of saving and retreiving contentUserData.

@JPSchellenberg JPSchellenberg self-assigned this Nov 12, 2021
@JPSchellenberg JPSchellenberg added the [type] feature Changes that introduce a new feature (resulting in minor-version-bump) label Nov 12, 2021
@sr258 sr258 changed the title feat(contentUserData): add feature to save and retreive contentUserdata (closes #1014) feat(contentUserData): add feature to save and retrieve contentUserdata (closes #1014) Nov 13, 2021
@JPSchellenberg
Copy link
Member Author

Documentation and comments will follow tomorrow.

Right now the contentUserData can be integrated directly into the Integration generated by the H5PPlayer.generateIntegration-method. Loading it via the GET request does not work. See #1014 (comment)

package.json Outdated Show resolved Hide resolved
@sr258
Copy link
Member

sr258 commented Nov 14, 2021

I've added a few first remarks.

): Promise<void> {
const file = this.getUserDataFilePath(contentId);
try {
await fs.unlink(file);

Check failure

Code scanning / CodeQL

Uncontrolled data used in path expression

This path depends on [a user-provided value](1). This path depends on [a user-provided value](2).
const file = this.getUserDataFilePath(contentId);
let dataList: IContentUserData[];
try {
dataList = await fs.readJSON(file);

Check failure

Code scanning / CodeQL

Uncontrolled data used in path expression

This path depends on [a user-provided value](1). This path depends on [a user-provided value](2). This path depends on [a user-provided value](3).
): Promise<void> {
const file = this.getFinishedFilePath(contentId);
try {
await fs.unlink(file);

Check failure

Code scanning / CodeQL

Uncontrolled data used in path expression

This path depends on [a user-provided value](1). This path depends on [a user-provided value](2).
@sr258 sr258 merged commit bdf66da into master Jun 10, 2022
@sr258 sr258 deleted the feat/1014-contentUserData branch April 30, 2023 12:12
vlad-ilchenko pushed a commit to atmoschool/h5p-server that referenced this pull request Oct 29, 2024
* test(jest): run jest tests in watch mode via test:watch

* chore(scripts): add start:rest script

* feat(contentUserData): add parameters to contentUserDataUrl config

* feat(contentUserData): read saveFreq from config

* feat(contentUserData): add the contentUserData into the H5PIntegration

* test(contentUserDataGET): add example for GET issue

Lumieducation/H5P-Nodejs-library#1014 (comment)

* test(contentUserData): revert example

* chore(scripts): add h5p-server build script

* test(launch): add DEBUG to vscode launch

* refactor(script): rename start:rest to start:rest:server

Lumieducation/H5P-Nodejs-library#1886 (comment)

* refactor(saveFreq): rename saveFreq to contentUserStateSaveInterval

Lumieducation/H5P-Nodejs-library#1886 (comment)

* feat(contentUserData): delete contentUserData when content is deleted

* test(contentUserData): use mock for H5PPlayer.render test

* refactor(h5p-examples): add mock implementation to pass build

* feat(contentUserData): build contentUserDataIntegration in Manager

* feat(contentUserData): update interfaces

* test(contentUserDataManager): add tests

* refactor(h5p-examples): remove test/example conentUserDataStorage

* refactor(saveContentUserData): add invalidate and preload parameters

* feat(h5p-express): add ContentUserDataController

* fix(contentManager): delete contentUserDataStorage after content

Lumieducation/H5P-Nodejs-library#1886 (comment)

* refactor(ContentUserDataManager): remove unnecessary code

* refactor(ContentUserDataManager): use boolean instead of number

Lumieducation/H5P-Nodejs-library#1886 (comment)

* refactor(ContentManager): remove unnecessary code

* refactor(ContentUserDataManager): use boolean instead of number

Lumieducation/H5P-Nodejs-library#1886 (comment)

* fix(ContentUserDataManager): sanitize userState before saving

* feat(h5pexpress): add ContentUserDataRouter

* refactor(h5p-server): add deleteAllContentUserDataforContentId method

* refactor(h5p-examples): add reference implementation to h5p-example

* docs(ContentUserDataStorage): add contentUserDataStorage docs

* feat(contentUserData): add setFinished

* fix(ContentUserDataManager): throw H5pError instead of regular error

* fix(contentUserStateSaveInterval): change from seconds to milliseconds

Lumieducation/H5P-Nodejs-library#1886 (comment)

* refactor(code): remove redundant return statements

* refactor(code): reorder import statements

* refactor(log): change to debug from info

* refactor(code): remove typos, reorder imports, remove redundant code

* refactor(h5p-examples): don't use singleton

* fix(H5PPlayer): use contentUserStateSaveInterval in milliseconds

* refactor(code): fix typos

* fix(contentUserDataManager): saveContentUserData: check arguments

* fix(h5p-examples): correct json number declaration (#1991)

* feat(listContentUserDataByUserId): add listContentUserDataByUserId

* style(jsdocs): add divergence

* refactor: formatting and minor issues

* refactor: fixed imports

* test: corrected test

* refactor: decreased content user state save interval

* test: fix test

* fix(contentUserDataManager): remove userData when invalidate is true

Lumieducation/H5P-Nodejs-library#1886 (comment)

* fix(contentUserData): generate integration only when preload is true

Lumieducation/H5P-Nodejs-library#1886 (comment)

* feat(FileContentUserDataStorage): add FileContentUserDataStorage

* feat(contentUserData): include contentUserData in rest-example

* feat(contentUserData): include in rest example

* test(contentUserDataRouter): fix test

* chore(contentUserDataStorage): add json to gitignore

* build(h5p-shared-state-server): build h5p-shared-state-server on install

* fix(contentUserData): delete invalid contentUserData if content changes

Lumieducation/H5P-Nodejs-library#1886 (comment)

* refactor(contentUserData): rename saveContentUserData

saveContentUserData-method is renamed to createOrUpdateContentUserData

* feat(mongos3): add MongoContentUserDataStorage

* refactor: made namings more consistent

* refactor: minor cleanup

* fix: examples work

* test: use snapshot instead of inline HTML

* feat: corrected and extended MongoContentUserDataStorage

* fix: corrected FileContentUserDataStorage signature

* test: added more tests

* test: more tests

* feat: delete finished data when content is deleted

* feat: reimplemented FileContentUserDataStorage to work with directories

* test: added tests for FileContentUserDataStorage

* test: renamed generalized test file

* fix: missing user data doesn't return 404

* fix: corrected CSFR token generation + own route for setFinished

* fix: protected FileContentUserDataStorage against attacks

* test: corrected tests

* fix: corrected config to load falsy settings

* fix: improved filename validation

* feat: routes are closed when feature disabled in config

* feat: added CSRF tokens to rest example & fixed bugs

* fix: fileContentUserDataStorage saves more than one entry

* test: corrected test

* feat: improved  CSRF

* refactor: correct shared state example

* refactor: cleanup

* docs: added docs

Co-authored-by: Oliver Tacke <o.tacke@posteo.de>
Co-authored-by: Sebastian Rettig <serettig@posteo.de>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[type] feature Changes that introduce a new feature (resulting in minor-version-bump)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants