mirror of
https://codeberg.org/timelimit/timelimit-server.git
synced 2026-08-31 19:03:45 +02:00
Compare commits
16
Commits
2026-05-20
..
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d269e33524 | ||
|
|
e907a98c5c | ||
|
|
7df7790288 | ||
|
|
1aee08f409 | ||
|
|
85cd9f3bb0 | ||
|
|
52bde0bc23 | ||
|
|
1e5e74659e | ||
|
|
893f3664cf | ||
|
|
ccfbf97d36 | ||
|
|
bf338f4aff | ||
|
|
91cb44d244 | ||
|
|
235115168f | ||
|
|
b2bcc3715f | ||
|
|
2f35b969bf | ||
|
|
48d6a061f8 | ||
|
|
0b6ece0d28 |
+5
-1
@@ -100,7 +100,10 @@ request properties: ``purchaseToken``, ``purchaseId`` and ``dryRun``
|
|||||||
|
|
||||||
- ``purchasetoken`` is a string which the client shows at the purchase screen
|
- ``purchasetoken`` is a string which the client shows at the purchase screen
|
||||||
- ``purchaseId`` is the ID that is used at the bill
|
- ``purchaseId`` is the ID that is used at the bill
|
||||||
- ``dryRun`` is a boolean; setting true will skip the actual unlocking
|
- ``dryRun`` is a boolean
|
||||||
|
- setting true will skip the actual unlocking
|
||||||
|
- false will add a four week tolerance to the token expiry to permit checking now and unlocking later
|
||||||
|
- ``type`` is a string and must be ``year``, ``month`` or ``unpaid14``
|
||||||
|
|
||||||
### response
|
### response
|
||||||
|
|
||||||
@@ -121,6 +124,7 @@ The response contains the following properties:
|
|||||||
- optional object
|
- optional object
|
||||||
- should be shown to the support
|
- should be shown to the support
|
||||||
- ``wasAlreadyExecuted`` (boolean, set if and only if ``ok`` is true)
|
- ``wasAlreadyExecuted`` (boolean, set if and only if ``ok`` is true)
|
||||||
|
- ``mail`` (string, set if and only if ``ok`` is true)
|
||||||
|
|
||||||
If the request was malformed: HTTP status code 400 Bad Request
|
If the request was malformed: HTTP status code 400 Bad Request
|
||||||
|
|
||||||
|
|||||||
@@ -15,6 +15,8 @@ Use this before a purchase to check if a purchase is possible.
|
|||||||
|
|
||||||
see [this JSON schema](../schema/candopurchaserequest.md)
|
see [this JSON schema](../schema/candopurchaserequest.md)
|
||||||
|
|
||||||
|
Note that ``type`` is not used at all.
|
||||||
|
|
||||||
### response
|
### response
|
||||||
|
|
||||||
On a invalid request body: HTTP status code 400 Bad request
|
On a invalid request body: HTTP status code 400 Bad request
|
||||||
|
|||||||
@@ -14,8 +14,7 @@
|
|||||||
},
|
},
|
||||||
"additionalProperties": false,
|
"additionalProperties": false,
|
||||||
"required": [
|
"required": [
|
||||||
"deviceAuthToken",
|
"deviceAuthToken"
|
||||||
"type"
|
|
||||||
],
|
],
|
||||||
"definitions": {},
|
"definitions": {},
|
||||||
"$schema": "http://json-schema.org/draft-07/schema#",
|
"$schema": "http://json-schema.org/draft-07/schema#",
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ https://timelimit.io/CanDoPurchaseRequest
|
|||||||
|
|
||||||
| Property | Type | Required | Nullable | Defined by |
|
| Property | Type | Required | Nullable | Defined by |
|
||||||
| :---------------------------------- | :------- | :------- | :------------- | :------------------------------------------------------------------------------------------------------------------------------------------------- |
|
| :---------------------------------- | :------- | :------- | :------------- | :------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||||
| [type](#type) | `string` | Required | cannot be null | [CanDoPurchaseRequest](candopurchaserequest-properties-type.md "https://timelimit.io/CanDoPurchaseRequest#/properties/type") |
|
| [type](#type) | `string` | Optional | cannot be null | [CanDoPurchaseRequest](candopurchaserequest-properties-type.md "https://timelimit.io/CanDoPurchaseRequest#/properties/type") |
|
||||||
| [deviceAuthToken](#deviceauthtoken) | `string` | Required | cannot be null | [CanDoPurchaseRequest](candopurchaserequest-properties-deviceauthtoken.md "https://timelimit.io/CanDoPurchaseRequest#/properties/deviceAuthToken") |
|
| [deviceAuthToken](#deviceauthtoken) | `string` | Required | cannot be null | [CanDoPurchaseRequest](candopurchaserequest-properties-deviceauthtoken.md "https://timelimit.io/CanDoPurchaseRequest#/properties/deviceAuthToken") |
|
||||||
|
|
||||||
## type
|
## type
|
||||||
@@ -27,7 +27,7 @@ https://timelimit.io/CanDoPurchaseRequest
|
|||||||
|
|
||||||
`type`
|
`type`
|
||||||
|
|
||||||
* is required
|
* is optional
|
||||||
|
|
||||||
* Type: `string`
|
* Type: `string`
|
||||||
|
|
||||||
|
|||||||
Generated
+158
-158
@@ -19,7 +19,7 @@
|
|||||||
"jose": "^4.9.3",
|
"jose": "^4.9.3",
|
||||||
"lodash": "^4.17.21",
|
"lodash": "^4.17.21",
|
||||||
"mariadb": "^2.5.2",
|
"mariadb": "^2.5.2",
|
||||||
"nodemailer": "^8.0.4",
|
"nodemailer": "^9.0.4",
|
||||||
"pg": "^8.5.1",
|
"pg": "^8.5.1",
|
||||||
"pg-hstore": "^2.3.3",
|
"pg-hstore": "^2.3.3",
|
||||||
"rate-limiter-flexible": "^2.1.15",
|
"rate-limiter-flexible": "^2.1.15",
|
||||||
@@ -57,9 +57,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@adobe/jsonschema2md": {
|
"node_modules/@adobe/jsonschema2md": {
|
||||||
"version": "8.0.8",
|
"version": "8.0.11",
|
||||||
"resolved": "https://registry.npmjs.org/@adobe/jsonschema2md/-/jsonschema2md-8.0.8.tgz",
|
"resolved": "https://registry.npmjs.org/@adobe/jsonschema2md/-/jsonschema2md-8.0.11.tgz",
|
||||||
"integrity": "sha512-KqYjZxjvCj7/AlvVtXVKz1AJk+5f3LFnuWi8B2N1sRsJX3oCKNI/XXkns5uChaEL+qAazkvbh7AQd8kANtbjLA==",
|
"integrity": "sha512-WRfZRqoyQqQ5eRWcfFPa/r3UUnOoKqREsED09pHj6AU3upcNdw/Mj28CYX8C5SUyov2VjIOhZZSsNaUovm6tUw==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@types/json-schema": "^7.0.8",
|
"@types/json-schema": "^7.0.8",
|
||||||
@@ -67,13 +67,13 @@
|
|||||||
"@types/unist": "^3.0.3",
|
"@types/unist": "^3.0.3",
|
||||||
"es2015-i18n-tag": "1.6.1",
|
"es2015-i18n-tag": "1.6.1",
|
||||||
"ferrum": "1.9.4",
|
"ferrum": "1.9.4",
|
||||||
"fs-extra": "11.3.2",
|
"fs-extra": "11.3.4",
|
||||||
"github-slugger": "2.0.0",
|
"github-slugger": "2.0.0",
|
||||||
"js-yaml": "4.1.1",
|
"js-yaml": "4.1.1",
|
||||||
"json-schema": "^0.4.0",
|
"json-schema": "^0.4.0",
|
||||||
"mdast-builder": "1.1.1",
|
"mdast-builder": "1.1.1",
|
||||||
"mdast-util-to-string": "4.0.0",
|
"mdast-util-to-string": "4.0.0",
|
||||||
"readdirp": "4.1.2",
|
"readdirp": "5.0.0",
|
||||||
"remark-gfm": "^4.0.0",
|
"remark-gfm": "^4.0.0",
|
||||||
"remark-parse": "11.0.0",
|
"remark-parse": "11.0.0",
|
||||||
"remark-stringify": "11.0.0",
|
"remark-stringify": "11.0.0",
|
||||||
@@ -285,15 +285,15 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@eslint/config-array/node_modules/brace-expansion": {
|
"node_modules/@eslint/config-array/node_modules/brace-expansion": {
|
||||||
"version": "5.0.6",
|
"version": "5.0.9",
|
||||||
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-5.0.6.tgz",
|
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-5.0.9.tgz",
|
||||||
"integrity": "sha512-kLpxurY4Z4r9sgMsyG0Z9uzsBlgiU/EFKhj/h91/8yHu0edo7XuixOIH3VcJ8kkxs6/jPzoI6U9Vj3WqbMQ94g==",
|
"integrity": "sha512-ScQ4IuvIEF1TMlP7Zt+vjJ//9zlPb2SDcxWxM3bk8s6t6GGdJ7KO1dCcTidOPJKePW30LE/2cT7wCyPho9/Wxg==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"balanced-match": "^4.0.2"
|
"balanced-match": "^4.0.2"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": "18 || 20 || >=22"
|
"node": "20 || >=22"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@eslint/config-array/node_modules/minimatch": {
|
"node_modules/@eslint/config-array/node_modules/minimatch": {
|
||||||
@@ -959,9 +959,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@typescript-eslint/typescript-estree/node_modules/brace-expansion": {
|
"node_modules/@typescript-eslint/typescript-estree/node_modules/brace-expansion": {
|
||||||
"version": "2.0.3",
|
"version": "2.1.4",
|
||||||
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.3.tgz",
|
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.1.4.tgz",
|
||||||
"integrity": "sha512-MCV/fYJEbqx68aE58kv2cA/kiky1G8vux3OR6/jbS+jIMe/6fJWa0DTzJU7dqijOWYwHi1t29FlfYI9uytqlpA==",
|
"integrity": "sha512-hGfVzPxthbf3+2yjg/RBs60cB0FhqBS/zvdV/4wn4/BmN0bNMMHPc4V/BbFieqf1TKAGGAHnY4eSjajCl0f2Xg==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"balanced-match": "^1.0.0"
|
"balanced-match": "^1.0.0"
|
||||||
@@ -1198,9 +1198,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/body-parser": {
|
"node_modules/body-parser": {
|
||||||
"version": "1.20.4",
|
"version": "1.20.6",
|
||||||
"resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.20.4.tgz",
|
"resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.20.6.tgz",
|
||||||
"integrity": "sha512-ZTgYYLMOXY9qKU/57FAo8F+HA2dGX7bqGc71txDRC1rS4frdFI5R7NhluHxH6M0YItAP0sHB4uqAOcYKxO6uGA==",
|
"integrity": "sha512-p5tAzS57i5MV9fZFDj9LeIiTZEufbSe2eDozP+ElheSUq1m74CRq1jI4mYNDdVs9vQztXFLuk/Gd6BWTdwRJ5g==",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"bytes": "~3.1.2",
|
"bytes": "~3.1.2",
|
||||||
"content-type": "~1.0.5",
|
"content-type": "~1.0.5",
|
||||||
@@ -1210,7 +1210,7 @@
|
|||||||
"http-errors": "~2.0.1",
|
"http-errors": "~2.0.1",
|
||||||
"iconv-lite": "~0.4.24",
|
"iconv-lite": "~0.4.24",
|
||||||
"on-finished": "~2.4.1",
|
"on-finished": "~2.4.1",
|
||||||
"qs": "~6.14.0",
|
"qs": "~6.15.1",
|
||||||
"raw-body": "~2.5.3",
|
"raw-body": "~2.5.3",
|
||||||
"type-is": "~1.6.18",
|
"type-is": "~1.6.18",
|
||||||
"unpipe": "~1.0.0"
|
"unpipe": "~1.0.0"
|
||||||
@@ -1269,9 +1269,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/brace-expansion": {
|
"node_modules/brace-expansion": {
|
||||||
"version": "1.1.13",
|
"version": "1.1.18",
|
||||||
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.13.tgz",
|
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.18.tgz",
|
||||||
"integrity": "sha512-9ZLprWS6EENmhEOpjCYW2c8VkmOvckIJZfkr7rBW6dObmfgJ/L1GpSYW5Hpo9lDz4D1+n0Ckz8rU7FwHDQiG/w==",
|
"integrity": "sha512-Edep/X9fGqVNmzKBVsDYIOtD+z1tuezV70LBjdCst9Tqu76lsnvRiZ6oTic1n+/BIwX6QDGAO94PN4N2SADvtw==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"balanced-match": "^1.0.0",
|
"balanced-match": "^1.0.0",
|
||||||
@@ -1652,9 +1652,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/engine.io": {
|
"node_modules/engine.io": {
|
||||||
"version": "6.6.8",
|
"version": "6.6.9",
|
||||||
"resolved": "https://registry.npmjs.org/engine.io/-/engine.io-6.6.8.tgz",
|
"resolved": "https://registry.npmjs.org/engine.io/-/engine.io-6.6.9.tgz",
|
||||||
"integrity": "sha512-2agL3ueZhqxoVrfmntO8yuVj+uNSlIOnhykYHk3Cq0ShYPdUjjUiSJrQvXjq01I9jAuI0Zl2YO8Evv5Mqytm5g==",
|
"integrity": "sha512-clKkw4C7nJ22mGgoVcCg6V/W/TxdNyIOTr89k2ONZu81qqkddPFDF0LXcbAwhzPD8DjkiRCjzuiO6Y+fkpD4vg==",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@types/cors": "^2.8.12",
|
"@types/cors": "^2.8.12",
|
||||||
"@types/node": ">=10.0.0",
|
"@types/node": ">=10.0.0",
|
||||||
@@ -1665,7 +1665,7 @@
|
|||||||
"cors": "~2.8.5",
|
"cors": "~2.8.5",
|
||||||
"debug": "~4.4.1",
|
"debug": "~4.4.1",
|
||||||
"engine.io-parser": "~5.2.1",
|
"engine.io-parser": "~5.2.1",
|
||||||
"ws": "~8.20.1"
|
"ws": "~8.21.0"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=10.2.0"
|
"node": ">=10.2.0"
|
||||||
@@ -1725,9 +1725,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/es-object-atoms": {
|
"node_modules/es-object-atoms": {
|
||||||
"version": "1.1.1",
|
"version": "1.1.2",
|
||||||
"resolved": "https://registry.npmjs.org/es-object-atoms/-/es-object-atoms-1.1.1.tgz",
|
"resolved": "https://registry.npmjs.org/es-object-atoms/-/es-object-atoms-1.1.2.tgz",
|
||||||
"integrity": "sha512-FGgH2h8zKNim9ljj7dankFPcICIK9Cp5bm+c2gQSYePhpaG5+esrLODihIorn+Pe6FGJzWhXQotPv73jTaldXA==",
|
"integrity": "sha512-HWcBoN6NileqtSydK2FqHbS/LoDd2pqrnQHLyJzBj4kOp/ky2MWMN694xOfkK8/SnUsW2DH7EfyVlydKCsm1Zw==",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"es-errors": "^1.3.0"
|
"es-errors": "^1.3.0"
|
||||||
},
|
},
|
||||||
@@ -1881,15 +1881,15 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/eslint/node_modules/brace-expansion": {
|
"node_modules/eslint/node_modules/brace-expansion": {
|
||||||
"version": "5.0.6",
|
"version": "5.0.9",
|
||||||
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-5.0.6.tgz",
|
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-5.0.9.tgz",
|
||||||
"integrity": "sha512-kLpxurY4Z4r9sgMsyG0Z9uzsBlgiU/EFKhj/h91/8yHu0edo7XuixOIH3VcJ8kkxs6/jPzoI6U9Vj3WqbMQ94g==",
|
"integrity": "sha512-ScQ4IuvIEF1TMlP7Zt+vjJ//9zlPb2SDcxWxM3bk8s6t6GGdJ7KO1dCcTidOPJKePW30LE/2cT7wCyPho9/Wxg==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"balanced-match": "^4.0.2"
|
"balanced-match": "^4.0.2"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": "18 || 20 || >=22"
|
"node": "20 || >=22"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/eslint/node_modules/eslint-visitor-keys": {
|
"node_modules/eslint/node_modules/eslint-visitor-keys": {
|
||||||
@@ -2005,13 +2005,13 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/express": {
|
"node_modules/express": {
|
||||||
"version": "4.22.1",
|
"version": "4.22.2",
|
||||||
"resolved": "https://registry.npmjs.org/express/-/express-4.22.1.tgz",
|
"resolved": "https://registry.npmjs.org/express/-/express-4.22.2.tgz",
|
||||||
"integrity": "sha512-F2X8g9P1X7uCPZMA3MVf9wcTqlyNp7IhH5qPCI0izhaOIYXaW9L535tGA3qmjRzpH+bZczqq7hVKxTR4NWnu+g==",
|
"integrity": "sha512-IuL+Elrou2ZvCFHs18/CIzy2Nzvo25nZ1/D2eIZlz7c+QUayAcYoiM2BthCjs+EBHVpjYjcuLDAiCWgeIX3X1Q==",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"accepts": "~1.3.8",
|
"accepts": "~1.3.8",
|
||||||
"array-flatten": "1.1.1",
|
"array-flatten": "1.1.1",
|
||||||
"body-parser": "~1.20.3",
|
"body-parser": "~1.20.5",
|
||||||
"content-disposition": "~0.5.4",
|
"content-disposition": "~0.5.4",
|
||||||
"content-type": "~1.0.4",
|
"content-type": "~1.0.4",
|
||||||
"cookie": "~0.7.1",
|
"cookie": "~0.7.1",
|
||||||
@@ -2030,7 +2030,7 @@
|
|||||||
"parseurl": "~1.3.3",
|
"parseurl": "~1.3.3",
|
||||||
"path-to-regexp": "~0.1.12",
|
"path-to-regexp": "~0.1.12",
|
||||||
"proxy-addr": "~2.0.7",
|
"proxy-addr": "~2.0.7",
|
||||||
"qs": "~6.14.0",
|
"qs": "~6.15.1",
|
||||||
"range-parser": "~1.2.1",
|
"range-parser": "~1.2.1",
|
||||||
"safe-buffer": "5.2.1",
|
"safe-buffer": "5.2.1",
|
||||||
"send": "~0.19.0",
|
"send": "~0.19.0",
|
||||||
@@ -2170,9 +2170,9 @@
|
|||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"node_modules/fast-uri": {
|
"node_modules/fast-uri": {
|
||||||
"version": "3.1.2",
|
"version": "3.1.5",
|
||||||
"resolved": "https://registry.npmjs.org/fast-uri/-/fast-uri-3.1.2.tgz",
|
"resolved": "https://registry.npmjs.org/fast-uri/-/fast-uri-3.1.5.tgz",
|
||||||
"integrity": "sha512-rVjf7ArG3LTk+FS6Yw81V1DLuZl1bRbNrev6Tmd/9RaroeeRRJhAt7jg/6YFxbvAQXUCavSoZhPPj6oOx+5KjQ==",
|
"integrity": "sha512-gHwA1O9LDIcKunMKhObS/HimwtehO1nPUECKAu5TpKgaO19fcWEl4bliWe1jWxVFvIXztJjjQ4L8XQ1EU9f7Jw==",
|
||||||
"funding": [
|
"funding": [
|
||||||
{
|
{
|
||||||
"type": "github",
|
"type": "github",
|
||||||
@@ -2230,9 +2230,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/filelist/node_modules/brace-expansion": {
|
"node_modules/filelist/node_modules/brace-expansion": {
|
||||||
"version": "2.0.3",
|
"version": "2.1.4",
|
||||||
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.3.tgz",
|
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.1.4.tgz",
|
||||||
"integrity": "sha512-MCV/fYJEbqx68aE58kv2cA/kiky1G8vux3OR6/jbS+jIMe/6fJWa0DTzJU7dqijOWYwHi1t29FlfYI9uytqlpA==",
|
"integrity": "sha512-hGfVzPxthbf3+2yjg/RBs60cB0FhqBS/zvdV/4wn4/BmN0bNMMHPc4V/BbFieqf1TKAGGAHnY4eSjajCl0f2Xg==",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"balanced-match": "^1.0.0"
|
"balanced-match": "^1.0.0"
|
||||||
}
|
}
|
||||||
@@ -2357,9 +2357,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/fs-extra": {
|
"node_modules/fs-extra": {
|
||||||
"version": "11.3.2",
|
"version": "11.3.4",
|
||||||
"resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-11.3.2.tgz",
|
"resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-11.3.4.tgz",
|
||||||
"integrity": "sha512-Xr9F6z6up6Ws+NjzMCZc6WXg2YFRlrLP9NQDO3VQrWrfiojdhS56TzueT88ze0uBdCTwEIhQ3ptnmKeWGFAe0A==",
|
"integrity": "sha512-CTXd6rk/M3/ULNQj8FBqBWHYBVYybQ3VPBw0xGKFe3tuH7ytT6ACnvzpIQ3UZtB8yvUKC2cXn1a+x+5EVQLovA==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"graceful-fs": "^4.2.0",
|
"graceful-fs": "^4.2.0",
|
||||||
@@ -2491,9 +2491,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/graceful-fs": {
|
"node_modules/graceful-fs": {
|
||||||
"version": "4.2.9",
|
"version": "4.2.11",
|
||||||
"resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.9.tgz",
|
"resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.11.tgz",
|
||||||
"integrity": "sha512-NtNxqUcXgpW2iMrfqSfR73Glt39K+BLwWsPs94yR63v45T0Wbej7eRmL5cWfwEgqXnmjQp3zaJTshdRW/qC2ZQ==",
|
"integrity": "sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"node_modules/has-symbols": {
|
"node_modules/has-symbols": {
|
||||||
@@ -2508,9 +2508,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/hasown": {
|
"node_modules/hasown": {
|
||||||
"version": "2.0.2",
|
"version": "2.0.3",
|
||||||
"resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.2.tgz",
|
"resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.3.tgz",
|
||||||
"integrity": "sha512-0hJU9SCPvmMzIBdZFqNPXWa6dqh7WdH0cII9y+CyS8rG3nL48Bclra9HmKhVVUHyPWNH5Y7xDwAB7bfgSjkUMQ==",
|
"integrity": "sha512-ej4AhfhfL2Q2zpMmLo7U1Uv9+PyhIZpgQLGT1F9miIGmiCJIoCgSmczFdrc97mWT4kVY72KA+WnnhJ5pghSvSg==",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"function-bind": "^1.1.2"
|
"function-bind": "^1.1.2"
|
||||||
},
|
},
|
||||||
@@ -2707,9 +2707,9 @@
|
|||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"node_modules/jsonfile": {
|
"node_modules/jsonfile": {
|
||||||
"version": "6.2.0",
|
"version": "6.2.1",
|
||||||
"resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-6.2.0.tgz",
|
"resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-6.2.1.tgz",
|
||||||
"integrity": "sha512-FGuPw30AdOIUTRMC2OMRtQV+jkVj2cfPqSeWXv1NEAJ1qZ5zb1X6z1mFhbfOB/iy3ssJCD+3KuZ8r8C3uVFlAg==",
|
"integrity": "sha512-zwOTdL3rFQ/lRdBnntKVOX6k5cKJwEc1HdilT71BWEu7J41gXIB2MRp+vxduPSwZJPWBxEzv4yH1wYLJGUHX4Q==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"universalify": "^2.0.0"
|
"universalify": "^2.0.0"
|
||||||
@@ -3789,9 +3789,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/nodemailer": {
|
"node_modules/nodemailer": {
|
||||||
"version": "8.0.5",
|
"version": "9.0.4",
|
||||||
"resolved": "https://registry.npmjs.org/nodemailer/-/nodemailer-8.0.5.tgz",
|
"resolved": "https://registry.npmjs.org/nodemailer/-/nodemailer-9.0.4.tgz",
|
||||||
"integrity": "sha512-0PF8Yb1yZuQfQbq+5/pZJrtF6WQcjTd5/S4JOHs9PGFxuTqoB/icwuB44pOdURHJbRKX1PPoJZtY7R4VUoCC8w==",
|
"integrity": "sha512-LmJNRVRtfSCULxcZpy0Cpg4WWenlUZ9+zbmTO+S7v9wD6XreYLjXRFtDjtV/4F0HT5p1GyZfA0Ux/myxHb18CQ==",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=6.0.0"
|
"node": ">=6.0.0"
|
||||||
}
|
}
|
||||||
@@ -4110,9 +4110,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/qs": {
|
"node_modules/qs": {
|
||||||
"version": "6.14.2",
|
"version": "6.15.2",
|
||||||
"resolved": "https://registry.npmjs.org/qs/-/qs-6.14.2.tgz",
|
"resolved": "https://registry.npmjs.org/qs/-/qs-6.15.2.tgz",
|
||||||
"integrity": "sha512-V/yCWTTF7VJ9hIh18Ugr2zhJMP01MY7c5kh4J870L7imm6/DIzBsNLTXzMwUA3yZ5b/KBqLx8Kp3uRvd7xSe3Q==",
|
"integrity": "sha512-Rzq0KEyX/w/tEybncDgdkZrJgVUsUMk3xjh3t5bv3S1HTAtg+uOYt72+ZfwiQwKdysThkTBdL/rTi6HDmX9Ddw==",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"side-channel": "^1.1.0"
|
"side-channel": "^1.1.0"
|
||||||
},
|
},
|
||||||
@@ -4205,12 +4205,12 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/readdirp": {
|
"node_modules/readdirp": {
|
||||||
"version": "4.1.2",
|
"version": "5.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/readdirp/-/readdirp-4.1.2.tgz",
|
"resolved": "https://registry.npmjs.org/readdirp/-/readdirp-5.0.0.tgz",
|
||||||
"integrity": "sha512-GDhwkLfywWL2s6vEjyhri+eXmfH6j1L7JE27WhqLeYzoh/A3DBaYGEj2H/HFZCn/kMfim73FXxEJTw06WtxQwg==",
|
"integrity": "sha512-9u/XQ1pvrQtYyMpZe7DXKv2p5CNvyVwzUB6uhLAnQwHMSgKMBR62lc7AHljaeteeHXn11XTAaLLUVZYVZyuRBQ==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">= 14.18.0"
|
"node": ">= 20.19.0"
|
||||||
},
|
},
|
||||||
"funding": {
|
"funding": {
|
||||||
"type": "individual",
|
"type": "individual",
|
||||||
@@ -4565,12 +4565,12 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/side-channel-list": {
|
"node_modules/side-channel-list": {
|
||||||
"version": "1.0.0",
|
"version": "1.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/side-channel-list/-/side-channel-list-1.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/side-channel-list/-/side-channel-list-1.0.1.tgz",
|
||||||
"integrity": "sha512-FCLHtRD/gnpCiCHEiJLOwdmFP+wzCmDEkc9y7NsYxeF4u7Btsn1ZuwgwJGxImImHicJArLP4R0yX4c2KCrMrTA==",
|
"integrity": "sha512-mjn/0bi/oUURjc5Xl7IaWi/OJJJumuoJFQJfDDyO46+hBWsfaVM65TBHq2eoZBhzl9EchxOijpkbRC8SVBQU0w==",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"es-errors": "^1.3.0",
|
"es-errors": "^1.3.0",
|
||||||
"object-inspect": "^1.13.3"
|
"object-inspect": "^1.13.4"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">= 0.4"
|
"node": ">= 0.4"
|
||||||
@@ -4632,12 +4632,12 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/socket.io-adapter": {
|
"node_modules/socket.io-adapter": {
|
||||||
"version": "2.5.7",
|
"version": "2.5.8",
|
||||||
"resolved": "https://registry.npmjs.org/socket.io-adapter/-/socket.io-adapter-2.5.7.tgz",
|
"resolved": "https://registry.npmjs.org/socket.io-adapter/-/socket.io-adapter-2.5.8.tgz",
|
||||||
"integrity": "sha512-e0LyK91f3cUxTmv95/KzoLg47+zF+s/sbxRGDNsyG4dmIP8ZSX8ax6byOxfJXeNNtS/8AZlfD+uP7gBeR7DLlg==",
|
"integrity": "sha512-6Oy52pbg+kvdCVvjcN+FnY7BvxZ7cIHNScbvztT/It5d0vbwoJoVZmF2gjJmnV0/4WlXRfG15zc45ySk9Ah8bw==",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"debug": "~4.4.1",
|
"debug": "~4.4.1",
|
||||||
"ws": "~8.20.1"
|
"ws": "~8.21.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/socket.io-adapter/node_modules/debug": {
|
"node_modules/socket.io-adapter/node_modules/debug": {
|
||||||
@@ -4662,9 +4662,9 @@
|
|||||||
"integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA=="
|
"integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA=="
|
||||||
},
|
},
|
||||||
"node_modules/socket.io-parser": {
|
"node_modules/socket.io-parser": {
|
||||||
"version": "4.2.6",
|
"version": "4.2.7",
|
||||||
"resolved": "https://registry.npmjs.org/socket.io-parser/-/socket.io-parser-4.2.6.tgz",
|
"resolved": "https://registry.npmjs.org/socket.io-parser/-/socket.io-parser-4.2.7.tgz",
|
||||||
"integrity": "sha512-asJqbVBDsBCJx0pTqw3WfesSY0iRX+2xzWEWzrpcH7L6fLzrhyF8WPI8UaeM4YCuDfpwA/cgsdugMsmtz8EJeg==",
|
"integrity": "sha512-IH/iSeO9T6gz1KkFleGDWkG9N3dl4jXVYUtMhIqH10Md0ttMer8nUNWiP1DKuNrybD2xBrixLJdCC9J6ECoYkg==",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@socket.io/component-emitter": "~3.1.0",
|
"@socket.io/component-emitter": "~3.1.0",
|
||||||
"debug": "~4.4.1"
|
"debug": "~4.4.1"
|
||||||
@@ -4757,9 +4757,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/tar": {
|
"node_modules/tar": {
|
||||||
"version": "7.5.13",
|
"version": "7.5.21",
|
||||||
"resolved": "https://registry.npmjs.org/tar/-/tar-7.5.13.tgz",
|
"resolved": "https://registry.npmjs.org/tar/-/tar-7.5.21.tgz",
|
||||||
"integrity": "sha512-tOG/7GyXpFevhXVh8jOPJrmtRpOTsYqUIkVdVooZYJS/z8WhfQUX8RJILmeuJNinGAMSu1veBr4asSHFt5/hng==",
|
"integrity": "sha512-XdhtCvlMywwxpCW8YEq3lOXBJpUPTR2OHHcwLPO3HwsJqOHa2Ok/oJ7ruGzp+JrKoRPVCzJwAdEjqLW/vNRPHA==",
|
||||||
"optional": true,
|
"optional": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@isaacs/fs-minipass": "^4.0.0",
|
"@isaacs/fs-minipass": "^4.0.0",
|
||||||
@@ -5312,9 +5312,9 @@
|
|||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"node_modules/ws": {
|
"node_modules/ws": {
|
||||||
"version": "8.20.1",
|
"version": "8.21.0",
|
||||||
"resolved": "https://registry.npmjs.org/ws/-/ws-8.20.1.tgz",
|
"resolved": "https://registry.npmjs.org/ws/-/ws-8.21.0.tgz",
|
||||||
"integrity": "sha512-It4dO0K5v//JtTXuPkfEOaI3uUN87iYPnqo/ZzqCoG3g8uhA66QUMs/SrM0YK7/NAu+r4LMh/9dq2A7k+rHs+w==",
|
"integrity": "sha512-Vsp28b7DRcimFQvrqu2Wek3z1iYxDCWqHYB8Qsnk/S4RfaCQzPGPyBNuVjJV3cd6UiKtUtp6sNM77gWvzcCH+g==",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=10.0.0"
|
"node": ">=10.0.0"
|
||||||
},
|
},
|
||||||
@@ -5429,9 +5429,9 @@
|
|||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"@adobe/jsonschema2md": {
|
"@adobe/jsonschema2md": {
|
||||||
"version": "8.0.8",
|
"version": "8.0.11",
|
||||||
"resolved": "https://registry.npmjs.org/@adobe/jsonschema2md/-/jsonschema2md-8.0.8.tgz",
|
"resolved": "https://registry.npmjs.org/@adobe/jsonschema2md/-/jsonschema2md-8.0.11.tgz",
|
||||||
"integrity": "sha512-KqYjZxjvCj7/AlvVtXVKz1AJk+5f3LFnuWi8B2N1sRsJX3oCKNI/XXkns5uChaEL+qAazkvbh7AQd8kANtbjLA==",
|
"integrity": "sha512-WRfZRqoyQqQ5eRWcfFPa/r3UUnOoKqREsED09pHj6AU3upcNdw/Mj28CYX8C5SUyov2VjIOhZZSsNaUovm6tUw==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"@types/json-schema": "^7.0.8",
|
"@types/json-schema": "^7.0.8",
|
||||||
@@ -5439,13 +5439,13 @@
|
|||||||
"@types/unist": "^3.0.3",
|
"@types/unist": "^3.0.3",
|
||||||
"es2015-i18n-tag": "1.6.1",
|
"es2015-i18n-tag": "1.6.1",
|
||||||
"ferrum": "1.9.4",
|
"ferrum": "1.9.4",
|
||||||
"fs-extra": "11.3.2",
|
"fs-extra": "11.3.4",
|
||||||
"github-slugger": "2.0.0",
|
"github-slugger": "2.0.0",
|
||||||
"js-yaml": "4.1.1",
|
"js-yaml": "4.1.1",
|
||||||
"json-schema": "^0.4.0",
|
"json-schema": "^0.4.0",
|
||||||
"mdast-builder": "1.1.1",
|
"mdast-builder": "1.1.1",
|
||||||
"mdast-util-to-string": "4.0.0",
|
"mdast-util-to-string": "4.0.0",
|
||||||
"readdirp": "4.1.2",
|
"readdirp": "5.0.0",
|
||||||
"remark-gfm": "^4.0.0",
|
"remark-gfm": "^4.0.0",
|
||||||
"remark-parse": "11.0.0",
|
"remark-parse": "11.0.0",
|
||||||
"remark-stringify": "11.0.0",
|
"remark-stringify": "11.0.0",
|
||||||
@@ -5590,9 +5590,9 @@
|
|||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"brace-expansion": {
|
"brace-expansion": {
|
||||||
"version": "5.0.6",
|
"version": "5.0.9",
|
||||||
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-5.0.6.tgz",
|
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-5.0.9.tgz",
|
||||||
"integrity": "sha512-kLpxurY4Z4r9sgMsyG0Z9uzsBlgiU/EFKhj/h91/8yHu0edo7XuixOIH3VcJ8kkxs6/jPzoI6U9Vj3WqbMQ94g==",
|
"integrity": "sha512-ScQ4IuvIEF1TMlP7Zt+vjJ//9zlPb2SDcxWxM3bk8s6t6GGdJ7KO1dCcTidOPJKePW30LE/2cT7wCyPho9/Wxg==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"balanced-match": "^4.0.2"
|
"balanced-match": "^4.0.2"
|
||||||
@@ -6106,9 +6106,9 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"brace-expansion": {
|
"brace-expansion": {
|
||||||
"version": "2.0.3",
|
"version": "2.1.4",
|
||||||
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.3.tgz",
|
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.1.4.tgz",
|
||||||
"integrity": "sha512-MCV/fYJEbqx68aE58kv2cA/kiky1G8vux3OR6/jbS+jIMe/6fJWa0DTzJU7dqijOWYwHi1t29FlfYI9uytqlpA==",
|
"integrity": "sha512-hGfVzPxthbf3+2yjg/RBs60cB0FhqBS/zvdV/4wn4/BmN0bNMMHPc4V/BbFieqf1TKAGGAHnY4eSjajCl0f2Xg==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"balanced-match": "^1.0.0"
|
"balanced-match": "^1.0.0"
|
||||||
@@ -6271,9 +6271,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"body-parser": {
|
"body-parser": {
|
||||||
"version": "1.20.4",
|
"version": "1.20.6",
|
||||||
"resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.20.4.tgz",
|
"resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.20.6.tgz",
|
||||||
"integrity": "sha512-ZTgYYLMOXY9qKU/57FAo8F+HA2dGX7bqGc71txDRC1rS4frdFI5R7NhluHxH6M0YItAP0sHB4uqAOcYKxO6uGA==",
|
"integrity": "sha512-p5tAzS57i5MV9fZFDj9LeIiTZEufbSe2eDozP+ElheSUq1m74CRq1jI4mYNDdVs9vQztXFLuk/Gd6BWTdwRJ5g==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"bytes": "~3.1.2",
|
"bytes": "~3.1.2",
|
||||||
"content-type": "~1.0.5",
|
"content-type": "~1.0.5",
|
||||||
@@ -6283,7 +6283,7 @@
|
|||||||
"http-errors": "~2.0.1",
|
"http-errors": "~2.0.1",
|
||||||
"iconv-lite": "~0.4.24",
|
"iconv-lite": "~0.4.24",
|
||||||
"on-finished": "~2.4.1",
|
"on-finished": "~2.4.1",
|
||||||
"qs": "~6.14.0",
|
"qs": "~6.15.1",
|
||||||
"raw-body": "~2.5.3",
|
"raw-body": "~2.5.3",
|
||||||
"type-is": "~1.6.18",
|
"type-is": "~1.6.18",
|
||||||
"unpipe": "~1.0.0"
|
"unpipe": "~1.0.0"
|
||||||
@@ -6327,9 +6327,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"brace-expansion": {
|
"brace-expansion": {
|
||||||
"version": "1.1.13",
|
"version": "1.1.18",
|
||||||
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.13.tgz",
|
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.18.tgz",
|
||||||
"integrity": "sha512-9ZLprWS6EENmhEOpjCYW2c8VkmOvckIJZfkr7rBW6dObmfgJ/L1GpSYW5Hpo9lDz4D1+n0Ckz8rU7FwHDQiG/w==",
|
"integrity": "sha512-Edep/X9fGqVNmzKBVsDYIOtD+z1tuezV70LBjdCst9Tqu76lsnvRiZ6oTic1n+/BIwX6QDGAO94PN4N2SADvtw==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"balanced-match": "^1.0.0",
|
"balanced-match": "^1.0.0",
|
||||||
@@ -6598,9 +6598,9 @@
|
|||||||
"integrity": "sha512-TPJXq8JqFaVYm2CWmPvnP2Iyo4ZSM7/QKcSmuMLDObfpH5fi7RUGmd/rTDf+rut/saiDiQEeVTNgAmJEdAOx0w=="
|
"integrity": "sha512-TPJXq8JqFaVYm2CWmPvnP2Iyo4ZSM7/QKcSmuMLDObfpH5fi7RUGmd/rTDf+rut/saiDiQEeVTNgAmJEdAOx0w=="
|
||||||
},
|
},
|
||||||
"engine.io": {
|
"engine.io": {
|
||||||
"version": "6.6.8",
|
"version": "6.6.9",
|
||||||
"resolved": "https://registry.npmjs.org/engine.io/-/engine.io-6.6.8.tgz",
|
"resolved": "https://registry.npmjs.org/engine.io/-/engine.io-6.6.9.tgz",
|
||||||
"integrity": "sha512-2agL3ueZhqxoVrfmntO8yuVj+uNSlIOnhykYHk3Cq0ShYPdUjjUiSJrQvXjq01I9jAuI0Zl2YO8Evv5Mqytm5g==",
|
"integrity": "sha512-clKkw4C7nJ22mGgoVcCg6V/W/TxdNyIOTr89k2ONZu81qqkddPFDF0LXcbAwhzPD8DjkiRCjzuiO6Y+fkpD4vg==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"@types/cors": "^2.8.12",
|
"@types/cors": "^2.8.12",
|
||||||
"@types/node": ">=10.0.0",
|
"@types/node": ">=10.0.0",
|
||||||
@@ -6611,7 +6611,7 @@
|
|||||||
"cors": "~2.8.5",
|
"cors": "~2.8.5",
|
||||||
"debug": "~4.4.1",
|
"debug": "~4.4.1",
|
||||||
"engine.io-parser": "~5.2.1",
|
"engine.io-parser": "~5.2.1",
|
||||||
"ws": "~8.20.1"
|
"ws": "~8.21.0"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"cookie": {
|
"cookie": {
|
||||||
@@ -6650,9 +6650,9 @@
|
|||||||
"integrity": "sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw=="
|
"integrity": "sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw=="
|
||||||
},
|
},
|
||||||
"es-object-atoms": {
|
"es-object-atoms": {
|
||||||
"version": "1.1.1",
|
"version": "1.1.2",
|
||||||
"resolved": "https://registry.npmjs.org/es-object-atoms/-/es-object-atoms-1.1.1.tgz",
|
"resolved": "https://registry.npmjs.org/es-object-atoms/-/es-object-atoms-1.1.2.tgz",
|
||||||
"integrity": "sha512-FGgH2h8zKNim9ljj7dankFPcICIK9Cp5bm+c2gQSYePhpaG5+esrLODihIorn+Pe6FGJzWhXQotPv73jTaldXA==",
|
"integrity": "sha512-HWcBoN6NileqtSydK2FqHbS/LoDd2pqrnQHLyJzBj4kOp/ky2MWMN694xOfkK8/SnUsW2DH7EfyVlydKCsm1Zw==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"es-errors": "^1.3.0"
|
"es-errors": "^1.3.0"
|
||||||
}
|
}
|
||||||
@@ -6737,9 +6737,9 @@
|
|||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"brace-expansion": {
|
"brace-expansion": {
|
||||||
"version": "5.0.6",
|
"version": "5.0.9",
|
||||||
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-5.0.6.tgz",
|
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-5.0.9.tgz",
|
||||||
"integrity": "sha512-kLpxurY4Z4r9sgMsyG0Z9uzsBlgiU/EFKhj/h91/8yHu0edo7XuixOIH3VcJ8kkxs6/jPzoI6U9Vj3WqbMQ94g==",
|
"integrity": "sha512-ScQ4IuvIEF1TMlP7Zt+vjJ//9zlPb2SDcxWxM3bk8s6t6GGdJ7KO1dCcTidOPJKePW30LE/2cT7wCyPho9/Wxg==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"balanced-match": "^4.0.2"
|
"balanced-match": "^4.0.2"
|
||||||
@@ -6841,13 +6841,13 @@
|
|||||||
"integrity": "sha512-aIL5Fx7mawVa300al2BnEE4iNvo1qETxLrPI/o05L7z6go7fCw1J6EQmbK4FmJ2AS7kgVF/KEZWufBfdClMcPg=="
|
"integrity": "sha512-aIL5Fx7mawVa300al2BnEE4iNvo1qETxLrPI/o05L7z6go7fCw1J6EQmbK4FmJ2AS7kgVF/KEZWufBfdClMcPg=="
|
||||||
},
|
},
|
||||||
"express": {
|
"express": {
|
||||||
"version": "4.22.1",
|
"version": "4.22.2",
|
||||||
"resolved": "https://registry.npmjs.org/express/-/express-4.22.1.tgz",
|
"resolved": "https://registry.npmjs.org/express/-/express-4.22.2.tgz",
|
||||||
"integrity": "sha512-F2X8g9P1X7uCPZMA3MVf9wcTqlyNp7IhH5qPCI0izhaOIYXaW9L535tGA3qmjRzpH+bZczqq7hVKxTR4NWnu+g==",
|
"integrity": "sha512-IuL+Elrou2ZvCFHs18/CIzy2Nzvo25nZ1/D2eIZlz7c+QUayAcYoiM2BthCjs+EBHVpjYjcuLDAiCWgeIX3X1Q==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"accepts": "~1.3.8",
|
"accepts": "~1.3.8",
|
||||||
"array-flatten": "1.1.1",
|
"array-flatten": "1.1.1",
|
||||||
"body-parser": "~1.20.3",
|
"body-parser": "~1.20.5",
|
||||||
"content-disposition": "~0.5.4",
|
"content-disposition": "~0.5.4",
|
||||||
"content-type": "~1.0.4",
|
"content-type": "~1.0.4",
|
||||||
"cookie": "~0.7.1",
|
"cookie": "~0.7.1",
|
||||||
@@ -6866,7 +6866,7 @@
|
|||||||
"parseurl": "~1.3.3",
|
"parseurl": "~1.3.3",
|
||||||
"path-to-regexp": "~0.1.12",
|
"path-to-regexp": "~0.1.12",
|
||||||
"proxy-addr": "~2.0.7",
|
"proxy-addr": "~2.0.7",
|
||||||
"qs": "~6.14.0",
|
"qs": "~6.15.1",
|
||||||
"range-parser": "~1.2.1",
|
"range-parser": "~1.2.1",
|
||||||
"safe-buffer": "5.2.1",
|
"safe-buffer": "5.2.1",
|
||||||
"send": "~0.19.0",
|
"send": "~0.19.0",
|
||||||
@@ -6971,9 +6971,9 @@
|
|||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"fast-uri": {
|
"fast-uri": {
|
||||||
"version": "3.1.2",
|
"version": "3.1.5",
|
||||||
"resolved": "https://registry.npmjs.org/fast-uri/-/fast-uri-3.1.2.tgz",
|
"resolved": "https://registry.npmjs.org/fast-uri/-/fast-uri-3.1.5.tgz",
|
||||||
"integrity": "sha512-rVjf7ArG3LTk+FS6Yw81V1DLuZl1bRbNrev6Tmd/9RaroeeRRJhAt7jg/6YFxbvAQXUCavSoZhPPj6oOx+5KjQ=="
|
"integrity": "sha512-gHwA1O9LDIcKunMKhObS/HimwtehO1nPUECKAu5TpKgaO19fcWEl4bliWe1jWxVFvIXztJjjQ4L8XQ1EU9f7Jw=="
|
||||||
},
|
},
|
||||||
"fastestsmallesttextencoderdecoder": {
|
"fastestsmallesttextencoderdecoder": {
|
||||||
"version": "1.0.22",
|
"version": "1.0.22",
|
||||||
@@ -7018,9 +7018,9 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"brace-expansion": {
|
"brace-expansion": {
|
||||||
"version": "2.0.3",
|
"version": "2.1.4",
|
||||||
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.3.tgz",
|
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.1.4.tgz",
|
||||||
"integrity": "sha512-MCV/fYJEbqx68aE58kv2cA/kiky1G8vux3OR6/jbS+jIMe/6fJWa0DTzJU7dqijOWYwHi1t29FlfYI9uytqlpA==",
|
"integrity": "sha512-hGfVzPxthbf3+2yjg/RBs60cB0FhqBS/zvdV/4wn4/BmN0bNMMHPc4V/BbFieqf1TKAGGAHnY4eSjajCl0f2Xg==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"balanced-match": "^1.0.0"
|
"balanced-match": "^1.0.0"
|
||||||
}
|
}
|
||||||
@@ -7119,9 +7119,9 @@
|
|||||||
"integrity": "sha512-zJ2mQYM18rEFOudeV4GShTGIQ7RbzA7ozbU9I/XBpm7kqgMywgmylMwXHxZJmkVoYkna9d2pVXVXPdYTP9ej8Q=="
|
"integrity": "sha512-zJ2mQYM18rEFOudeV4GShTGIQ7RbzA7ozbU9I/XBpm7kqgMywgmylMwXHxZJmkVoYkna9d2pVXVXPdYTP9ej8Q=="
|
||||||
},
|
},
|
||||||
"fs-extra": {
|
"fs-extra": {
|
||||||
"version": "11.3.2",
|
"version": "11.3.4",
|
||||||
"resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-11.3.2.tgz",
|
"resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-11.3.4.tgz",
|
||||||
"integrity": "sha512-Xr9F6z6up6Ws+NjzMCZc6WXg2YFRlrLP9NQDO3VQrWrfiojdhS56TzueT88ze0uBdCTwEIhQ3ptnmKeWGFAe0A==",
|
"integrity": "sha512-CTXd6rk/M3/ULNQj8FBqBWHYBVYybQ3VPBw0xGKFe3tuH7ytT6ACnvzpIQ3UZtB8yvUKC2cXn1a+x+5EVQLovA==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"graceful-fs": "^4.2.0",
|
"graceful-fs": "^4.2.0",
|
||||||
@@ -7213,9 +7213,9 @@
|
|||||||
"integrity": "sha512-ZUKRh6/kUFoAiTAtTYPZJ3hw9wNxx+BIBOijnlG9PnrJsCcSjs1wyyD6vJpaYtgnzDrKYRSqf3OO6Rfa93xsRg=="
|
"integrity": "sha512-ZUKRh6/kUFoAiTAtTYPZJ3hw9wNxx+BIBOijnlG9PnrJsCcSjs1wyyD6vJpaYtgnzDrKYRSqf3OO6Rfa93xsRg=="
|
||||||
},
|
},
|
||||||
"graceful-fs": {
|
"graceful-fs": {
|
||||||
"version": "4.2.9",
|
"version": "4.2.11",
|
||||||
"resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.9.tgz",
|
"resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.11.tgz",
|
||||||
"integrity": "sha512-NtNxqUcXgpW2iMrfqSfR73Glt39K+BLwWsPs94yR63v45T0Wbej7eRmL5cWfwEgqXnmjQp3zaJTshdRW/qC2ZQ==",
|
"integrity": "sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"has-symbols": {
|
"has-symbols": {
|
||||||
@@ -7224,9 +7224,9 @@
|
|||||||
"integrity": "sha512-1cDNdwJ2Jaohmb3sg4OmKaMBwuC48sYni5HUw2DvsC8LjGTLK9h+eb1X6RyuOHe4hT0ULCW68iomhjUoKUqlPQ=="
|
"integrity": "sha512-1cDNdwJ2Jaohmb3sg4OmKaMBwuC48sYni5HUw2DvsC8LjGTLK9h+eb1X6RyuOHe4hT0ULCW68iomhjUoKUqlPQ=="
|
||||||
},
|
},
|
||||||
"hasown": {
|
"hasown": {
|
||||||
"version": "2.0.2",
|
"version": "2.0.3",
|
||||||
"resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.2.tgz",
|
"resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.3.tgz",
|
||||||
"integrity": "sha512-0hJU9SCPvmMzIBdZFqNPXWa6dqh7WdH0cII9y+CyS8rG3nL48Bclra9HmKhVVUHyPWNH5Y7xDwAB7bfgSjkUMQ==",
|
"integrity": "sha512-ej4AhfhfL2Q2zpMmLo7U1Uv9+PyhIZpgQLGT1F9miIGmiCJIoCgSmczFdrc97mWT4kVY72KA+WnnhJ5pghSvSg==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"function-bind": "^1.1.2"
|
"function-bind": "^1.1.2"
|
||||||
}
|
}
|
||||||
@@ -7372,9 +7372,9 @@
|
|||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"jsonfile": {
|
"jsonfile": {
|
||||||
"version": "6.2.0",
|
"version": "6.2.1",
|
||||||
"resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-6.2.0.tgz",
|
"resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-6.2.1.tgz",
|
||||||
"integrity": "sha512-FGuPw30AdOIUTRMC2OMRtQV+jkVj2cfPqSeWXv1NEAJ1qZ5zb1X6z1mFhbfOB/iy3ssJCD+3KuZ8r8C3uVFlAg==",
|
"integrity": "sha512-zwOTdL3rFQ/lRdBnntKVOX6k5cKJwEc1HdilT71BWEu7J41gXIB2MRp+vxduPSwZJPWBxEzv4yH1wYLJGUHX4Q==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"graceful-fs": "^4.1.6",
|
"graceful-fs": "^4.1.6",
|
||||||
@@ -8095,9 +8095,9 @@
|
|||||||
"optional": true
|
"optional": true
|
||||||
},
|
},
|
||||||
"nodemailer": {
|
"nodemailer": {
|
||||||
"version": "8.0.5",
|
"version": "9.0.4",
|
||||||
"resolved": "https://registry.npmjs.org/nodemailer/-/nodemailer-8.0.5.tgz",
|
"resolved": "https://registry.npmjs.org/nodemailer/-/nodemailer-9.0.4.tgz",
|
||||||
"integrity": "sha512-0PF8Yb1yZuQfQbq+5/pZJrtF6WQcjTd5/S4JOHs9PGFxuTqoB/icwuB44pOdURHJbRKX1PPoJZtY7R4VUoCC8w=="
|
"integrity": "sha512-LmJNRVRtfSCULxcZpy0Cpg4WWenlUZ9+zbmTO+S7v9wD6XreYLjXRFtDjtV/4F0HT5p1GyZfA0Ux/myxHb18CQ=="
|
||||||
},
|
},
|
||||||
"object-assign": {
|
"object-assign": {
|
||||||
"version": "4.1.1",
|
"version": "4.1.1",
|
||||||
@@ -8322,9 +8322,9 @@
|
|||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"qs": {
|
"qs": {
|
||||||
"version": "6.14.2",
|
"version": "6.15.2",
|
||||||
"resolved": "https://registry.npmjs.org/qs/-/qs-6.14.2.tgz",
|
"resolved": "https://registry.npmjs.org/qs/-/qs-6.15.2.tgz",
|
||||||
"integrity": "sha512-V/yCWTTF7VJ9hIh18Ugr2zhJMP01MY7c5kh4J870L7imm6/DIzBsNLTXzMwUA3yZ5b/KBqLx8Kp3uRvd7xSe3Q==",
|
"integrity": "sha512-Rzq0KEyX/w/tEybncDgdkZrJgVUsUMk3xjh3t5bv3S1HTAtg+uOYt72+ZfwiQwKdysThkTBdL/rTi6HDmX9Ddw==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"side-channel": "^1.1.0"
|
"side-channel": "^1.1.0"
|
||||||
}
|
}
|
||||||
@@ -8380,9 +8380,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"readdirp": {
|
"readdirp": {
|
||||||
"version": "4.1.2",
|
"version": "5.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/readdirp/-/readdirp-4.1.2.tgz",
|
"resolved": "https://registry.npmjs.org/readdirp/-/readdirp-5.0.0.tgz",
|
||||||
"integrity": "sha512-GDhwkLfywWL2s6vEjyhri+eXmfH6j1L7JE27WhqLeYzoh/A3DBaYGEj2H/HFZCn/kMfim73FXxEJTw06WtxQwg==",
|
"integrity": "sha512-9u/XQ1pvrQtYyMpZe7DXKv2p5CNvyVwzUB6uhLAnQwHMSgKMBR62lc7AHljaeteeHXn11XTAaLLUVZYVZyuRBQ==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"remark-gfm": {
|
"remark-gfm": {
|
||||||
@@ -8623,12 +8623,12 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"side-channel-list": {
|
"side-channel-list": {
|
||||||
"version": "1.0.0",
|
"version": "1.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/side-channel-list/-/side-channel-list-1.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/side-channel-list/-/side-channel-list-1.0.1.tgz",
|
||||||
"integrity": "sha512-FCLHtRD/gnpCiCHEiJLOwdmFP+wzCmDEkc9y7NsYxeF4u7Btsn1ZuwgwJGxImImHicJArLP4R0yX4c2KCrMrTA==",
|
"integrity": "sha512-mjn/0bi/oUURjc5Xl7IaWi/OJJJumuoJFQJfDDyO46+hBWsfaVM65TBHq2eoZBhzl9EchxOijpkbRC8SVBQU0w==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"es-errors": "^1.3.0",
|
"es-errors": "^1.3.0",
|
||||||
"object-inspect": "^1.13.3"
|
"object-inspect": "^1.13.4"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"side-channel-map": {
|
"side-channel-map": {
|
||||||
@@ -8669,12 +8669,12 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"socket.io-adapter": {
|
"socket.io-adapter": {
|
||||||
"version": "2.5.7",
|
"version": "2.5.8",
|
||||||
"resolved": "https://registry.npmjs.org/socket.io-adapter/-/socket.io-adapter-2.5.7.tgz",
|
"resolved": "https://registry.npmjs.org/socket.io-adapter/-/socket.io-adapter-2.5.8.tgz",
|
||||||
"integrity": "sha512-e0LyK91f3cUxTmv95/KzoLg47+zF+s/sbxRGDNsyG4dmIP8ZSX8ax6byOxfJXeNNtS/8AZlfD+uP7gBeR7DLlg==",
|
"integrity": "sha512-6Oy52pbg+kvdCVvjcN+FnY7BvxZ7cIHNScbvztT/It5d0vbwoJoVZmF2gjJmnV0/4WlXRfG15zc45ySk9Ah8bw==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"debug": "~4.4.1",
|
"debug": "~4.4.1",
|
||||||
"ws": "~8.20.1"
|
"ws": "~8.21.0"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"debug": {
|
"debug": {
|
||||||
@@ -8693,9 +8693,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"socket.io-parser": {
|
"socket.io-parser": {
|
||||||
"version": "4.2.6",
|
"version": "4.2.7",
|
||||||
"resolved": "https://registry.npmjs.org/socket.io-parser/-/socket.io-parser-4.2.6.tgz",
|
"resolved": "https://registry.npmjs.org/socket.io-parser/-/socket.io-parser-4.2.7.tgz",
|
||||||
"integrity": "sha512-asJqbVBDsBCJx0pTqw3WfesSY0iRX+2xzWEWzrpcH7L6fLzrhyF8WPI8UaeM4YCuDfpwA/cgsdugMsmtz8EJeg==",
|
"integrity": "sha512-IH/iSeO9T6gz1KkFleGDWkG9N3dl4jXVYUtMhIqH10Md0ttMer8nUNWiP1DKuNrybD2xBrixLJdCC9J6ECoYkg==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"@socket.io/component-emitter": "~3.1.0",
|
"@socket.io/component-emitter": "~3.1.0",
|
||||||
"debug": "~4.4.1"
|
"debug": "~4.4.1"
|
||||||
@@ -8762,9 +8762,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"tar": {
|
"tar": {
|
||||||
"version": "7.5.13",
|
"version": "7.5.21",
|
||||||
"resolved": "https://registry.npmjs.org/tar/-/tar-7.5.13.tgz",
|
"resolved": "https://registry.npmjs.org/tar/-/tar-7.5.21.tgz",
|
||||||
"integrity": "sha512-tOG/7GyXpFevhXVh8jOPJrmtRpOTsYqUIkVdVooZYJS/z8WhfQUX8RJILmeuJNinGAMSu1veBr4asSHFt5/hng==",
|
"integrity": "sha512-XdhtCvlMywwxpCW8YEq3lOXBJpUPTR2OHHcwLPO3HwsJqOHa2Ok/oJ7ruGzp+JrKoRPVCzJwAdEjqLW/vNRPHA==",
|
||||||
"optional": true,
|
"optional": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"@isaacs/fs-minipass": "^4.0.0",
|
"@isaacs/fs-minipass": "^4.0.0",
|
||||||
@@ -9171,9 +9171,9 @@
|
|||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"ws": {
|
"ws": {
|
||||||
"version": "8.20.1",
|
"version": "8.21.0",
|
||||||
"resolved": "https://registry.npmjs.org/ws/-/ws-8.20.1.tgz",
|
"resolved": "https://registry.npmjs.org/ws/-/ws-8.21.0.tgz",
|
||||||
"integrity": "sha512-It4dO0K5v//JtTXuPkfEOaI3uUN87iYPnqo/ZzqCoG3g8uhA66QUMs/SrM0YK7/NAu+r4LMh/9dq2A7k+rHs+w==",
|
"integrity": "sha512-Vsp28b7DRcimFQvrqu2Wek3z1iYxDCWqHYB8Qsnk/S4RfaCQzPGPyBNuVjJV3cd6UiKtUtp6sNM77gWvzcCH+g==",
|
||||||
"requires": {}
|
"requires": {}
|
||||||
},
|
},
|
||||||
"xtend": {
|
"xtend": {
|
||||||
|
|||||||
+1
-1
@@ -55,7 +55,7 @@
|
|||||||
"jose": "^4.9.3",
|
"jose": "^4.9.3",
|
||||||
"lodash": "^4.17.21",
|
"lodash": "^4.17.21",
|
||||||
"mariadb": "^2.5.2",
|
"mariadb": "^2.5.2",
|
||||||
"nodemailer": "^8.0.4",
|
"nodemailer": "^9.0.4",
|
||||||
"pg": "^8.5.1",
|
"pg": "^8.5.1",
|
||||||
"pg-hstore": "^2.3.3",
|
"pg-hstore": "^2.3.3",
|
||||||
"rate-limiter-flexible": "^2.1.15",
|
"rate-limiter-flexible": "^2.1.15",
|
||||||
|
|||||||
+35
-25
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* server component for the TimeLimit App
|
* server component for the TimeLimit App
|
||||||
* Copyright (C) 2019 - 2022 Jonas Lochmann
|
* Copyright (C) 2019 - 2026 Jonas Lochmann
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU Affero General Public License as
|
* it under the terms of the GNU Affero General Public License as
|
||||||
@@ -19,7 +19,7 @@ import { json } from 'body-parser'
|
|||||||
import { Router } from 'express'
|
import { Router } from 'express'
|
||||||
import { BadRequest, Conflict } from 'http-errors'
|
import { BadRequest, Conflict } from 'http-errors'
|
||||||
import * as Sequelize from 'sequelize'
|
import * as Sequelize from 'sequelize'
|
||||||
import { Database } from '../database'
|
import { SimpleDatabase } from '../database/simple'
|
||||||
import { addPurchase, canDoNextPurchase } from '../function/purchase'
|
import { addPurchase, canDoNextPurchase } from '../function/purchase'
|
||||||
import { getStatusMessage, setStatusMessage } from '../function/statusmessage'
|
import { getStatusMessage, setStatusMessage } from '../function/statusmessage'
|
||||||
import { EventHandler } from '../monitoring/eventhandler'
|
import { EventHandler } from '../monitoring/eventhandler'
|
||||||
@@ -28,7 +28,7 @@ import { verifyIdentitifyToken, TokenValidationException } from '../util/identit
|
|||||||
import { WebsocketApi } from '../websocket'
|
import { WebsocketApi } from '../websocket'
|
||||||
|
|
||||||
export const createAdminRouter = ({ database, websocket, eventHandler }: {
|
export const createAdminRouter = ({ database, websocket, eventHandler }: {
|
||||||
database: Database
|
database: SimpleDatabase
|
||||||
websocket: WebsocketApi
|
websocket: WebsocketApi
|
||||||
eventHandler: EventHandler
|
eventHandler: EventHandler
|
||||||
}) => {
|
}) => {
|
||||||
@@ -60,7 +60,9 @@ export const createAdminRouter = ({ database, websocket, eventHandler }: {
|
|||||||
|
|
||||||
router.get('/status-message', async (_, res, next) => {
|
router.get('/status-message', async (_, res, next) => {
|
||||||
try {
|
try {
|
||||||
const currentStatusMessage = await getStatusMessage({ database })
|
const currentStatusMessage = await database.transaction(async (transaction) => {
|
||||||
|
return getStatusMessage({ transaction })
|
||||||
|
})
|
||||||
|
|
||||||
res.json({
|
res.json({
|
||||||
statusMessage: currentStatusMessage
|
statusMessage: currentStatusMessage
|
||||||
@@ -102,12 +104,12 @@ export const createAdminRouter = ({ database, websocket, eventHandler }: {
|
|||||||
}
|
}
|
||||||
|
|
||||||
await database.transaction(async (transaction) => {
|
await database.transaction(async (transaction) => {
|
||||||
const userEntryUnsafe = await database.user.findOne({
|
const userEntryUnsafe = await transaction.legacy.database.user.findOne({
|
||||||
where: {
|
where: {
|
||||||
mail
|
mail
|
||||||
},
|
},
|
||||||
attributes: ['familyId'],
|
attributes: ['familyId'],
|
||||||
transaction
|
transaction: transaction.legacy.transaction
|
||||||
})
|
})
|
||||||
|
|
||||||
if (!userEntryUnsafe) {
|
if (!userEntryUnsafe) {
|
||||||
@@ -119,13 +121,12 @@ export const createAdminRouter = ({ database, websocket, eventHandler }: {
|
|||||||
}
|
}
|
||||||
|
|
||||||
await addPurchase({
|
await addPurchase({
|
||||||
database,
|
transaction,
|
||||||
familyId: userEntry.familyId,
|
familyId: userEntry.familyId,
|
||||||
type,
|
type,
|
||||||
service: 'directpurchase',
|
service: 'directpurchase',
|
||||||
transactionId: 'legacyunlock-' + type + '-' + generatePurchaseId(),
|
transactionId: 'legacyunlock-' + type + '-' + generatePurchaseId(),
|
||||||
websocket,
|
websocket
|
||||||
transaction
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -141,7 +142,8 @@ export const createAdminRouter = ({ database, websocket, eventHandler }: {
|
|||||||
typeof req.body !== 'object' ||
|
typeof req.body !== 'object' ||
|
||||||
typeof req.body.purchaseToken !== 'string' ||
|
typeof req.body.purchaseToken !== 'string' ||
|
||||||
typeof req.body.purchaseId !== 'string' ||
|
typeof req.body.purchaseId !== 'string' ||
|
||||||
typeof req.body.dryRun !== 'boolean'
|
typeof req.body.dryRun !== 'boolean' ||
|
||||||
|
typeof req.body.type !== 'string'
|
||||||
) {
|
) {
|
||||||
throw new BadRequest()
|
throw new BadRequest()
|
||||||
}
|
}
|
||||||
@@ -149,8 +151,13 @@ export const createAdminRouter = ({ database, websocket, eventHandler }: {
|
|||||||
const purchaseToken: string = req.body.purchaseToken
|
const purchaseToken: string = req.body.purchaseToken
|
||||||
const purchaseId: string = req.body.purchaseId
|
const purchaseId: string = req.body.purchaseId
|
||||||
const dryRun: boolean = req.body.dryRun
|
const dryRun: boolean = req.body.dryRun
|
||||||
|
const type: string = req.body.type
|
||||||
|
|
||||||
const tokenContent = await verifyIdentitifyToken(purchaseToken)
|
if (type !== 'month' && type !== 'year' && type !== 'unpaid14') {
|
||||||
|
throw new BadRequest()
|
||||||
|
}
|
||||||
|
|
||||||
|
const tokenContent = await verifyIdentitifyToken(purchaseToken, dryRun)
|
||||||
|
|
||||||
if (tokenContent.purpose !== 'purchase') {
|
if (tokenContent.purpose !== 'purchase') {
|
||||||
res.json({ ok: false, error: 'token invalid', detail: 'wrong purpose' })
|
res.json({ ok: false, error: 'token invalid', detail: 'wrong purpose' })
|
||||||
@@ -159,14 +166,14 @@ export const createAdminRouter = ({ database, websocket, eventHandler }: {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const response = await database.transaction(async (transaction) => {
|
const response = await database.transaction(async (transaction) => {
|
||||||
const userValid = await database.user.count({
|
const userValid = await transaction.legacy.database.user.count({
|
||||||
where: {
|
where: {
|
||||||
familyId: tokenContent.familyId,
|
familyId: tokenContent.familyId,
|
||||||
userId: tokenContent.userId,
|
userId: tokenContent.userId,
|
||||||
mail: tokenContent.mail,
|
mail: tokenContent.mail,
|
||||||
type: 'parent'
|
type: 'parent'
|
||||||
},
|
},
|
||||||
transaction
|
transaction: transaction.legacy.transaction
|
||||||
})
|
})
|
||||||
|
|
||||||
if (!userValid) return {
|
if (!userValid) return {
|
||||||
@@ -179,7 +186,7 @@ export const createAdminRouter = ({ database, websocket, eventHandler }: {
|
|||||||
|
|
||||||
if (tokenContent.mail !== '') mailToReturn = tokenContent.mail
|
if (tokenContent.mail !== '') mailToReturn = tokenContent.mail
|
||||||
else {
|
else {
|
||||||
const userEntryWithMail = await database.user.findOne({
|
const userEntryWithMail = await transaction.legacy.database.user.findOne({
|
||||||
where: {
|
where: {
|
||||||
familyId: tokenContent.familyId,
|
familyId: tokenContent.familyId,
|
||||||
mail: {
|
mail: {
|
||||||
@@ -187,7 +194,7 @@ export const createAdminRouter = ({ database, websocket, eventHandler }: {
|
|||||||
},
|
},
|
||||||
type: 'parent'
|
type: 'parent'
|
||||||
},
|
},
|
||||||
transaction
|
transaction: transaction.legacy.transaction
|
||||||
})
|
})
|
||||||
|
|
||||||
if (!userEntryWithMail) return {
|
if (!userEntryWithMail) return {
|
||||||
@@ -201,11 +208,12 @@ export const createAdminRouter = ({ database, websocket, eventHandler }: {
|
|||||||
|
|
||||||
let wasAlreadyExecuted: boolean
|
let wasAlreadyExecuted: boolean
|
||||||
|
|
||||||
const oldPurchaseByPurchaseId = await database.purchase.findOne({
|
const oldPurchaseByPurchaseId = await transaction.legacy.database.purchase.findOne({
|
||||||
where: {
|
where: {
|
||||||
service: 'directpurchase',
|
service: 'directpurchase',
|
||||||
transactionId: purchaseId
|
transactionId: purchaseId
|
||||||
}
|
},
|
||||||
|
transaction: transaction.legacy.transaction
|
||||||
})
|
})
|
||||||
|
|
||||||
if (oldPurchaseByPurchaseId === null) wasAlreadyExecuted = false
|
if (oldPurchaseByPurchaseId === null) wasAlreadyExecuted = false
|
||||||
@@ -216,11 +224,11 @@ export const createAdminRouter = ({ database, websocket, eventHandler }: {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!wasAlreadyExecuted) {
|
if (!wasAlreadyExecuted) {
|
||||||
const familyEntry = await database.family.findOne({
|
const familyEntry = await transaction.legacy.database.family.findOne({
|
||||||
where: {
|
where: {
|
||||||
familyId: tokenContent.familyId
|
familyId: tokenContent.familyId
|
||||||
},
|
},
|
||||||
transaction
|
transaction: transaction.legacy.transaction
|
||||||
})
|
})
|
||||||
|
|
||||||
if (!familyEntry) return {
|
if (!familyEntry) return {
|
||||||
@@ -228,14 +236,17 @@ export const createAdminRouter = ({ database, websocket, eventHandler }: {
|
|||||||
error: 'family not found'
|
error: 'family not found'
|
||||||
}
|
}
|
||||||
|
|
||||||
const canDoPurchase = canDoNextPurchase({ fullVersionUntil: parseInt(familyEntry.fullVersionUntil) })
|
const canDoPurchase = canDoNextPurchase({
|
||||||
|
fullVersionUntil: parseInt(familyEntry.fullVersionUntil),
|
||||||
|
fullVersionDebts: parseInt(familyEntry.fullVersionDebts),
|
||||||
|
})
|
||||||
|
|
||||||
if (!canDoPurchase) {
|
if (!canDoPurchase) {
|
||||||
const lastPurchase = await database.purchase.findOne({
|
const lastPurchase = await transaction.legacy.database.purchase.findOne({
|
||||||
where: {
|
where: {
|
||||||
familyId: tokenContent.familyId
|
familyId: tokenContent.familyId
|
||||||
},
|
},
|
||||||
transaction,
|
transaction: transaction.legacy.transaction,
|
||||||
order: [['loggedAt', 'DESC']],
|
order: [['loggedAt', 'DESC']],
|
||||||
limit: 1
|
limit: 1
|
||||||
})
|
})
|
||||||
@@ -254,13 +265,12 @@ export const createAdminRouter = ({ database, websocket, eventHandler }: {
|
|||||||
|
|
||||||
if (!dryRun) {
|
if (!dryRun) {
|
||||||
await addPurchase({
|
await addPurchase({
|
||||||
database,
|
transaction,
|
||||||
familyId: tokenContent.familyId,
|
familyId: tokenContent.familyId,
|
||||||
type: 'year',
|
type,
|
||||||
service: 'directpurchase',
|
service: 'directpurchase',
|
||||||
transactionId: purchaseId,
|
transactionId: purchaseId,
|
||||||
websocket,
|
websocket,
|
||||||
transaction
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-3
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* server component for the TimeLimit App
|
* server component for the TimeLimit App
|
||||||
* Copyright (C) 2019 - 2021 Jonas Lochmann
|
* Copyright (C) 2019 - 2026 Jonas Lochmann
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU Affero General Public License as
|
* it under the terms of the GNU Affero General Public License as
|
||||||
@@ -18,7 +18,7 @@
|
|||||||
import { json } from 'body-parser'
|
import { json } from 'body-parser'
|
||||||
import { Router } from 'express'
|
import { Router } from 'express'
|
||||||
import { BadRequest } from 'http-errors'
|
import { BadRequest } from 'http-errors'
|
||||||
import { Database } from '../database'
|
import { SimpleDatabase } from '../database/simple'
|
||||||
import { sendLoginCode, signInByMailCode } from '../function/authentication/login-by-mail'
|
import { sendLoginCode, signInByMailCode } from '../function/authentication/login-by-mail'
|
||||||
import { isMailAddressCoveredByWhitelist, isMailServerBlacklisted, sanitizeMailAddress } from '../util/mail'
|
import { isMailAddressCoveredByWhitelist, isMailServerBlacklisted, sanitizeMailAddress } from '../util/mail'
|
||||||
import {
|
import {
|
||||||
@@ -26,7 +26,7 @@ import {
|
|||||||
isSignInByMailCodeRequest
|
isSignInByMailCodeRequest
|
||||||
} from './validator'
|
} from './validator'
|
||||||
|
|
||||||
export const createAuthRouter = (database: Database) => {
|
export const createAuthRouter = (database: SimpleDatabase) => {
|
||||||
const router = Router()
|
const router = Router()
|
||||||
|
|
||||||
router.post('/send-mail-login-code-v2', json(), async (req, res, next) => {
|
router.post('/send-mail-login-code-v2', json(), async (req, res, next) => {
|
||||||
|
|||||||
+3
-3
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* server component for the TimeLimit App
|
* server component for the TimeLimit App
|
||||||
* Copyright (C) 2019 - 2022 Jonas Lochmann
|
* Copyright (C) 2019 - 2026 Jonas Lochmann
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU Affero General Public License as
|
* it under the terms of the GNU Affero General Public License as
|
||||||
@@ -18,7 +18,7 @@
|
|||||||
import { json } from 'body-parser'
|
import { json } from 'body-parser'
|
||||||
import { Router } from 'express'
|
import { Router } from 'express'
|
||||||
import { BadRequest } from 'http-errors'
|
import { BadRequest } from 'http-errors'
|
||||||
import { Database } from '../database'
|
import { SimpleDatabase } from '../database/simple'
|
||||||
import { addChildDevice } from '../function/child/add-device'
|
import { addChildDevice } from '../function/child/add-device'
|
||||||
import { logoutAtPrimaryDevice } from '../function/child/logout-at-primary-device'
|
import { logoutAtPrimaryDevice } from '../function/child/logout-at-primary-device'
|
||||||
import { setPrimaryDevice } from '../function/child/set-primary-device'
|
import { setPrimaryDevice } from '../function/child/set-primary-device'
|
||||||
@@ -27,7 +27,7 @@ import { isRegisterChildDeviceRequest, isRequestWithAuthToken, isUpdatePrimaryDe
|
|||||||
import { EventHandler } from '../monitoring/eventhandler'
|
import { EventHandler } from '../monitoring/eventhandler'
|
||||||
|
|
||||||
export const createChildRouter = ({ database, websocket, eventHandler }: {
|
export const createChildRouter = ({ database, websocket, eventHandler }: {
|
||||||
database: Database
|
database: SimpleDatabase
|
||||||
websocket: WebsocketApi
|
websocket: WebsocketApi
|
||||||
eventHandler: EventHandler
|
eventHandler: EventHandler
|
||||||
}) => {
|
}) => {
|
||||||
|
|||||||
+3
-3
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* server component for the TimeLimit App
|
* server component for the TimeLimit App
|
||||||
* Copyright (C) 2019 - 2022 Jonas Lochmann
|
* Copyright (C) 2019 - 2026 Jonas Lochmann
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU Affero General Public License as
|
* it under the terms of the GNU Affero General Public License as
|
||||||
@@ -18,7 +18,7 @@
|
|||||||
import * as basicAuth from 'basic-auth'
|
import * as basicAuth from 'basic-auth'
|
||||||
import * as express from 'express'
|
import * as express from 'express'
|
||||||
import { VisibleConnectedDevicesManager } from '../connected-devices'
|
import { VisibleConnectedDevicesManager } from '../connected-devices'
|
||||||
import { Database } from '../database'
|
import { SimpleDatabase } from '../database/simple'
|
||||||
import { EventHandler } from '../monitoring/eventhandler'
|
import { EventHandler } from '../monitoring/eventhandler'
|
||||||
import { WebsocketApi } from '../websocket'
|
import { WebsocketApi } from '../websocket'
|
||||||
import { createAdminRouter } from './admin'
|
import { createAdminRouter } from './admin'
|
||||||
@@ -31,7 +31,7 @@ import { createSyncRouter } from './sync'
|
|||||||
const adminToken = process.env.ADMIN_TOKEN || ''
|
const adminToken = process.env.ADMIN_TOKEN || ''
|
||||||
|
|
||||||
export const createApi = ({ database, websocket, connectedDevicesManager, eventHandler }: {
|
export const createApi = ({ database, websocket, connectedDevicesManager, eventHandler }: {
|
||||||
database: Database
|
database: SimpleDatabase
|
||||||
websocket: WebsocketApi
|
websocket: WebsocketApi
|
||||||
connectedDevicesManager: VisibleConnectedDevicesManager
|
connectedDevicesManager: VisibleConnectedDevicesManager
|
||||||
eventHandler: EventHandler
|
eventHandler: EventHandler
|
||||||
|
|||||||
+18
-20
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* server component for the TimeLimit App
|
* server component for the TimeLimit App
|
||||||
* Copyright (C) 2019 - 2023 Jonas Lochmann
|
* Copyright (C) 2019 - 2026 Jonas Lochmann
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU Affero General Public License as
|
* it under the terms of the GNU Affero General Public License as
|
||||||
@@ -20,7 +20,7 @@ import { createHmac } from 'crypto'
|
|||||||
import { Router } from 'express'
|
import { Router } from 'express'
|
||||||
import { BadRequest, Forbidden, Unauthorized } from 'http-errors'
|
import { BadRequest, Forbidden, Unauthorized } from 'http-errors'
|
||||||
import { config } from '../config'
|
import { config } from '../config'
|
||||||
import { Database, Transaction } from '../database'
|
import { SimpleDatabase, SimpleDatabaseTransaction } from '../database/simple'
|
||||||
import { deleteAccount } from '../function/cleanup/account-deletion'
|
import { deleteAccount } from '../function/cleanup/account-deletion'
|
||||||
import { removeDevice } from '../function/device/remove-device'
|
import { removeDevice } from '../function/device/remove-device'
|
||||||
import { createAddDeviceToken } from '../function/parent/create-add-device-token'
|
import { createAddDeviceToken } from '../function/parent/create-add-device-token'
|
||||||
@@ -44,7 +44,7 @@ import {
|
|||||||
export const createParentRouter = ({
|
export const createParentRouter = ({
|
||||||
database, websocket, eventHandler
|
database, websocket, eventHandler
|
||||||
}: {
|
}: {
|
||||||
database: Database
|
database: SimpleDatabase
|
||||||
websocket: WebsocketApi
|
websocket: WebsocketApi
|
||||||
eventHandler: EventHandler
|
eventHandler: EventHandler
|
||||||
}) => {
|
}) => {
|
||||||
@@ -58,7 +58,7 @@ export const createParentRouter = ({
|
|||||||
|
|
||||||
const { mailAuthToken } = req.body
|
const { mailAuthToken } = req.body
|
||||||
const { status, mail } = await database.transaction(async (transaction) => {
|
const { status, mail } = await database.transaction(async (transaction) => {
|
||||||
return getStatusByMailToken({ database, mailAuthToken, transaction })
|
return getStatusByMailToken({ transaction, mailAuthToken })
|
||||||
})
|
})
|
||||||
|
|
||||||
res.json({
|
res.json({
|
||||||
@@ -153,13 +153,13 @@ export const createParentRouter = ({
|
|||||||
deviceAuthToken: string
|
deviceAuthToken: string
|
||||||
parentId: string
|
parentId: string
|
||||||
secondPasswordHash: string
|
secondPasswordHash: string
|
||||||
transaction: Transaction
|
transaction: SimpleDatabaseTransaction
|
||||||
}) {
|
}) {
|
||||||
const deviceEntry = await database.device.findOne({
|
const deviceEntry = await transaction.legacy.database.device.findOne({
|
||||||
where: {
|
where: {
|
||||||
deviceAuthToken: deviceAuthToken
|
deviceAuthToken: deviceAuthToken
|
||||||
},
|
},
|
||||||
transaction
|
transaction: transaction.legacy.transaction
|
||||||
})
|
})
|
||||||
|
|
||||||
if (!deviceEntry) {
|
if (!deviceEntry) {
|
||||||
@@ -171,13 +171,13 @@ export const createParentRouter = ({
|
|||||||
throw new Unauthorized()
|
throw new Unauthorized()
|
||||||
}
|
}
|
||||||
|
|
||||||
const parentEntry = await database.user.findOne({
|
const parentEntry = await transaction.legacy.database.user.findOne({
|
||||||
where: {
|
where: {
|
||||||
familyId: deviceEntry.familyId,
|
familyId: deviceEntry.familyId,
|
||||||
type: 'parent',
|
type: 'parent',
|
||||||
userId: deviceEntry.currentUserId
|
userId: deviceEntry.currentUserId
|
||||||
},
|
},
|
||||||
transaction
|
transaction: transaction.legacy.transaction
|
||||||
})
|
})
|
||||||
|
|
||||||
if (!parentEntry) {
|
if (!parentEntry) {
|
||||||
@@ -187,11 +187,11 @@ export const createParentRouter = ({
|
|||||||
return { deviceEntry, parentEntry }
|
return { deviceEntry, parentEntry }
|
||||||
} else if (secondPasswordHash.startsWith('u2f:')) {
|
} else if (secondPasswordHash.startsWith('u2f:')) {
|
||||||
try {
|
try {
|
||||||
const familyEntryUnsafe = await database.family.findOne({
|
const familyEntryUnsafe = await transaction.legacy.database.family.findOne({
|
||||||
where: {
|
where: {
|
||||||
familyId: deviceEntry.familyId
|
familyId: deviceEntry.familyId
|
||||||
},
|
},
|
||||||
transaction,
|
transaction: transaction.legacy.transaction,
|
||||||
attributes: ['hasFullVersion']
|
attributes: ['hasFullVersion']
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -208,7 +208,6 @@ export const createParentRouter = ({
|
|||||||
hasFullVersion,
|
hasFullVersion,
|
||||||
familyId: deviceEntry.familyId,
|
familyId: deviceEntry.familyId,
|
||||||
deviceId: deviceEntry.deviceId,
|
deviceId: deviceEntry.deviceId,
|
||||||
database,
|
|
||||||
transaction,
|
transaction,
|
||||||
calculateHmac: (secret) => createHmac('sha256', secret)
|
calculateHmac: (secret) => createHmac('sha256', secret)
|
||||||
.update('direct action')
|
.update('direct action')
|
||||||
@@ -217,13 +216,13 @@ export const createParentRouter = ({
|
|||||||
|
|
||||||
if (u2fResult.userId !== parentId) throw new Unauthorized()
|
if (u2fResult.userId !== parentId) throw new Unauthorized()
|
||||||
|
|
||||||
const parentEntry = await database.user.findOne({
|
const parentEntry = await transaction.legacy.database.user.findOne({
|
||||||
where: {
|
where: {
|
||||||
familyId: deviceEntry.familyId,
|
familyId: deviceEntry.familyId,
|
||||||
type: 'parent',
|
type: 'parent',
|
||||||
userId: u2fResult.userId
|
userId: u2fResult.userId
|
||||||
},
|
},
|
||||||
transaction
|
transaction: transaction.legacy.transaction
|
||||||
})
|
})
|
||||||
|
|
||||||
if (!parentEntry) {
|
if (!parentEntry) {
|
||||||
@@ -236,14 +235,14 @@ export const createParentRouter = ({
|
|||||||
else throw ex
|
else throw ex
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
const parentEntry = await database.user.findOne({
|
const parentEntry = await transaction.legacy.database.user.findOne({
|
||||||
where: {
|
where: {
|
||||||
familyId: deviceEntry.familyId,
|
familyId: deviceEntry.familyId,
|
||||||
type: 'parent',
|
type: 'parent',
|
||||||
userId: parentId,
|
userId: parentId,
|
||||||
secondPasswordHash: secondPasswordHash
|
secondPasswordHash: secondPasswordHash
|
||||||
},
|
},
|
||||||
transaction
|
transaction: transaction.legacy.transaction
|
||||||
})
|
})
|
||||||
|
|
||||||
if (!parentEntry) {
|
if (!parentEntry) {
|
||||||
@@ -268,7 +267,7 @@ export const createParentRouter = ({
|
|||||||
transaction
|
transaction
|
||||||
})
|
})
|
||||||
|
|
||||||
return createAddDeviceToken({ familyId: deviceEntry.familyId, database, transaction })
|
return createAddDeviceToken({ familyId: deviceEntry.familyId, transaction })
|
||||||
})
|
})
|
||||||
|
|
||||||
res.json({ token, deviceId })
|
res.json({ token, deviceId })
|
||||||
@@ -313,11 +312,10 @@ export const createParentRouter = ({
|
|||||||
})
|
})
|
||||||
|
|
||||||
await removeDevice({
|
await removeDevice({
|
||||||
database,
|
transaction,
|
||||||
familyId: deviceEntry.familyId,
|
familyId: deviceEntry.familyId,
|
||||||
deviceId: req.body.deviceId,
|
deviceId: req.body.deviceId,
|
||||||
websocket,
|
websocket
|
||||||
transaction
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
+17
-16
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* server component for the TimeLimit App
|
* server component for the TimeLimit App
|
||||||
* Copyright (C) 2019 - 2022 Jonas Lochmann
|
* Copyright (C) 2019 - 2026 Jonas Lochmann
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU Affero General Public License as
|
* it under the terms of the GNU Affero General Public License as
|
||||||
@@ -18,7 +18,7 @@
|
|||||||
import { json } from 'body-parser'
|
import { json } from 'body-parser'
|
||||||
import { Router } from 'express'
|
import { Router } from 'express'
|
||||||
import { BadRequest, Conflict, Unauthorized } from 'http-errors'
|
import { BadRequest, Conflict, Unauthorized } from 'http-errors'
|
||||||
import { Database } from '../database'
|
import { SimpleDatabase } from '../database/simple'
|
||||||
import {
|
import {
|
||||||
addPurchase,
|
addPurchase,
|
||||||
areGooglePlayPaymentsPossible,
|
areGooglePlayPaymentsPossible,
|
||||||
@@ -31,30 +31,32 @@ import { WebsocketApi } from '../websocket'
|
|||||||
import { isCanDoPurchaseRequest, isFinishPurchaseByGooglePlayRequest } from './validator'
|
import { isCanDoPurchaseRequest, isFinishPurchaseByGooglePlayRequest } from './validator'
|
||||||
|
|
||||||
export const createPurchaseRouter = ({ database, websocket }: {
|
export const createPurchaseRouter = ({ database, websocket }: {
|
||||||
database: Database
|
database: SimpleDatabase
|
||||||
websocket: WebsocketApi
|
websocket: WebsocketApi
|
||||||
}) => {
|
}) => {
|
||||||
const router = Router()
|
const router = Router()
|
||||||
|
|
||||||
router.post('/can-do-purchase', json(), async (req, res, next) => {
|
router.post('/can-do-purchase', json(), async (req, res, next) => {
|
||||||
if (!areGooglePlayPaymentsPossible) {
|
|
||||||
res.json({ canDoPurchase: 'no because not supported by the server' })
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (!isCanDoPurchaseRequest(req.body)) {
|
if (!isCanDoPurchaseRequest(req.body)) {
|
||||||
throw new BadRequest()
|
throw new BadRequest()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (req.body.type === 'googleplay' && !areGooglePlayPaymentsPossible) {
|
||||||
|
res.json({ canDoPurchase: 'no because not supported by the server' })
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
const result: boolean = await database.transaction(async (transaction) => {
|
const result: boolean = await database.transaction(async (transaction) => {
|
||||||
const familyEntry = await requireFamilyEntry({
|
const familyEntry = await requireFamilyEntry({
|
||||||
database,
|
transaction,
|
||||||
deviceAuthToken: req.body.deviceAuthToken,
|
deviceAuthToken: req.body.deviceAuthToken,
|
||||||
transaction
|
|
||||||
})
|
})
|
||||||
|
|
||||||
return canDoNextPurchase({ fullVersionUntil: parseInt(familyEntry.fullVersionUntil, 10) })
|
return canDoNextPurchase({
|
||||||
|
fullVersionUntil: parseInt(familyEntry.fullVersionUntil, 10),
|
||||||
|
fullVersionDebts: parseInt(familyEntry.fullVersionDebts, 10),
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
res.json({
|
res.json({
|
||||||
@@ -73,12 +75,12 @@ export const createPurchaseRouter = ({ database, websocket }: {
|
|||||||
}
|
}
|
||||||
|
|
||||||
await database.transaction(async (transaction) => {
|
await database.transaction(async (transaction) => {
|
||||||
const deviceEntryUnsafe = await database.device.findOne({
|
const deviceEntryUnsafe = await transaction.legacy.database.device.findOne({
|
||||||
where: {
|
where: {
|
||||||
deviceAuthToken: req.body.deviceAuthToken
|
deviceAuthToken: req.body.deviceAuthToken
|
||||||
},
|
},
|
||||||
attributes: ['familyId'],
|
attributes: ['familyId'],
|
||||||
transaction
|
transaction: transaction.legacy.transaction
|
||||||
})
|
})
|
||||||
|
|
||||||
if (!deviceEntryUnsafe) {
|
if (!deviceEntryUnsafe) {
|
||||||
@@ -119,13 +121,12 @@ export const createPurchaseRouter = ({ database, websocket }: {
|
|||||||
}
|
}
|
||||||
|
|
||||||
await addPurchase({
|
await addPurchase({
|
||||||
database,
|
transaction,
|
||||||
familyId: deviceEntry.familyId,
|
familyId: deviceEntry.familyId,
|
||||||
type,
|
type,
|
||||||
service: 'googleplay',
|
service: 'googleplay',
|
||||||
transactionId: orderId,
|
transactionId: orderId,
|
||||||
websocket,
|
websocket
|
||||||
transaction
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -113,7 +113,7 @@ export interface CreateRegisterDeviceTokenRequest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface CanDoPurchaseRequest {
|
export interface CanDoPurchaseRequest {
|
||||||
type: 'googleplay' | 'any'
|
type?: 'googleplay' | 'any'
|
||||||
deviceAuthToken: string
|
deviceAuthToken: string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+10
-11
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* server component for the TimeLimit App
|
* server component for the TimeLimit App
|
||||||
* Copyright (C) 2019 - 2022 Jonas Lochmann
|
* Copyright (C) 2019 - 2026 Jonas Lochmann
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU Affero General Public License as
|
* it under the terms of the GNU Affero General Public License as
|
||||||
@@ -19,7 +19,7 @@ import { json } from 'body-parser'
|
|||||||
import { Router } from 'express'
|
import { Router } from 'express'
|
||||||
import { BadRequest, Unauthorized } from 'http-errors'
|
import { BadRequest, Unauthorized } from 'http-errors'
|
||||||
import { VisibleConnectedDevicesManager } from '../connected-devices'
|
import { VisibleConnectedDevicesManager } from '../connected-devices'
|
||||||
import { Database } from '../database'
|
import { SimpleDatabase } from '../database/simple'
|
||||||
import { reportDeviceRemoved } from '../function/device/report-device-removed'
|
import { reportDeviceRemoved } from '../function/device/report-device-removed'
|
||||||
import { applyActionsFromDevice } from '../function/sync/apply-actions'
|
import { applyActionsFromDevice } from '../function/sync/apply-actions'
|
||||||
import { generateServerDataStatus } from '../function/sync/get-server-data-status'
|
import { generateServerDataStatus } from '../function/sync/get-server-data-status'
|
||||||
@@ -34,7 +34,7 @@ const getRoundedTimestampForLastConnectivity = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const createSyncRouter = ({ database, websocket, connectedDevicesManager, eventHandler }: {
|
export const createSyncRouter = ({ database, websocket, connectedDevicesManager, eventHandler }: {
|
||||||
database: Database
|
database: SimpleDatabase
|
||||||
websocket: WebsocketApi
|
websocket: WebsocketApi
|
||||||
connectedDevicesManager: VisibleConnectedDevicesManager
|
connectedDevicesManager: VisibleConnectedDevicesManager
|
||||||
eventHandler: EventHandler
|
eventHandler: EventHandler
|
||||||
@@ -86,12 +86,12 @@ export const createSyncRouter = ({ database, websocket, connectedDevicesManager,
|
|||||||
}
|
}
|
||||||
|
|
||||||
const serverStatus = await database.transaction(async (transaction) => {
|
const serverStatus = await database.transaction(async (transaction) => {
|
||||||
const deviceEntryUnsafe = await database.device.findOne({
|
const deviceEntryUnsafe = await transaction.legacy.database.device.findOne({
|
||||||
where: {
|
where: {
|
||||||
deviceAuthToken: body.deviceAuthToken
|
deviceAuthToken: body.deviceAuthToken
|
||||||
},
|
},
|
||||||
attributes: ['familyId', 'deviceId', 'lastConnectivity'],
|
attributes: ['familyId', 'deviceId', 'lastConnectivity'],
|
||||||
transaction
|
transaction: transaction.legacy.transaction
|
||||||
})
|
})
|
||||||
|
|
||||||
if (!deviceEntryUnsafe) {
|
if (!deviceEntryUnsafe) {
|
||||||
@@ -102,22 +102,21 @@ export const createSyncRouter = ({ database, websocket, connectedDevicesManager,
|
|||||||
const now = getRoundedTimestampForLastConnectivity()
|
const now = getRoundedTimestampForLastConnectivity()
|
||||||
|
|
||||||
if (parseInt(lastConnectivity, 10) !== now) {
|
if (parseInt(lastConnectivity, 10) !== now) {
|
||||||
await database.device.update({
|
await transaction.legacy.database.device.update({
|
||||||
lastConnectivity: now.toString(10)
|
lastConnectivity: now.toString(10)
|
||||||
}, {
|
}, {
|
||||||
where: {
|
where: {
|
||||||
deviceAuthToken: body.deviceAuthToken
|
deviceAuthToken: body.deviceAuthToken
|
||||||
},
|
},
|
||||||
transaction
|
transaction: transaction.legacy.transaction
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
return generateServerDataStatus({
|
return generateServerDataStatus({
|
||||||
database,
|
transaction,
|
||||||
familyId,
|
familyId,
|
||||||
deviceId,
|
deviceId,
|
||||||
clientStatus: body.status,
|
clientStatus: body.status,
|
||||||
transaction,
|
|
||||||
eventHandler
|
eventHandler
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
@@ -165,11 +164,11 @@ export const createSyncRouter = ({ database, websocket, connectedDevicesManager,
|
|||||||
}
|
}
|
||||||
|
|
||||||
const isDeviceRemoved: boolean = await database.transaction(async (transaction) => {
|
const isDeviceRemoved: boolean = await database.transaction(async (transaction) => {
|
||||||
const removedEntry = await database.oldDevice.findOne({
|
const removedEntry = await transaction.legacy.database.oldDevice.findOne({
|
||||||
where: {
|
where: {
|
||||||
deviceAuthToken: req.body.deviceAuthToken
|
deviceAuthToken: req.body.deviceAuthToken
|
||||||
},
|
},
|
||||||
transaction
|
transaction: transaction.legacy.transaction
|
||||||
})
|
})
|
||||||
|
|
||||||
return !!removedEntry
|
return !!removedEntry
|
||||||
|
|||||||
@@ -3353,8 +3353,7 @@ export const isCanDoPurchaseRequest: (value: unknown) => value is CanDoPurchaseR
|
|||||||
},
|
},
|
||||||
"additionalProperties": false,
|
"additionalProperties": false,
|
||||||
"required": [
|
"required": [
|
||||||
"deviceAuthToken",
|
"deviceAuthToken"
|
||||||
"type"
|
|
||||||
],
|
],
|
||||||
"definitions": definitions,
|
"definitions": definitions,
|
||||||
"$schema": "http://json-schema.org/draft-07/schema#"
|
"$schema": "http://json-schema.org/draft-07/schema#"
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* server component for the TimeLimit App
|
* server component for the TimeLimit App
|
||||||
* Copyright (C) 2019 Jonas Lochmann
|
* Copyright (C) 2019 - 2026 Jonas Lochmann
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU Affero General Public License as
|
* it under the terms of the GNU Affero General Public License as
|
||||||
@@ -16,9 +16,10 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { defaultDatabase } from '../database'
|
import { defaultDatabase } from '../database'
|
||||||
|
import { fromLegacy as createSimpleDatabase } from '../database/simple'
|
||||||
import { deleteOldFamilies } from '../function/cleanup/delete-old-families'
|
import { deleteOldFamilies } from '../function/cleanup/delete-old-families'
|
||||||
|
|
||||||
const database = defaultDatabase
|
const database = createSimpleDatabase(defaultDatabase)
|
||||||
|
|
||||||
deleteOldFamilies(database)
|
deleteOldFamilies(database)
|
||||||
.then(() => console.log('done'))
|
.then(() => console.log('done'))
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* server component for the TimeLimit App
|
* server component for the TimeLimit App
|
||||||
* Copyright (C) 2019 Jonas Lochmann
|
* Copyright (C) 2019 - 2026 Jonas Lochmann
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU Affero General Public License as
|
* it under the terms of the GNU Affero General Public License as
|
||||||
@@ -16,9 +16,10 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { defaultDatabase } from '../database'
|
import { defaultDatabase } from '../database'
|
||||||
|
import { fromLegacy as createSimpleDatabase } from '../database/simple'
|
||||||
import { findOldFamilyIds } from '../function/cleanup/delete-old-families'
|
import { findOldFamilyIds } from '../function/cleanup/delete-old-families'
|
||||||
|
|
||||||
const database = defaultDatabase
|
const database = createSimpleDatabase(defaultDatabase)
|
||||||
|
|
||||||
findOldFamilyIds(database)
|
findOldFamilyIds(database)
|
||||||
.then((res) => console.log(JSON.stringify(res)))
|
.then((res) => console.log(JSON.stringify(res)))
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* server component for the TimeLimit App
|
* server component for the TimeLimit App
|
||||||
* Copyright (C) 2019 - 2022 Jonas Lochmann
|
* Copyright (C) 2019 - 2026 Jonas Lochmann
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU Affero General Public License as
|
* it under the terms of the GNU Affero General Public License as
|
||||||
@@ -16,7 +16,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { EventEmitter } from 'events'
|
import { EventEmitter } from 'events'
|
||||||
import { Database } from '../database'
|
import { SimpleDatabase } from '../database/simple'
|
||||||
|
|
||||||
export class ConnectedDevicesManager {
|
export class ConnectedDevicesManager {
|
||||||
private deviceConnectionCounters = new Map<string, number>()
|
private deviceConnectionCounters = new Map<string, number>()
|
||||||
@@ -59,10 +59,10 @@ export class ConnectedDevicesManager {
|
|||||||
|
|
||||||
export class VisibleConnectedDevicesManager {
|
export class VisibleConnectedDevicesManager {
|
||||||
connectedDevicesManager = new ConnectedDevicesManager()
|
connectedDevicesManager = new ConnectedDevicesManager()
|
||||||
private database: Database
|
private database: SimpleDatabase
|
||||||
|
|
||||||
constructor ({ database }: {
|
constructor ({ database }: {
|
||||||
database: Database
|
database: SimpleDatabase
|
||||||
}) {
|
}) {
|
||||||
this.database = database
|
this.database = database
|
||||||
}
|
}
|
||||||
@@ -174,19 +174,24 @@ export class VisibleConnectedDevicesManager {
|
|||||||
|
|
||||||
// add all current devices
|
// add all current devices
|
||||||
;(async () => {
|
;(async () => {
|
||||||
const devicesUnsafe = await this.database.device.findAll({
|
const devices = await this.database.transaction(async (transaction) => {
|
||||||
where: {
|
const devicesUnsafe = await transaction.legacy.database.device.findAll({
|
||||||
familyId
|
where: {
|
||||||
},
|
familyId
|
||||||
attributes: [
|
},
|
||||||
'deviceId',
|
attributes: [
|
||||||
'showDeviceConnected'
|
'deviceId',
|
||||||
]
|
'showDeviceConnected'
|
||||||
})
|
],
|
||||||
|
transaction: transaction.legacy.transaction
|
||||||
|
})
|
||||||
|
|
||||||
const devices = devicesUnsafe.map(({ deviceId, showDeviceConnected }) => ({
|
const devices = devicesUnsafe.map(({ deviceId, showDeviceConnected }) => ({
|
||||||
deviceId, showDeviceConnected
|
deviceId, showDeviceConnected
|
||||||
}))
|
}))
|
||||||
|
|
||||||
|
return devices
|
||||||
|
})
|
||||||
|
|
||||||
devices.forEach(({ deviceId, showDeviceConnected }) => {
|
devices.forEach(({ deviceId, showDeviceConnected }) => {
|
||||||
addDevice({ deviceId, showDeviceConnected })
|
addDevice({ deviceId, showDeviceConnected })
|
||||||
|
|||||||
+20
-3
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* server component for the TimeLimit App
|
* server component for the TimeLimit App
|
||||||
* Copyright (C) 2019 - 2022 Jonas Lochmann
|
* Copyright (C) 2019 - 2026 Jonas Lochmann
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU Affero General Public License as
|
* it under the terms of the GNU Affero General Public License as
|
||||||
@@ -37,8 +37,13 @@ export interface FamilyAttributesVersion3 {
|
|||||||
u2fKeysVersion: string
|
u2fKeysVersion: string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface FamilyAttributesVersion4 {
|
||||||
|
fullVersionDebts: string
|
||||||
|
}
|
||||||
|
|
||||||
export type FamilyAttributes = FamilyAttributesVersion1 &
|
export type FamilyAttributes = FamilyAttributesVersion1 &
|
||||||
FamilyAttributesVersion2 & FamilyAttributesVersion3
|
FamilyAttributesVersion2 & FamilyAttributesVersion3 &
|
||||||
|
FamilyAttributesVersion4
|
||||||
|
|
||||||
export type FamilyModel = Sequelize.Model<FamilyAttributes> & FamilyAttributes
|
export type FamilyModel = Sequelize.Model<FamilyAttributes> & FamilyAttributes
|
||||||
export type FamilyModelStatic = typeof Sequelize.Model & {
|
export type FamilyModelStatic = typeof Sequelize.Model & {
|
||||||
@@ -76,10 +81,22 @@ export const attributesVersion3: SequelizeAttributes<FamilyAttributesVersion3> =
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const attributesVersion4: SequelizeAttributes<FamilyAttributesVersion4> = {
|
||||||
|
fullVersionDebts: {
|
||||||
|
type: Sequelize.BIGINT,
|
||||||
|
allowNull: false,
|
||||||
|
defaultValue: 0,
|
||||||
|
validate: {
|
||||||
|
min: 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export const attributes: SequelizeAttributes<FamilyAttributes> = {
|
export const attributes: SequelizeAttributes<FamilyAttributes> = {
|
||||||
...attributesVersion1,
|
...attributesVersion1,
|
||||||
...attributesVersion2,
|
...attributesVersion2,
|
||||||
...attributesVersion3
|
...attributesVersion3,
|
||||||
|
...attributesVersion4
|
||||||
}
|
}
|
||||||
|
|
||||||
export const createFamilyModel = (sequelize: Sequelize.Sequelize): FamilyModelStatic => sequelize.define('Family', attributes) as FamilyModelStatic
|
export const createFamilyModel = (sequelize: Sequelize.Sequelize): FamilyModelStatic => sequelize.define('Family', attributes) as FamilyModelStatic
|
||||||
|
|||||||
@@ -0,0 +1,39 @@
|
|||||||
|
/*
|
||||||
|
* server component for the TimeLimit App
|
||||||
|
* Copyright (C) 2019 - 2026 Jonas Lochmann
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License as
|
||||||
|
* published by the Free Software Foundation, version 3 of the License.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { QueryInterface, Sequelize, Transaction } from 'sequelize'
|
||||||
|
import { attributesVersion4 as familyAttributes } from '../../family'
|
||||||
|
|
||||||
|
export async function up (queryInterface: QueryInterface, sequelize: Sequelize) {
|
||||||
|
await sequelize.transaction({
|
||||||
|
type: Transaction.TYPES.EXCLUSIVE
|
||||||
|
}, async (transaction) => {
|
||||||
|
await queryInterface.addColumn('Families', 'fullVersionDebts', {
|
||||||
|
...familyAttributes.fullVersionDebts
|
||||||
|
}, {
|
||||||
|
transaction
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function down (queryInterface: QueryInterface, sequelize: Sequelize) {
|
||||||
|
await sequelize.transaction({
|
||||||
|
type: Transaction.TYPES.EXCLUSIVE
|
||||||
|
}, async (transaction) => {
|
||||||
|
await queryInterface.removeColumn('Families', 'fullVersionDebts', { transaction })
|
||||||
|
})
|
||||||
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* server component for the TimeLimit App
|
* server component for the TimeLimit App
|
||||||
* Copyright (C) 2019 - 2022 Jonas Lochmann
|
* Copyright (C) 2019 - 2026 Jonas Lochmann
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU Affero General Public License as
|
* it under the terms of the GNU Affero General Public License as
|
||||||
@@ -23,7 +23,7 @@ export interface PurchaseAttributes {
|
|||||||
familyId: string
|
familyId: string
|
||||||
service: 'googleplay' | 'directpurchase'
|
service: 'googleplay' | 'directpurchase'
|
||||||
transactionId: string
|
transactionId: string
|
||||||
type: 'month' | 'year'
|
type: 'month' | 'year' | 'unpaid14'
|
||||||
loggedAt: string
|
loggedAt: string
|
||||||
previousFullVersionEndTime: string
|
previousFullVersionEndTime: string
|
||||||
newFullVersionEndTime: string
|
newFullVersionEndTime: string
|
||||||
@@ -44,7 +44,7 @@ export const attributes: SequelizeAttributes<PurchaseAttributes> = {
|
|||||||
type: Sequelize.STRING,
|
type: Sequelize.STRING,
|
||||||
primaryKey: true
|
primaryKey: true
|
||||||
},
|
},
|
||||||
type: createEnumColumn(['month', 'year']),
|
type: createEnumColumn(['month', 'year', 'unpaid14']),
|
||||||
loggedAt: { ...timestampColumn },
|
loggedAt: { ...timestampColumn },
|
||||||
previousFullVersionEndTime: { ...timestampColumn },
|
previousFullVersionEndTime: { ...timestampColumn },
|
||||||
newFullVersionEndTime: { ...timestampColumn }
|
newFullVersionEndTime: { ...timestampColumn }
|
||||||
|
|||||||
@@ -0,0 +1,59 @@
|
|||||||
|
/*
|
||||||
|
* server component for the TimeLimit App
|
||||||
|
* Copyright (C) 2019 - 2026 Jonas Lochmann
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License as
|
||||||
|
* published by the Free Software Foundation, version 3 of the License.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { Database as LegacyDatabase, Transaction as LegacyTransaction } from '../main'
|
||||||
|
|
||||||
|
export interface SimpleDatabase {
|
||||||
|
legacy: LegacyDatabase
|
||||||
|
transaction: <T> (
|
||||||
|
inner: (t: SimpleDatabaseTransaction) => Promise<T>
|
||||||
|
) => Promise<T>
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface SimpleDatabaseTransaction {
|
||||||
|
transaction: <T> (
|
||||||
|
inner: (t: SimpleDatabaseTransaction) => Promise<T>
|
||||||
|
) => Promise<T>
|
||||||
|
|
||||||
|
enqueueAfterCommit(callback: () => void): void
|
||||||
|
|
||||||
|
legacy: {
|
||||||
|
database: LegacyDatabase
|
||||||
|
transaction: LegacyTransaction
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export function fromLegacy(database: LegacyDatabase): SimpleDatabase {
|
||||||
|
return {
|
||||||
|
legacy: database,
|
||||||
|
transaction: (inner) => database.transaction((legacyTransaction) => inner(fromLegacyTransaction(database, legacyTransaction)))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function fromLegacyTransaction(database: LegacyDatabase, legacyTransaction: LegacyTransaction): SimpleDatabaseTransaction {
|
||||||
|
return {
|
||||||
|
transaction: (inner) => database.transaction(
|
||||||
|
(innerTransaction) => inner(fromLegacyTransaction(database, innerTransaction)),
|
||||||
|
{ transaction: legacyTransaction }
|
||||||
|
),
|
||||||
|
enqueueAfterCommit: (afterCommitAction) => legacyTransaction.afterCommit(afterCommitAction),
|
||||||
|
legacy: {
|
||||||
|
database,
|
||||||
|
transaction: legacyTransaction
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* server component for the TimeLimit App
|
* server component for the TimeLimit App
|
||||||
* Copyright (C) 2019 - 2021 Jonas Lochmann
|
* Copyright (C) 2019 - 2026 Jonas Lochmann
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU Affero General Public License as
|
* it under the terms of the GNU Affero General Public License as
|
||||||
@@ -16,45 +16,45 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { Unauthorized } from 'http-errors'
|
import { Unauthorized } from 'http-errors'
|
||||||
import { Database, Transaction } from '../../database'
|
import { SimpleDatabaseTransaction } from '../../database/simple'
|
||||||
import { generateAuthToken } from '../../util/token'
|
import { generateAuthToken } from '../../util/token'
|
||||||
|
|
||||||
export const createAuthTokenByMailAddress = async ({
|
export const createAuthTokenByMailAddress = async ({
|
||||||
mail, database, transaction, locale
|
mail, transaction, locale
|
||||||
}: {
|
}: {
|
||||||
mail: string, database: Database, transaction: Transaction, locale: string
|
mail: string, transaction: SimpleDatabaseTransaction, locale: string
|
||||||
}) => {
|
}) => {
|
||||||
const token = generateAuthToken()
|
const token = generateAuthToken()
|
||||||
|
|
||||||
await database.authtoken.create({
|
await transaction.legacy.database.authtoken.create({
|
||||||
token,
|
token,
|
||||||
mail,
|
mail,
|
||||||
createdAt: Date.now().toString(),
|
createdAt: Date.now().toString(),
|
||||||
locale
|
locale
|
||||||
}, { transaction })
|
}, { transaction: transaction.legacy.transaction })
|
||||||
|
|
||||||
return token
|
return token
|
||||||
}
|
}
|
||||||
|
|
||||||
export const getMailAndLocaleByAuthToken = async ({
|
export const getMailAndLocaleByAuthToken = async ({
|
||||||
mailAuthToken, database, transaction, invalidate
|
mailAuthToken, transaction, invalidate
|
||||||
}: {
|
}: {
|
||||||
mailAuthToken: string, database: Database, transaction: Transaction, invalidate: boolean
|
mailAuthToken: string, transaction: SimpleDatabaseTransaction, invalidate: boolean
|
||||||
}) => {
|
}) => {
|
||||||
const entry = await database.authtoken.findOne({
|
const entry = await transaction.legacy.database.authtoken.findOne({
|
||||||
where: {
|
where: {
|
||||||
token: mailAuthToken
|
token: mailAuthToken
|
||||||
},
|
},
|
||||||
transaction
|
transaction: transaction.legacy.transaction
|
||||||
})
|
})
|
||||||
|
|
||||||
if (entry) {
|
if (entry) {
|
||||||
if (invalidate) {
|
if (invalidate) {
|
||||||
const rowCounter = await database.authtoken.destroy({
|
const rowCounter = await transaction.legacy.database.authtoken.destroy({
|
||||||
where: {
|
where: {
|
||||||
token: mailAuthToken
|
token: mailAuthToken
|
||||||
},
|
},
|
||||||
transaction
|
transaction: transaction.legacy.transaction
|
||||||
})
|
})
|
||||||
|
|
||||||
if (rowCounter !== 1) {
|
if (rowCounter !== 1) {
|
||||||
@@ -72,11 +72,11 @@ export const getMailAndLocaleByAuthToken = async ({
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const requireMailAndLocaleByAuthToken = async ({
|
export const requireMailAndLocaleByAuthToken = async ({
|
||||||
mailAuthToken, database, transaction, invalidate
|
mailAuthToken, transaction, invalidate
|
||||||
}: {
|
}: {
|
||||||
mailAuthToken: string, database: Database, transaction: Transaction, invalidate: boolean
|
mailAuthToken: string, transaction: SimpleDatabaseTransaction, invalidate: boolean
|
||||||
}) => {
|
}) => {
|
||||||
const result = await getMailAndLocaleByAuthToken({ mailAuthToken, database, transaction, invalidate })
|
const result = await getMailAndLocaleByAuthToken({ mailAuthToken, transaction, invalidate })
|
||||||
|
|
||||||
if (!result) {
|
if (!result) {
|
||||||
throw new Unauthorized()
|
throw new Unauthorized()
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* server component for the TimeLimit App
|
* server component for the TimeLimit App
|
||||||
* Copyright (C) 2019 - 2023 Jonas Lochmann
|
* Copyright (C) 2019 - 2026 Jonas Lochmann
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU Affero General Public License as
|
* it under the terms of the GNU Affero General Public License as
|
||||||
@@ -16,7 +16,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { Forbidden, Gone, TooManyRequests, Unauthorized } from 'http-errors'
|
import { Forbidden, Gone, TooManyRequests, Unauthorized } from 'http-errors'
|
||||||
import { Database } from '../../database'
|
import { SimpleDatabase } from '../../database/simple'
|
||||||
import { sendAuthenticationMail } from '../../util/mail'
|
import { sendAuthenticationMail } from '../../util/mail'
|
||||||
import { areWordSequencesEqual, randomWords } from '../../util/random-words'
|
import { areWordSequencesEqual, randomWords } from '../../util/random-words'
|
||||||
import { checkMailSendLimit } from '../../util/ratelimit-authmail'
|
import { checkMailSendLimit } from '../../util/ratelimit-authmail'
|
||||||
@@ -27,17 +27,17 @@ export const sendLoginCode = async ({ mail, deviceAuthToken, locale, database }:
|
|||||||
mail: string
|
mail: string
|
||||||
deviceAuthToken?: string
|
deviceAuthToken?: string
|
||||||
locale: string
|
locale: string
|
||||||
database: Database
|
database: SimpleDatabase
|
||||||
// no transaction here because this is directly called from an API endpoint
|
// no transaction here because this is directly called from an API endpoint
|
||||||
}): Promise<{ mailLoginToken: string }> => {
|
}): Promise<{ mailLoginToken: string }> => {
|
||||||
let deviceName = null
|
let deviceName = null
|
||||||
|
|
||||||
if (deviceAuthToken !== undefined) {
|
if (deviceAuthToken !== undefined) {
|
||||||
const info = await database.transaction(async (transaction) => {
|
const info = await database.transaction(async (transaction) => {
|
||||||
const deviceEntryUnsafe = await database.device.findOne({
|
const deviceEntryUnsafe = await transaction.legacy.database.device.findOne({
|
||||||
where: { deviceAuthToken },
|
where: { deviceAuthToken },
|
||||||
attributes: ['familyId', 'name'],
|
attributes: ['familyId', 'name'],
|
||||||
transaction
|
transaction: transaction.legacy.transaction
|
||||||
})
|
})
|
||||||
|
|
||||||
if (!deviceEntryUnsafe) {
|
if (!deviceEntryUnsafe) {
|
||||||
@@ -49,12 +49,12 @@ export const sendLoginCode = async ({ mail, deviceAuthToken, locale, database }:
|
|||||||
name: deviceEntryUnsafe.name
|
name: deviceEntryUnsafe.name
|
||||||
}
|
}
|
||||||
|
|
||||||
const userEntryCounter = await database.user.count({
|
const userEntryCounter = await transaction.legacy.database.user.count({
|
||||||
where: {
|
where: {
|
||||||
familyId: deviceEntry.familyId,
|
familyId: deviceEntry.familyId,
|
||||||
mail
|
mail
|
||||||
},
|
},
|
||||||
transaction
|
transaction: transaction.legacy.transaction
|
||||||
})
|
})
|
||||||
|
|
||||||
if (userEntryCounter === 1) {
|
if (userEntryCounter === 1) {
|
||||||
@@ -86,14 +86,14 @@ export const sendLoginCode = async ({ mail, deviceAuthToken, locale, database }:
|
|||||||
})
|
})
|
||||||
|
|
||||||
await database.transaction(async (transaction) => {
|
await database.transaction(async (transaction) => {
|
||||||
await database.mailLoginToken.create({
|
await transaction.legacy.database.mailLoginToken.create({
|
||||||
mailLoginToken,
|
mailLoginToken,
|
||||||
receivedCode: code,
|
receivedCode: code,
|
||||||
mail,
|
mail,
|
||||||
createdAt: Date.now().toString(10),
|
createdAt: Date.now().toString(10),
|
||||||
remainingAttempts: 3,
|
remainingAttempts: 3,
|
||||||
locale
|
locale
|
||||||
}, { transaction })
|
}, { transaction: transaction.legacy.transaction })
|
||||||
})
|
})
|
||||||
|
|
||||||
return {
|
return {
|
||||||
@@ -106,15 +106,15 @@ export const sendLoginCode = async ({ mail, deviceAuthToken, locale, database }:
|
|||||||
export const signInByMailCode = async ({ mailLoginToken, receivedCode, database }: {
|
export const signInByMailCode = async ({ mailLoginToken, receivedCode, database }: {
|
||||||
mailLoginToken: string
|
mailLoginToken: string
|
||||||
receivedCode: string
|
receivedCode: string
|
||||||
database: Database
|
database: SimpleDatabase
|
||||||
// no transaction here because this is directly called from an API endpoint
|
// no transaction here because this is directly called from an API endpoint
|
||||||
}): Promise<{ mailAuthToken: string }> => {
|
}): Promise<{ mailAuthToken: string }> => {
|
||||||
const result = await database.transaction(async (transaction) => {
|
const result = await database.transaction(async (transaction) => {
|
||||||
const entry = await database.mailLoginToken.findOne({
|
const entry = await transaction.legacy.database.mailLoginToken.findOne({
|
||||||
where: {
|
where: {
|
||||||
mailLoginToken
|
mailLoginToken
|
||||||
},
|
},
|
||||||
transaction
|
transaction: transaction.legacy.transaction
|
||||||
})
|
})
|
||||||
|
|
||||||
if ((!entry) || entry.remainingAttempts === 0) {
|
if ((!entry) || entry.remainingAttempts === 0) {
|
||||||
@@ -124,7 +124,7 @@ export const signInByMailCode = async ({ mailLoginToken, receivedCode, database
|
|||||||
if (!areWordSequencesEqual(entry.receivedCode, receivedCode)) {
|
if (!areWordSequencesEqual(entry.receivedCode, receivedCode)) {
|
||||||
entry.remainingAttempts--
|
entry.remainingAttempts--
|
||||||
|
|
||||||
await entry.save({ transaction })
|
await entry.save({ transaction: transaction.legacy.transaction })
|
||||||
|
|
||||||
if (entry.remainingAttempts === 0) {
|
if (entry.remainingAttempts === 0) {
|
||||||
return () => { throw new Gone() }
|
return () => { throw new Gone() }
|
||||||
@@ -133,11 +133,11 @@ export const signInByMailCode = async ({ mailLoginToken, receivedCode, database
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const counter = await database.mailLoginToken.destroy({
|
const counter = await transaction.legacy.database.mailLoginToken.destroy({
|
||||||
where: {
|
where: {
|
||||||
mailLoginToken
|
mailLoginToken
|
||||||
},
|
},
|
||||||
transaction
|
transaction: transaction.legacy.transaction
|
||||||
})
|
})
|
||||||
|
|
||||||
if (counter !== 1) {
|
if (counter !== 1) {
|
||||||
@@ -147,7 +147,6 @@ export const signInByMailCode = async ({ mailLoginToken, receivedCode, database
|
|||||||
const mailAuthToken = await createAuthTokenByMailAddress({
|
const mailAuthToken = await createAuthTokenByMailAddress({
|
||||||
mail: entry.mail,
|
mail: entry.mail,
|
||||||
locale: entry.locale,
|
locale: entry.locale,
|
||||||
database,
|
|
||||||
transaction
|
transaction
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* server component for the TimeLimit App
|
* server component for the TimeLimit App
|
||||||
* Copyright (C) 2019 - 2022 Jonas Lochmann
|
* Copyright (C) 2019 - 2026 Jonas Lochmann
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU Affero General Public License as
|
* it under the terms of the GNU Affero General Public License as
|
||||||
@@ -17,7 +17,7 @@
|
|||||||
|
|
||||||
import { Unauthorized } from 'http-errors'
|
import { Unauthorized } from 'http-errors'
|
||||||
import { RegisterChildDeviceRequest } from '../../api/schema'
|
import { RegisterChildDeviceRequest } from '../../api/schema'
|
||||||
import { Database } from '../../database'
|
import { SimpleDatabase } from '../../database/simple'
|
||||||
import { generateAuthToken, generateVersionId } from '../../util/token'
|
import { generateAuthToken, generateVersionId } from '../../util/token'
|
||||||
import { WebsocketApi } from '../../websocket'
|
import { WebsocketApi } from '../../websocket'
|
||||||
import { prepareDeviceEntry } from '../device/prepare-device-entry'
|
import { prepareDeviceEntry } from '../device/prepare-device-entry'
|
||||||
@@ -28,7 +28,7 @@ import { ServerDataStatus } from '../../object/serverdatastatus'
|
|||||||
import { createEmptyClientDataStatus } from '../../object/clientdatastatus'
|
import { createEmptyClientDataStatus } from '../../object/clientdatastatus'
|
||||||
|
|
||||||
export const addChildDevice = async ({ database, eventHandler, websocket, request }: {
|
export const addChildDevice = async ({ database, eventHandler, websocket, request }: {
|
||||||
database: Database
|
database: SimpleDatabase
|
||||||
eventHandler: EventHandler
|
eventHandler: EventHandler
|
||||||
websocket: WebsocketApi
|
websocket: WebsocketApi
|
||||||
request: RegisterChildDeviceRequest
|
request: RegisterChildDeviceRequest
|
||||||
@@ -39,23 +39,23 @@ export const addChildDevice = async ({ database, eventHandler, websocket, reques
|
|||||||
data: ServerDataStatus
|
data: ServerDataStatus
|
||||||
}> => {
|
}> => {
|
||||||
return database.transaction(async (transaction) => {
|
return database.transaction(async (transaction) => {
|
||||||
const entry = await database.addDeviceToken.findOne({
|
const entry = await transaction.legacy.database.addDeviceToken.findOne({
|
||||||
where: {
|
where: {
|
||||||
token: request.registerToken.toLowerCase()
|
token: request.registerToken.toLowerCase()
|
||||||
},
|
},
|
||||||
transaction
|
transaction: transaction.legacy.transaction
|
||||||
})
|
})
|
||||||
|
|
||||||
if (!entry) {
|
if (!entry) {
|
||||||
throw new Unauthorized()
|
throw new Unauthorized()
|
||||||
}
|
}
|
||||||
|
|
||||||
await entry.destroy({ transaction })
|
await entry.destroy({ transaction: transaction.legacy.transaction })
|
||||||
|
|
||||||
const { deviceId, familyId } = entry
|
const { deviceId, familyId } = entry
|
||||||
const deviceAuthToken = generateAuthToken()
|
const deviceAuthToken = generateAuthToken()
|
||||||
|
|
||||||
await database.device.create(prepareDeviceEntry({
|
await transaction.legacy.database.device.create(prepareDeviceEntry({
|
||||||
familyId,
|
familyId,
|
||||||
deviceId,
|
deviceId,
|
||||||
deviceAuthToken,
|
deviceAuthToken,
|
||||||
@@ -63,33 +63,31 @@ export const addChildDevice = async ({ database, eventHandler, websocket, reques
|
|||||||
newDeviceInfo: request.childDevice,
|
newDeviceInfo: request.childDevice,
|
||||||
userId: '',
|
userId: '',
|
||||||
isUserKeptSignedIn: false
|
isUserKeptSignedIn: false
|
||||||
}), { transaction })
|
}), { transaction: transaction.legacy.transaction })
|
||||||
|
|
||||||
await database.family.update({
|
await transaction.legacy.database.family.update({
|
||||||
deviceListVersion: generateVersionId()
|
deviceListVersion: generateVersionId()
|
||||||
}, {
|
}, {
|
||||||
where: {
|
where: {
|
||||||
familyId
|
familyId
|
||||||
},
|
},
|
||||||
transaction
|
transaction: transaction.legacy.transaction
|
||||||
})
|
})
|
||||||
|
|
||||||
await notifyClientsAboutChangesDelayed({
|
await notifyClientsAboutChangesDelayed({
|
||||||
familyId,
|
familyId,
|
||||||
websocket,
|
websocket,
|
||||||
database,
|
transaction,
|
||||||
generalLevel: 1,
|
generalLevel: 1,
|
||||||
targetedLevels: new Map(),
|
targetedLevels: new Map(),
|
||||||
sourceDeviceId: deviceId,
|
sourceDeviceId: deviceId
|
||||||
transaction
|
|
||||||
})
|
})
|
||||||
|
|
||||||
const data = await generateServerDataStatus({
|
const data = await generateServerDataStatus({
|
||||||
database,
|
transaction,
|
||||||
clientStatus: createEmptyClientDataStatus({ clientLevel: request.clientLevel || null }),
|
clientStatus: createEmptyClientDataStatus({ clientLevel: request.clientLevel || null }),
|
||||||
familyId: entry.familyId,
|
familyId: entry.familyId,
|
||||||
deviceId,
|
deviceId,
|
||||||
transaction,
|
|
||||||
eventHandler
|
eventHandler
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* server component for the TimeLimit App
|
* server component for the TimeLimit App
|
||||||
* Copyright (C) 2019 - 2020 Jonas Lochmann
|
* Copyright (C) 2019 - 2026 Jonas Lochmann
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU Affero General Public License as
|
* it under the terms of the GNU Affero General Public License as
|
||||||
@@ -16,21 +16,21 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { Conflict, Unauthorized } from 'http-errors'
|
import { Conflict, Unauthorized } from 'http-errors'
|
||||||
import { Database } from '../../database'
|
import { SimpleDatabase } from '../../database/simple'
|
||||||
import { WebsocketApi } from '../../websocket'
|
import { WebsocketApi } from '../../websocket'
|
||||||
|
|
||||||
export const logoutAtPrimaryDevice = async ({ deviceAuthToken, database, websocket }: {
|
export const logoutAtPrimaryDevice = async ({ deviceAuthToken, database, websocket }: {
|
||||||
deviceAuthToken: string
|
deviceAuthToken: string
|
||||||
database: Database
|
database: SimpleDatabase
|
||||||
websocket: WebsocketApi
|
websocket: WebsocketApi
|
||||||
// no transaction here because this is directly called from an API endpoint
|
// no transaction here because this is directly called from an API endpoint
|
||||||
}) => {
|
}) => {
|
||||||
await database.transaction(async (transaction) => {
|
await database.transaction(async (transaction) => {
|
||||||
const ownDeviceEntryUnsafe = await database.device.findOne({
|
const ownDeviceEntryUnsafe = await transaction.legacy.database.device.findOne({
|
||||||
where: {
|
where: {
|
||||||
deviceAuthToken
|
deviceAuthToken
|
||||||
},
|
},
|
||||||
transaction,
|
transaction: transaction.legacy.transaction,
|
||||||
attributes: ['familyId', 'currentUserId', 'deviceId']
|
attributes: ['familyId', 'currentUserId', 'deviceId']
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -43,14 +43,14 @@ export const logoutAtPrimaryDevice = async ({ deviceAuthToken, database, websock
|
|||||||
currentUserId: ownDeviceEntryUnsafe.currentUserId
|
currentUserId: ownDeviceEntryUnsafe.currentUserId
|
||||||
}
|
}
|
||||||
|
|
||||||
const deviceUserEntryUnsafe = await database.user.findOne({
|
const deviceUserEntryUnsafe = await transaction.legacy.database.user.findOne({
|
||||||
where: {
|
where: {
|
||||||
familyId: ownDeviceEntry.familyId,
|
familyId: ownDeviceEntry.familyId,
|
||||||
userId: ownDeviceEntry.currentUserId,
|
userId: ownDeviceEntry.currentUserId,
|
||||||
type: 'child'
|
type: 'child'
|
||||||
},
|
},
|
||||||
attributes: ['currentDevice'],
|
attributes: ['currentDevice'],
|
||||||
transaction
|
transaction: transaction.legacy.transaction
|
||||||
})
|
})
|
||||||
|
|
||||||
if (!deviceUserEntryUnsafe) {
|
if (!deviceUserEntryUnsafe) {
|
||||||
@@ -61,14 +61,14 @@ export const logoutAtPrimaryDevice = async ({ deviceAuthToken, database, websock
|
|||||||
currentDevice: deviceUserEntryUnsafe.currentDevice
|
currentDevice: deviceUserEntryUnsafe.currentDevice
|
||||||
}
|
}
|
||||||
|
|
||||||
const otherDeviceEntryUnsafe = await database.device.findOne({
|
const otherDeviceEntryUnsafe = await transaction.legacy.database.device.findOne({
|
||||||
where: {
|
where: {
|
||||||
familyId: ownDeviceEntry.familyId,
|
familyId: ownDeviceEntry.familyId,
|
||||||
deviceId: deviceUserEntry.currentDevice,
|
deviceId: deviceUserEntry.currentDevice,
|
||||||
currentUserId: ownDeviceEntry.currentUserId
|
currentUserId: ownDeviceEntry.currentUserId
|
||||||
},
|
},
|
||||||
attributes: ['deviceAuthToken'],
|
attributes: ['deviceAuthToken'],
|
||||||
transaction
|
transaction: transaction.legacy.transaction
|
||||||
})
|
})
|
||||||
|
|
||||||
if (!otherDeviceEntryUnsafe) {
|
if (!otherDeviceEntryUnsafe) {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* server component for the TimeLimit App
|
* server component for the TimeLimit App
|
||||||
* Copyright (C) 2019 - 2022 Jonas Lochmann
|
* Copyright (C) 2019 - 2026 Jonas Lochmann
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU Affero General Public License as
|
* it under the terms of the GNU Affero General Public License as
|
||||||
@@ -17,13 +17,13 @@
|
|||||||
|
|
||||||
import { Conflict, InternalServerError, Unauthorized } from 'http-errors'
|
import { Conflict, InternalServerError, Unauthorized } from 'http-errors'
|
||||||
import { config } from '../../config'
|
import { config } from '../../config'
|
||||||
import { Database } from '../../database'
|
import { SimpleDatabase } from '../../database/simple'
|
||||||
import { generateVersionId } from '../../util/token'
|
import { generateVersionId } from '../../util/token'
|
||||||
import { WebsocketApi } from '../../websocket'
|
import { WebsocketApi } from '../../websocket'
|
||||||
import { notifyClientsAboutChangesDelayed } from '../websocket'
|
import { notifyClientsAboutChangesDelayed } from '../websocket'
|
||||||
|
|
||||||
export const setPrimaryDevice = async ({ database, websocket, deviceAuthToken, currentUserId, action }: {
|
export const setPrimaryDevice = async ({ database, websocket, deviceAuthToken, currentUserId, action }: {
|
||||||
database: Database
|
database: SimpleDatabase
|
||||||
websocket: WebsocketApi
|
websocket: WebsocketApi
|
||||||
deviceAuthToken: string
|
deviceAuthToken: string
|
||||||
currentUserId: string
|
currentUserId: string
|
||||||
@@ -31,11 +31,11 @@ export const setPrimaryDevice = async ({ database, websocket, deviceAuthToken, c
|
|||||||
// no transaction here because this is directly called from an API endpoint
|
// no transaction here because this is directly called from an API endpoint
|
||||||
}): Promise<'assigned to other device' | 'requires full version' | 'success'> => {
|
}): Promise<'assigned to other device' | 'requires full version' | 'success'> => {
|
||||||
return database.transaction(async (transaction): Promise<'assigned to other device' | 'requires full version' | 'success'> => {
|
return database.transaction(async (transaction): Promise<'assigned to other device' | 'requires full version' | 'success'> => {
|
||||||
const deviceEntryUnsafe = await database.device.findOne({
|
const deviceEntryUnsafe = await transaction.legacy.database.device.findOne({
|
||||||
where: {
|
where: {
|
||||||
deviceAuthToken
|
deviceAuthToken
|
||||||
},
|
},
|
||||||
transaction,
|
transaction: transaction.legacy.transaction,
|
||||||
attributes: ['familyId', 'currentUserId', 'deviceId']
|
attributes: ['familyId', 'currentUserId', 'deviceId']
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -53,12 +53,12 @@ export const setPrimaryDevice = async ({ database, websocket, deviceAuthToken, c
|
|||||||
throw new Conflict()
|
throw new Conflict()
|
||||||
}
|
}
|
||||||
|
|
||||||
const userEntryUnsafe = await database.user.findOne({
|
const userEntryUnsafe = await transaction.legacy.database.user.findOne({
|
||||||
where: {
|
where: {
|
||||||
familyId: deviceEntry.familyId,
|
familyId: deviceEntry.familyId,
|
||||||
userId: deviceEntry.currentUserId
|
userId: deviceEntry.currentUserId
|
||||||
},
|
},
|
||||||
transaction,
|
transaction: transaction.legacy.transaction,
|
||||||
attributes: ['currentDevice']
|
attributes: ['currentDevice']
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -70,12 +70,12 @@ export const setPrimaryDevice = async ({ database, websocket, deviceAuthToken, c
|
|||||||
currentDevice: userEntryUnsafe.currentDevice
|
currentDevice: userEntryUnsafe.currentDevice
|
||||||
}
|
}
|
||||||
|
|
||||||
const userDeviceEntriesUnsafe = await database.device.findAll({
|
const userDeviceEntriesUnsafe = await transaction.legacy.database.device.findAll({
|
||||||
where: {
|
where: {
|
||||||
familyId: deviceEntry.familyId,
|
familyId: deviceEntry.familyId,
|
||||||
currentUserId
|
currentUserId
|
||||||
},
|
},
|
||||||
transaction,
|
transaction: transaction.legacy.transaction,
|
||||||
attributes: ['deviceId']
|
attributes: ['deviceId']
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -84,11 +84,11 @@ export const setPrimaryDevice = async ({ database, websocket, deviceAuthToken, c
|
|||||||
}))
|
}))
|
||||||
|
|
||||||
if (userDeviceEntries.length >= 2) {
|
if (userDeviceEntries.length >= 2) {
|
||||||
const familyEntryUnsafe = await database.family.findOne({
|
const familyEntryUnsafe = await transaction.legacy.database.family.findOne({
|
||||||
where: {
|
where: {
|
||||||
familyId: deviceEntry.familyId
|
familyId: deviceEntry.familyId
|
||||||
},
|
},
|
||||||
transaction,
|
transaction: transaction.legacy.transaction,
|
||||||
attributes: ['hasFullVersion']
|
attributes: ['hasFullVersion']
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -112,14 +112,14 @@ export const setPrimaryDevice = async ({ database, websocket, deviceAuthToken, c
|
|||||||
}
|
}
|
||||||
|
|
||||||
// update
|
// update
|
||||||
const [affectedRows] = await database.user.update({
|
const [affectedRows] = await transaction.legacy.database.user.update({
|
||||||
currentDevice: deviceEntry.deviceId
|
currentDevice: deviceEntry.deviceId
|
||||||
}, {
|
}, {
|
||||||
where: {
|
where: {
|
||||||
familyId: deviceEntry.familyId,
|
familyId: deviceEntry.familyId,
|
||||||
userId: currentUserId
|
userId: currentUserId
|
||||||
},
|
},
|
||||||
transaction
|
transaction: transaction.legacy.transaction
|
||||||
})
|
})
|
||||||
|
|
||||||
if (affectedRows !== 1) {
|
if (affectedRows !== 1) {
|
||||||
@@ -131,14 +131,14 @@ export const setPrimaryDevice = async ({ database, websocket, deviceAuthToken, c
|
|||||||
}
|
}
|
||||||
|
|
||||||
// update
|
// update
|
||||||
const [affectedRows] = await database.user.update({
|
const [affectedRows] = await transaction.legacy.database.user.update({
|
||||||
currentDevice: ''
|
currentDevice: ''
|
||||||
}, {
|
}, {
|
||||||
where: {
|
where: {
|
||||||
familyId: deviceEntry.familyId,
|
familyId: deviceEntry.familyId,
|
||||||
userId: currentUserId
|
userId: currentUserId
|
||||||
},
|
},
|
||||||
transaction
|
transaction: transaction.legacy.transaction
|
||||||
})
|
})
|
||||||
|
|
||||||
if (affectedRows !== 1) {
|
if (affectedRows !== 1) {
|
||||||
@@ -149,10 +149,10 @@ export const setPrimaryDevice = async ({ database, websocket, deviceAuthToken, c
|
|||||||
}
|
}
|
||||||
|
|
||||||
// invalidiate user list
|
// invalidiate user list
|
||||||
await database.family.update({
|
await transaction.legacy.database.family.update({
|
||||||
userListVersion: generateVersionId()
|
userListVersion: generateVersionId()
|
||||||
}, {
|
}, {
|
||||||
transaction,
|
transaction: transaction.legacy.transaction,
|
||||||
where: {
|
where: {
|
||||||
familyId: deviceEntry.familyId
|
familyId: deviceEntry.familyId
|
||||||
}
|
}
|
||||||
@@ -163,10 +163,9 @@ export const setPrimaryDevice = async ({ database, websocket, deviceAuthToken, c
|
|||||||
familyId: deviceEntry.familyId,
|
familyId: deviceEntry.familyId,
|
||||||
sourceDeviceId: deviceEntry.deviceId,
|
sourceDeviceId: deviceEntry.deviceId,
|
||||||
websocket,
|
websocket,
|
||||||
database,
|
transaction,
|
||||||
generalLevel: 1, // the source device knows it already
|
generalLevel: 1, // the source device knows it already
|
||||||
targetedLevels: new Map(),
|
targetedLevels: new Map(),
|
||||||
transaction
|
|
||||||
})
|
})
|
||||||
|
|
||||||
return 'success'
|
return 'success'
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* server component for the TimeLimit App
|
* server component for the TimeLimit App
|
||||||
* Copyright (C) 2019 - 2023 Jonas Lochmann
|
* Copyright (C) 2019 - 2026 Jonas Lochmann
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU Affero General Public License as
|
* it under the terms of the GNU Affero General Public License as
|
||||||
@@ -17,7 +17,7 @@
|
|||||||
|
|
||||||
import { Unauthorized } from 'http-errors'
|
import { Unauthorized } from 'http-errors'
|
||||||
import { DeleteAccountPayload } from '../../api/schema'
|
import { DeleteAccountPayload } from '../../api/schema'
|
||||||
import { Database } from '../../database'
|
import { SimpleDatabase } from '../../database/simple'
|
||||||
import { sendAccountDeletedMail } from '../../util/mail'
|
import { sendAccountDeletedMail } from '../../util/mail'
|
||||||
import { WebsocketApi } from '../../websocket'
|
import { WebsocketApi } from '../../websocket'
|
||||||
import { requireMailAndLocaleByAuthToken } from '../authentication'
|
import { requireMailAndLocaleByAuthToken } from '../authentication'
|
||||||
@@ -25,14 +25,14 @@ import { deleteFamilies } from './delete-families'
|
|||||||
|
|
||||||
export async function deleteAccount({ request, database, websocket }: {
|
export async function deleteAccount({ request, database, websocket }: {
|
||||||
request: DeleteAccountPayload
|
request: DeleteAccountPayload
|
||||||
database: Database
|
database: SimpleDatabase
|
||||||
websocket: WebsocketApi
|
websocket: WebsocketApi
|
||||||
}) {
|
}) {
|
||||||
await database.transaction(async (transaction) => {
|
await database.transaction(async (transaction) => {
|
||||||
const deviceEntryUnsafe = await database.device.findOne({
|
const deviceEntryUnsafe = await transaction.legacy.database.device.findOne({
|
||||||
where: { deviceAuthToken: request.deviceAuthToken },
|
where: { deviceAuthToken: request.deviceAuthToken },
|
||||||
attributes: ['familyId'],
|
attributes: ['familyId'],
|
||||||
transaction
|
transaction: transaction.legacy.transaction
|
||||||
})
|
})
|
||||||
|
|
||||||
if (!deviceEntryUnsafe) {
|
if (!deviceEntryUnsafe) {
|
||||||
@@ -43,13 +43,13 @@ export async function deleteAccount({ request, database, websocket }: {
|
|||||||
familyId: deviceEntryUnsafe.familyId
|
familyId: deviceEntryUnsafe.familyId
|
||||||
}
|
}
|
||||||
|
|
||||||
const userEntries = (await database.user.findAll({
|
const userEntries = (await transaction.legacy.database.user.findAll({
|
||||||
where: {
|
where: {
|
||||||
familyId: deviceEntry.familyId,
|
familyId: deviceEntry.familyId,
|
||||||
type: 'parent'
|
type: 'parent'
|
||||||
},
|
},
|
||||||
attributes: ['mail'],
|
attributes: ['mail'],
|
||||||
transaction
|
transaction: transaction.legacy.transaction
|
||||||
})).map((item) => ({ mail: item.mail }))
|
})).map((item) => ({ mail: item.mail }))
|
||||||
|
|
||||||
const registeredMailAddresses = new Set<string>()
|
const registeredMailAddresses = new Set<string>()
|
||||||
@@ -63,7 +63,6 @@ export async function deleteAccount({ request, database, websocket }: {
|
|||||||
for (const mailAuthToken of request.mailAuthTokens) {
|
for (const mailAuthToken of request.mailAuthTokens) {
|
||||||
const info = await requireMailAndLocaleByAuthToken({
|
const info = await requireMailAndLocaleByAuthToken({
|
||||||
mailAuthToken,
|
mailAuthToken,
|
||||||
database,
|
|
||||||
transaction,
|
transaction,
|
||||||
invalidate: true
|
invalidate: true
|
||||||
})
|
})
|
||||||
@@ -79,17 +78,17 @@ export async function deleteAccount({ request, database, websocket }: {
|
|||||||
if (!authenticatedMailAddresses.has(mail)) throw new Unauthorized()
|
if (!authenticatedMailAddresses.has(mail)) throw new Unauthorized()
|
||||||
})
|
})
|
||||||
|
|
||||||
const deviceEntries = (await database.device.findAll({
|
const deviceEntries = (await transaction.legacy.database.device.findAll({
|
||||||
where: {
|
where: {
|
||||||
familyId: deviceEntry.familyId
|
familyId: deviceEntry.familyId
|
||||||
},
|
},
|
||||||
transaction,
|
transaction: transaction.legacy.transaction,
|
||||||
attributes: ['deviceAuthToken']
|
attributes: ['deviceAuthToken']
|
||||||
})).map((item) => ({ deviceAuthToken: item.deviceAuthToken }))
|
})).map((item) => ({ deviceAuthToken: item.deviceAuthToken }))
|
||||||
|
|
||||||
await deleteFamilies({ database, transaction, familiyIds: [deviceEntry.familyId] })
|
await deleteFamilies({ transaction, familiyIds: [deviceEntry.familyId] })
|
||||||
|
|
||||||
transaction.afterCommit(() => {
|
transaction.enqueueAfterCommit(() => {
|
||||||
for (const device of deviceEntries) {
|
for (const device of deviceEntries) {
|
||||||
websocket.triggerSyncByDeviceAuthToken({
|
websocket.triggerSyncByDeviceAuthToken({
|
||||||
deviceAuthToken: device.deviceAuthToken,
|
deviceAuthToken: device.deviceAuthToken,
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* server component for the TimeLimit App
|
* server component for the TimeLimit App
|
||||||
* Copyright (C) 2019 - 2023 Jonas Lochmann
|
* Copyright (C) 2019 - 2026 Jonas Lochmann
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU Affero General Public License as
|
* it under the terms of the GNU Affero General Public License as
|
||||||
@@ -17,138 +17,136 @@
|
|||||||
|
|
||||||
import { difference } from 'lodash'
|
import { difference } from 'lodash'
|
||||||
import * as Sequelize from 'sequelize'
|
import * as Sequelize from 'sequelize'
|
||||||
import { Database, Transaction } from '../../database'
|
import { SimpleDatabaseTransaction } from '../../database/simple'
|
||||||
|
|
||||||
export async function deleteFamilies ({ database, transaction, familiyIds }: {
|
export async function deleteFamilies ({ transaction, familiyIds }: {
|
||||||
database: Database
|
transaction: SimpleDatabaseTransaction
|
||||||
transaction: Transaction
|
|
||||||
familiyIds: Array<string>
|
familiyIds: Array<string>
|
||||||
// no transaction here because this should run isolated
|
|
||||||
}) {
|
}) {
|
||||||
if (familiyIds.length === 0) {
|
if (familiyIds.length === 0) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// category
|
// category
|
||||||
await database.category.destroy({
|
await transaction.legacy.database.category.destroy({
|
||||||
where: {
|
where: {
|
||||||
familyId: {
|
familyId: {
|
||||||
[Sequelize.Op.in]: familiyIds
|
[Sequelize.Op.in]: familiyIds
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
transaction
|
transaction: transaction.legacy.transaction
|
||||||
})
|
})
|
||||||
|
|
||||||
// categoryapp
|
// categoryapp
|
||||||
await database.categoryApp.destroy({
|
await transaction.legacy.database.categoryApp.destroy({
|
||||||
where: {
|
where: {
|
||||||
familyId: {
|
familyId: {
|
||||||
[Sequelize.Op.in]: familiyIds
|
[Sequelize.Op.in]: familiyIds
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
transaction
|
transaction: transaction.legacy.transaction
|
||||||
})
|
})
|
||||||
|
|
||||||
// purchase
|
// purchase
|
||||||
await database.purchase.destroy({
|
await transaction.legacy.database.purchase.destroy({
|
||||||
where: {
|
where: {
|
||||||
familyId: {
|
familyId: {
|
||||||
[Sequelize.Op.in]: familiyIds
|
[Sequelize.Op.in]: familiyIds
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
transaction
|
transaction: transaction.legacy.transaction
|
||||||
})
|
})
|
||||||
|
|
||||||
// timelimitrule
|
// timelimitrule
|
||||||
await database.timelimitRule.destroy({
|
await transaction.legacy.database.timelimitRule.destroy({
|
||||||
where: {
|
where: {
|
||||||
familyId: {
|
familyId: {
|
||||||
[Sequelize.Op.in]: familiyIds
|
[Sequelize.Op.in]: familiyIds
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
transaction
|
transaction: transaction.legacy.transaction
|
||||||
})
|
})
|
||||||
|
|
||||||
// usedtime
|
// usedtime
|
||||||
await database.usedTime.destroy({
|
await transaction.legacy.database.usedTime.destroy({
|
||||||
where: {
|
where: {
|
||||||
familyId: {
|
familyId: {
|
||||||
[Sequelize.Op.in]: familiyIds
|
[Sequelize.Op.in]: familiyIds
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
transaction
|
transaction: transaction.legacy.transaction
|
||||||
})
|
})
|
||||||
|
|
||||||
// session durations
|
// session durations
|
||||||
await database.sessionDuration.destroy({
|
await transaction.legacy.database.sessionDuration.destroy({
|
||||||
where: {
|
where: {
|
||||||
familyId: {
|
familyId: {
|
||||||
[Sequelize.Op.in]: familiyIds
|
[Sequelize.Op.in]: familiyIds
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
transaction
|
transaction: transaction.legacy.transaction
|
||||||
})
|
})
|
||||||
|
|
||||||
// user
|
// user
|
||||||
await database.user.destroy({
|
await transaction.legacy.database.user.destroy({
|
||||||
where: {
|
where: {
|
||||||
familyId: {
|
familyId: {
|
||||||
[Sequelize.Op.in]: familiyIds
|
[Sequelize.Op.in]: familiyIds
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
transaction
|
transaction: transaction.legacy.transaction
|
||||||
})
|
})
|
||||||
|
|
||||||
// device
|
// device
|
||||||
const oldDeviceAuthTokens = (await database.device.findAll({
|
const oldDeviceAuthTokens = (await transaction.legacy.database.device.findAll({
|
||||||
where: {
|
where: {
|
||||||
familyId: {
|
familyId: {
|
||||||
[Sequelize.Op.in]: familiyIds
|
[Sequelize.Op.in]: familiyIds
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
attributes: ['deviceAuthToken'],
|
attributes: ['deviceAuthToken'],
|
||||||
transaction
|
transaction: transaction.legacy.transaction
|
||||||
})).map((item) => item.deviceAuthToken)
|
})).map((item) => item.deviceAuthToken)
|
||||||
|
|
||||||
await database.device.destroy({
|
await transaction.legacy.database.device.destroy({
|
||||||
where: {
|
where: {
|
||||||
familyId: {
|
familyId: {
|
||||||
[Sequelize.Op.in]: familiyIds
|
[Sequelize.Op.in]: familiyIds
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
transaction
|
transaction: transaction.legacy.transaction
|
||||||
})
|
})
|
||||||
|
|
||||||
// olddevice
|
// olddevice
|
||||||
if (oldDeviceAuthTokens.length > 0) {
|
if (oldDeviceAuthTokens.length > 0) {
|
||||||
const knownOldDeviceAuthTokens = (await database.oldDevice.findAll({
|
const knownOldDeviceAuthTokens = (await transaction.legacy.database.oldDevice.findAll({
|
||||||
where: {
|
where: {
|
||||||
deviceAuthToken: {
|
deviceAuthToken: {
|
||||||
[Sequelize.Op.in]: oldDeviceAuthTokens
|
[Sequelize.Op.in]: oldDeviceAuthTokens
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
transaction
|
transaction: transaction.legacy.transaction
|
||||||
})).map((item) => item.deviceAuthToken)
|
})).map((item) => item.deviceAuthToken)
|
||||||
|
|
||||||
const oldDeviceAuthTokensToAdd = difference(oldDeviceAuthTokens, knownOldDeviceAuthTokens)
|
const oldDeviceAuthTokensToAdd = difference(oldDeviceAuthTokens, knownOldDeviceAuthTokens)
|
||||||
|
|
||||||
if (oldDeviceAuthTokensToAdd.length > 0) {
|
if (oldDeviceAuthTokensToAdd.length > 0) {
|
||||||
await database.oldDevice.bulkCreate(
|
await transaction.legacy.database.oldDevice.bulkCreate(
|
||||||
oldDeviceAuthTokensToAdd.map((item) => ({
|
oldDeviceAuthTokensToAdd.map((item) => ({
|
||||||
deviceAuthToken: item
|
deviceAuthToken: item
|
||||||
})),
|
})),
|
||||||
{ transaction }
|
{ transaction: transaction.legacy.transaction }
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// family
|
// family
|
||||||
await database.family.destroy({
|
await transaction.legacy.database.family.destroy({
|
||||||
where: {
|
where: {
|
||||||
familyId: {
|
familyId: {
|
||||||
[Sequelize.Op.in]: familiyIds
|
[Sequelize.Op.in]: familiyIds
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
transaction
|
transaction: transaction.legacy.transaction
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* server component for the TimeLimit App
|
* server component for the TimeLimit App
|
||||||
* Copyright (C) 2019 - 2023 Jonas Lochmann
|
* Copyright (C) 2019 - 2026 Jonas Lochmann
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU Affero General Public License as
|
* it under the terms of the GNU Affero General Public License as
|
||||||
@@ -17,10 +17,10 @@
|
|||||||
|
|
||||||
import { difference } from 'lodash'
|
import { difference } from 'lodash'
|
||||||
import * as Sequelize from 'sequelize'
|
import * as Sequelize from 'sequelize'
|
||||||
import { Database } from '../../database'
|
import { SimpleDatabase } from '../../database/simple'
|
||||||
import { deleteFamilies } from './delete-families'
|
import { deleteFamilies } from './delete-families'
|
||||||
|
|
||||||
export async function deleteOldFamilies (database: Database) {
|
export async function deleteOldFamilies (database: SimpleDatabase) {
|
||||||
const oldFamilyIds = await findOldFamilyIds(database)
|
const oldFamilyIds = await findOldFamilyIds(database)
|
||||||
|
|
||||||
if (oldFamilyIds.length > 0) {
|
if (oldFamilyIds.length > 0) {
|
||||||
@@ -28,7 +28,6 @@ export async function deleteOldFamilies (database: Database) {
|
|||||||
|
|
||||||
await database.transaction(async (transaction) => {
|
await database.transaction(async (transaction) => {
|
||||||
await deleteFamilies({
|
await deleteFamilies({
|
||||||
database,
|
|
||||||
transaction,
|
transaction,
|
||||||
familiyIds: familyIdsToDelete
|
familiyIds: familyIdsToDelete
|
||||||
})
|
})
|
||||||
@@ -36,23 +35,23 @@ export async function deleteOldFamilies (database: Database) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function findOldFamilyIds (database: Database) {
|
export async function findOldFamilyIds (database: SimpleDatabase): Promise<Array<string>> {
|
||||||
return database.transaction(async (transaction) => {
|
return database.transaction(async (transaction) => {
|
||||||
const familyIdsWithExpiredLicenses = (await database.family.findAll({
|
const familyIdsWithExpiredLicenses = (await transaction.legacy.database.family.findAll({
|
||||||
where: {
|
where: {
|
||||||
fullVersionUntil: {
|
fullVersionUntil: {
|
||||||
[Sequelize.Op.lt]: (Date.now() - 1000 * 60 * 60 * 24 * 90 /* 90 days */).toString(10)
|
[Sequelize.Op.lt]: (Date.now() - 1000 * 60 * 60 * 24 * 90 /* 90 days */).toString(10)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
attributes: ['familyId'],
|
attributes: ['familyId'],
|
||||||
transaction
|
transaction: transaction.legacy.transaction
|
||||||
})).map((item) => item.familyId)
|
})).map((item) => item.familyId)
|
||||||
|
|
||||||
if (familyIdsWithExpiredLicenses.length === 0) {
|
if (familyIdsWithExpiredLicenses.length === 0) {
|
||||||
return []
|
return []
|
||||||
}
|
}
|
||||||
|
|
||||||
const recentlyUsedFamilyIds = (await database.device.findAll({
|
const recentlyUsedFamilyIds = (await transaction.legacy.database.device.findAll({
|
||||||
where: {
|
where: {
|
||||||
familyId: {
|
familyId: {
|
||||||
[Sequelize.Op.in]: familyIdsWithExpiredLicenses
|
[Sequelize.Op.in]: familyIdsWithExpiredLicenses
|
||||||
@@ -62,7 +61,7 @@ export async function findOldFamilyIds (database: Database) {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
attributes: ['familyId'],
|
attributes: ['familyId'],
|
||||||
transaction
|
transaction: transaction.legacy.transaction
|
||||||
})).map((item) => item.familyId)
|
})).map((item) => item.familyId)
|
||||||
|
|
||||||
return difference(familyIdsWithExpiredLicenses, recentlyUsedFamilyIds)
|
return difference(familyIdsWithExpiredLicenses, recentlyUsedFamilyIds)
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* server component for the TimeLimit App
|
* server component for the TimeLimit App
|
||||||
* Copyright (C) 2019 - 2022 Jonas Lochmann
|
* Copyright (C) 2019 - 2026 Jonas Lochmann
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU Affero General Public License as
|
* it under the terms of the GNU Affero General Public License as
|
||||||
@@ -16,24 +16,23 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { Conflict } from 'http-errors'
|
import { Conflict } from 'http-errors'
|
||||||
import { Database, Transaction } from '../../database'
|
import { SimpleDatabaseTransaction } from '../../database/simple'
|
||||||
import { generateVersionId } from '../../util/token'
|
import { generateVersionId } from '../../util/token'
|
||||||
import { WebsocketApi } from '../../websocket'
|
import { WebsocketApi } from '../../websocket'
|
||||||
import { notifyClientsAboutChangesDelayed } from '../websocket'
|
import { notifyClientsAboutChangesDelayed } from '../websocket'
|
||||||
|
|
||||||
export async function removeDevice ({ database, familyId, deviceId, websocket, transaction }: {
|
export async function removeDevice ({ familyId, deviceId, websocket, transaction }: {
|
||||||
database: Database
|
transaction: SimpleDatabaseTransaction
|
||||||
familyId: string
|
familyId: string
|
||||||
deviceId: string
|
deviceId: string
|
||||||
websocket: WebsocketApi
|
websocket: WebsocketApi
|
||||||
transaction: Transaction
|
|
||||||
}) {
|
}) {
|
||||||
const deviceEntry = await database.device.findOne({
|
const deviceEntry = await transaction.legacy.database.device.findOne({
|
||||||
where: {
|
where: {
|
||||||
familyId,
|
familyId,
|
||||||
deviceId
|
deviceId
|
||||||
},
|
},
|
||||||
transaction
|
transaction: transaction.legacy.transaction
|
||||||
})
|
})
|
||||||
|
|
||||||
if (!deviceEntry) {
|
if (!deviceEntry) {
|
||||||
@@ -41,37 +40,37 @@ export async function removeDevice ({ database, familyId, deviceId, websocket, t
|
|||||||
}
|
}
|
||||||
|
|
||||||
// remove as current device
|
// remove as current device
|
||||||
await database.user.update({
|
await transaction.legacy.database.user.update({
|
||||||
currentDevice: ''
|
currentDevice: ''
|
||||||
}, {
|
}, {
|
||||||
where: {
|
where: {
|
||||||
familyId,
|
familyId,
|
||||||
currentDevice: deviceId
|
currentDevice: deviceId
|
||||||
},
|
},
|
||||||
transaction
|
transaction: transaction.legacy.transaction
|
||||||
})
|
})
|
||||||
|
|
||||||
// add to old devices if it is not yet there (it could be there if it reported a uninstall)
|
// add to old devices if it is not yet there (it could be there if it reported a uninstall)
|
||||||
const oldOldDeviceEntry = await database.oldDevice.findOne({
|
const oldOldDeviceEntry = await transaction.legacy.database.oldDevice.findOne({
|
||||||
where: {
|
where: {
|
||||||
deviceAuthToken: deviceEntry.deviceAuthToken
|
deviceAuthToken: deviceEntry.deviceAuthToken
|
||||||
},
|
},
|
||||||
transaction
|
transaction: transaction.legacy.transaction
|
||||||
})
|
})
|
||||||
|
|
||||||
if (!oldOldDeviceEntry) {
|
if (!oldOldDeviceEntry) {
|
||||||
await database.oldDevice.create({
|
await transaction.legacy.database.oldDevice.create({
|
||||||
deviceAuthToken: deviceEntry.deviceAuthToken
|
deviceAuthToken: deviceEntry.deviceAuthToken
|
||||||
}, {
|
}, {
|
||||||
transaction
|
transaction: transaction.legacy.transaction
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// remove from the device list
|
// remove from the device list
|
||||||
await deviceEntry.destroy({ transaction })
|
await deviceEntry.destroy({ transaction: transaction.legacy.transaction })
|
||||||
|
|
||||||
// invalidiate the caches
|
// invalidiate the caches
|
||||||
await database.family.update({
|
await transaction.legacy.database.family.update({
|
||||||
deviceListVersion: generateVersionId(),
|
deviceListVersion: generateVersionId(),
|
||||||
// the device could have become unassigned during this
|
// the device could have become unassigned during this
|
||||||
userListVersion: generateVersionId()
|
userListVersion: generateVersionId()
|
||||||
@@ -79,20 +78,19 @@ export async function removeDevice ({ database, familyId, deviceId, websocket, t
|
|||||||
where: {
|
where: {
|
||||||
familyId: deviceEntry.familyId
|
familyId: deviceEntry.familyId
|
||||||
},
|
},
|
||||||
transaction
|
transaction: transaction.legacy.transaction
|
||||||
})
|
})
|
||||||
|
|
||||||
await notifyClientsAboutChangesDelayed({
|
await notifyClientsAboutChangesDelayed({
|
||||||
database,
|
transaction,
|
||||||
websocket,
|
websocket,
|
||||||
familyId,
|
familyId,
|
||||||
sourceDeviceId: null,
|
sourceDeviceId: null,
|
||||||
generalLevel: 1,
|
generalLevel: 1,
|
||||||
targetedLevels: new Map(),
|
targetedLevels: new Map()
|
||||||
transaction
|
|
||||||
})
|
})
|
||||||
|
|
||||||
transaction.afterCommit(() => {
|
transaction.enqueueAfterCommit(() => {
|
||||||
websocket.triggerSyncByDeviceAuthToken({
|
websocket.triggerSyncByDeviceAuthToken({
|
||||||
deviceAuthToken: deviceEntry.deviceAuthToken,
|
deviceAuthToken: deviceEntry.deviceAuthToken,
|
||||||
isImportant: true
|
isImportant: true
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* server component for the TimeLimit App
|
* server component for the TimeLimit App
|
||||||
* Copyright (C) 2019 - 2022 Jonas Lochmann
|
* Copyright (C) 2019 - 2026 Jonas Lochmann
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU Affero General Public License as
|
* it under the terms of the GNU Affero General Public License as
|
||||||
@@ -16,24 +16,24 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { Unauthorized } from 'http-errors'
|
import { Unauthorized } from 'http-errors'
|
||||||
import { Database } from '../../database'
|
import { SimpleDatabase } from '../../database/simple'
|
||||||
import { generateAuthToken, generateVersionId } from '../../util/token'
|
import { generateAuthToken, generateVersionId } from '../../util/token'
|
||||||
import { WebsocketApi } from '../../websocket'
|
import { WebsocketApi } from '../../websocket'
|
||||||
import { sendUninstallWarnings } from '../warningmail/uninstall'
|
import { sendUninstallWarnings } from '../warningmail/uninstall'
|
||||||
import { notifyClientsAboutChangesDelayed } from '../websocket'
|
import { notifyClientsAboutChangesDelayed } from '../websocket'
|
||||||
|
|
||||||
export async function reportDeviceRemoved ({ database, deviceAuthToken, websocket }: {
|
export async function reportDeviceRemoved ({ database, deviceAuthToken, websocket }: {
|
||||||
database: Database
|
database: SimpleDatabase
|
||||||
deviceAuthToken: string
|
deviceAuthToken: string
|
||||||
websocket: WebsocketApi
|
websocket: WebsocketApi
|
||||||
// no transaction here because this is directly called from an API endpoint
|
// no transaction here because this is directly called from an API endpoint
|
||||||
}) {
|
}) {
|
||||||
await database.transaction(async (transaction) => {
|
await database.transaction(async (transaction) => {
|
||||||
const deviceEntry = await database.device.findOne({
|
const deviceEntry = await transaction.legacy.database.device.findOne({
|
||||||
where: {
|
where: {
|
||||||
deviceAuthToken
|
deviceAuthToken
|
||||||
},
|
},
|
||||||
transaction
|
transaction: transaction.legacy.transaction
|
||||||
})
|
})
|
||||||
|
|
||||||
if (deviceEntry) {
|
if (deviceEntry) {
|
||||||
@@ -41,47 +41,45 @@ export async function reportDeviceRemoved ({ database, deviceAuthToken, websocke
|
|||||||
|
|
||||||
deviceEntry.didDeviceReportUninstall = true
|
deviceEntry.didDeviceReportUninstall = true
|
||||||
deviceEntry.deviceAuthToken = generateAuthToken() // invalidiate the token
|
deviceEntry.deviceAuthToken = generateAuthToken() // invalidiate the token
|
||||||
await deviceEntry.save({ transaction })
|
await deviceEntry.save({ transaction: transaction.legacy.transaction })
|
||||||
|
|
||||||
// invalidiate device list
|
// invalidiate device list
|
||||||
await database.family.update({
|
await transaction.legacy.database.family.update({
|
||||||
deviceListVersion: generateVersionId()
|
deviceListVersion: generateVersionId()
|
||||||
}, {
|
}, {
|
||||||
where: {
|
where: {
|
||||||
familyId: deviceEntry.familyId
|
familyId: deviceEntry.familyId
|
||||||
},
|
},
|
||||||
transaction
|
transaction: transaction.legacy.transaction
|
||||||
})
|
})
|
||||||
|
|
||||||
// add to old devices
|
// add to old devices
|
||||||
await database.oldDevice.create({
|
await transaction.legacy.database.oldDevice.create({
|
||||||
deviceAuthToken: currentAuthToken
|
deviceAuthToken: currentAuthToken
|
||||||
}, {
|
}, {
|
||||||
transaction
|
transaction: transaction.legacy.transaction
|
||||||
})
|
})
|
||||||
|
|
||||||
await notifyClientsAboutChangesDelayed({
|
await notifyClientsAboutChangesDelayed({
|
||||||
database,
|
transaction,
|
||||||
websocket,
|
websocket,
|
||||||
familyId: deviceEntry.familyId,
|
familyId: deviceEntry.familyId,
|
||||||
sourceDeviceId: null,
|
sourceDeviceId: null,
|
||||||
generalLevel: 1,
|
generalLevel: 1,
|
||||||
targetedLevels: new Map(),
|
targetedLevels: new Map(),
|
||||||
transaction
|
|
||||||
})
|
})
|
||||||
|
|
||||||
await sendUninstallWarnings({
|
await sendUninstallWarnings({
|
||||||
database,
|
transaction,
|
||||||
familyId: deviceEntry.familyId,
|
familyId: deviceEntry.familyId,
|
||||||
deviceName: deviceEntry.name,
|
deviceName: deviceEntry.name,
|
||||||
transaction
|
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
const oldDeviceEntry = await database.oldDevice.findOne({
|
const oldDeviceEntry = await transaction.legacy.database.oldDevice.findOne({
|
||||||
where: {
|
where: {
|
||||||
deviceAuthToken
|
deviceAuthToken
|
||||||
},
|
},
|
||||||
transaction
|
transaction: transaction.legacy.transaction
|
||||||
})
|
})
|
||||||
|
|
||||||
if (!oldDeviceEntry) {
|
if (!oldDeviceEntry) {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* server component for the TimeLimit App
|
* server component for the TimeLimit App
|
||||||
* Copyright (C) 2019 - 2022 Jonas Lochmann
|
* Copyright (C) 2019 - 2026 Jonas Lochmann
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU Affero General Public License as
|
* it under the terms of the GNU Affero General Public License as
|
||||||
@@ -15,17 +15,15 @@
|
|||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import * as Sequelize from 'sequelize'
|
|
||||||
import { createDecipheriv } from 'crypto'
|
import { createDecipheriv } from 'crypto'
|
||||||
import { Database } from '../../database'
|
import { SimpleDatabaseTransaction } from '../../database/simple'
|
||||||
import { isVersionId } from '../../util/token'
|
import { isVersionId } from '../../util/token'
|
||||||
import { getSharedSecret, SharedSecretException } from './shared-secret'
|
import { getSharedSecret, SharedSecretException } from './shared-secret'
|
||||||
|
|
||||||
export async function decrypt({
|
export async function decrypt({
|
||||||
database, transaction, familyId, deviceId, encryptedData, authData
|
transaction, familyId, deviceId, encryptedData, authData
|
||||||
}: {
|
}: {
|
||||||
database: Database
|
transaction: SimpleDatabaseTransaction
|
||||||
transaction: Sequelize.Transaction
|
|
||||||
familyId: string
|
familyId: string
|
||||||
deviceId: string
|
deviceId: string
|
||||||
encryptedData: string
|
encryptedData: string
|
||||||
@@ -46,7 +44,6 @@ export async function decrypt({
|
|||||||
const sharedSecret = await (async () => {
|
const sharedSecret = await (async () => {
|
||||||
try {
|
try {
|
||||||
return getSharedSecret({
|
return getSharedSecret({
|
||||||
database,
|
|
||||||
transaction,
|
transaction,
|
||||||
familyId,
|
familyId,
|
||||||
deviceId,
|
deviceId,
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* server component for the TimeLimit App
|
* server component for the TimeLimit App
|
||||||
* Copyright (C) 2019 - 2022 Jonas Lochmann
|
* Copyright (C) 2019 - 2026 Jonas Lochmann
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU Affero General Public License as
|
* it under the terms of the GNU Affero General Public License as
|
||||||
@@ -31,7 +31,6 @@ export async function decryptParentPassword({ cache, password } : {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
const secondHash = (await decrypt({
|
const secondHash = (await decrypt({
|
||||||
database: cache.database,
|
|
||||||
transaction: cache.transaction,
|
transaction: cache.transaction,
|
||||||
familyId: cache.familyId,
|
familyId: cache.familyId,
|
||||||
deviceId: cache.deviceId,
|
deviceId: cache.deviceId,
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* server component for the TimeLimit App
|
* server component for the TimeLimit App
|
||||||
* Copyright (C) 2019 - 2022 Jonas Lochmann
|
* Copyright (C) 2019 - 2026 Jonas Lochmann
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU Affero General Public License as
|
* it under the terms of the GNU Affero General Public License as
|
||||||
@@ -15,17 +15,15 @@
|
|||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import * as Sequelize from 'sequelize'
|
|
||||||
import { createPrivateKey, createPublicKey, diffieHellman } from 'crypto'
|
import { createPrivateKey, createPublicKey, diffieHellman } from 'crypto'
|
||||||
import { Database } from '../../database'
|
import { SimpleDatabaseTransaction } from '../../database/simple'
|
||||||
import { calculateExpireTime } from '../../database/devicedhkey'
|
import { calculateExpireTime } from '../../database/devicedhkey'
|
||||||
import { isVersionId } from '../../util/token'
|
import { isVersionId } from '../../util/token'
|
||||||
|
|
||||||
export async function getSharedSecret({
|
export async function getSharedSecret({
|
||||||
database, transaction, familyId, deviceId, keyId, otherPublicKey
|
transaction, familyId, deviceId, keyId, otherPublicKey
|
||||||
}: {
|
}: {
|
||||||
database: Database
|
transaction: SimpleDatabaseTransaction
|
||||||
transaction: Sequelize.Transaction
|
|
||||||
familyId: string
|
familyId: string
|
||||||
deviceId: string
|
deviceId: string
|
||||||
keyId: string
|
keyId: string
|
||||||
@@ -33,20 +31,20 @@ export async function getSharedSecret({
|
|||||||
}) {
|
}) {
|
||||||
if (!isVersionId(keyId)) throw new KeyNotFoundException('invalid key id')
|
if (!isVersionId(keyId)) throw new KeyNotFoundException('invalid key id')
|
||||||
|
|
||||||
const databaseKeyEntry = await database.deviceDhKey.findOne({
|
const databaseKeyEntry = await transaction.legacy.database.deviceDhKey.findOne({
|
||||||
where: {
|
where: {
|
||||||
familyId,
|
familyId,
|
||||||
deviceId,
|
deviceId,
|
||||||
version: keyId
|
version: keyId
|
||||||
},
|
},
|
||||||
transaction
|
transaction: transaction.legacy.transaction
|
||||||
})
|
})
|
||||||
|
|
||||||
if (!databaseKeyEntry) throw new KeyNotFoundException('private key not found')
|
if (!databaseKeyEntry) throw new KeyNotFoundException('private key not found')
|
||||||
|
|
||||||
if (databaseKeyEntry.expireAt === null) {
|
if (databaseKeyEntry.expireAt === null) {
|
||||||
databaseKeyEntry.expireAt = calculateExpireTime(BigInt(Date.now())).toString(10)
|
databaseKeyEntry.expireAt = calculateExpireTime(BigInt(Date.now())).toString(10)
|
||||||
await databaseKeyEntry.save({ transaction })
|
await databaseKeyEntry.save({ transaction: transaction.legacy.transaction })
|
||||||
} else {
|
} else {
|
||||||
if (BigInt(databaseKeyEntry.expireAt) < BigInt(Date.now())) throw new KeyExpiredException()
|
if (BigInt(databaseKeyEntry.expireAt) < BigInt(Date.now())) throw new KeyExpiredException()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* server component for the TimeLimit App
|
* server component for the TimeLimit App
|
||||||
* Copyright (C) 2019 - 2020 Jonas Lochmann
|
* Copyright (C) 2019 - 2026 Jonas Lochmann
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU Affero General Public License as
|
* it under the terms of the GNU Affero General Public License as
|
||||||
@@ -15,31 +15,30 @@
|
|||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { Database, Transaction } from '../../database'
|
import { SimpleDatabaseTransaction } from '../../database/simple'
|
||||||
import { randomWords } from '../../util/random-words'
|
import { randomWords } from '../../util/random-words'
|
||||||
import { generateIdWithinFamily } from '../../util/token'
|
import { generateIdWithinFamily } from '../../util/token'
|
||||||
|
|
||||||
export const createAddDeviceToken = async ({ familyId, database, transaction }: {
|
export const createAddDeviceToken = async ({ familyId, transaction }: {
|
||||||
familyId: string
|
familyId: string
|
||||||
database: Database
|
transaction: SimpleDatabaseTransaction
|
||||||
transaction: Transaction
|
|
||||||
}) => {
|
}) => {
|
||||||
const token = randomWords(5)
|
const token = randomWords(5)
|
||||||
const deviceId = generateIdWithinFamily()
|
const deviceId = generateIdWithinFamily()
|
||||||
|
|
||||||
await database.addDeviceToken.destroy({
|
await transaction.legacy.database.addDeviceToken.destroy({
|
||||||
where: {
|
where: {
|
||||||
familyId
|
familyId
|
||||||
},
|
},
|
||||||
transaction
|
transaction: transaction.legacy.transaction
|
||||||
})
|
})
|
||||||
|
|
||||||
await database.addDeviceToken.create({
|
await transaction.legacy.database.addDeviceToken.create({
|
||||||
familyId,
|
familyId,
|
||||||
token: token.toLowerCase(),
|
token: token.toLowerCase(),
|
||||||
deviceId,
|
deviceId,
|
||||||
createdAt: Date.now().toString()
|
createdAt: Date.now().toString()
|
||||||
}, { transaction })
|
}, { transaction: transaction.legacy.transaction })
|
||||||
|
|
||||||
return { token, deviceId }
|
return { token, deviceId }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* server component for the TimeLimit App
|
* server component for the TimeLimit App
|
||||||
* Copyright (C) 2019 - 2022 Jonas Lochmann
|
* Copyright (C) 2019 - 2026 Jonas Lochmann
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU Affero General Public License as
|
* it under the terms of the GNU Affero General Public License as
|
||||||
@@ -18,7 +18,7 @@
|
|||||||
import { Conflict } from 'http-errors'
|
import { Conflict } from 'http-errors'
|
||||||
import { generateServerDataStatus } from '../sync/get-server-data-status'
|
import { generateServerDataStatus } from '../sync/get-server-data-status'
|
||||||
import { NewDeviceInfo, PlaintextParentPassword, assertPlaintextParentPasswordValid } from '../../api/schema'
|
import { NewDeviceInfo, PlaintextParentPassword, assertPlaintextParentPasswordValid } from '../../api/schema'
|
||||||
import { Database } from '../../database'
|
import { SimpleDatabase } from '../../database/simple'
|
||||||
import { maxMailNotificationFlags } from '../../database/user'
|
import { maxMailNotificationFlags } from '../../database/user'
|
||||||
import { EventHandler } from '../../monitoring/eventhandler'
|
import { EventHandler } from '../../monitoring/eventhandler'
|
||||||
import { ServerDataStatus } from '../../object/serverdatastatus'
|
import { ServerDataStatus } from '../../object/serverdatastatus'
|
||||||
@@ -33,7 +33,7 @@ export async function createFamily ({
|
|||||||
database, eventHandler, mailAuthToken, firstParentDevice,
|
database, eventHandler, mailAuthToken, firstParentDevice,
|
||||||
password, timeZone, parentName, deviceName, clientLevel
|
password, timeZone, parentName, deviceName, clientLevel
|
||||||
}: {
|
}: {
|
||||||
database: Database
|
database: SimpleDatabase
|
||||||
eventHandler: EventHandler
|
eventHandler: EventHandler
|
||||||
mailAuthToken: string
|
mailAuthToken: string
|
||||||
firstParentDevice: NewDeviceInfo
|
firstParentDevice: NewDeviceInfo
|
||||||
@@ -52,14 +52,14 @@ export async function createFamily ({
|
|||||||
|
|
||||||
return database.transaction(async (transaction) => {
|
return database.transaction(async (transaction) => {
|
||||||
const now = Date.now().toString(10)
|
const now = Date.now().toString(10)
|
||||||
const mailInfo = await requireMailAndLocaleByAuthToken({ database, mailAuthToken, transaction, invalidate: true })
|
const mailInfo = await requireMailAndLocaleByAuthToken({ transaction, mailAuthToken, invalidate: true })
|
||||||
|
|
||||||
// ensure that no family was created for this mail yet
|
// ensure that no family was created for this mail yet
|
||||||
const existingUserEntry = await database.user.findOne({
|
const existingUserEntry = await transaction.legacy.database.user.findOne({
|
||||||
where: {
|
where: {
|
||||||
mail: mailInfo.mail
|
mail: mailInfo.mail
|
||||||
},
|
},
|
||||||
transaction
|
transaction: transaction.legacy.transaction
|
||||||
})
|
})
|
||||||
|
|
||||||
if (existingUserEntry) {
|
if (existingUserEntry) {
|
||||||
@@ -72,7 +72,7 @@ export async function createFamily ({
|
|||||||
const deviceAuthToken = generateAuthToken()
|
const deviceAuthToken = generateAuthToken()
|
||||||
|
|
||||||
// create family
|
// create family
|
||||||
await database.family.create({
|
await transaction.legacy.database.family.create({
|
||||||
familyId,
|
familyId,
|
||||||
name: '',
|
name: '',
|
||||||
createdAt: now,
|
createdAt: now,
|
||||||
@@ -82,11 +82,12 @@ export async function createFamily ({
|
|||||||
fullVersionUntil: (Date.now() + 1000 * 60 * 60 * 24 * 14).toString(10),
|
fullVersionUntil: (Date.now() + 1000 * 60 * 60 * 24 * 14).toString(10),
|
||||||
hasFullVersion: true,
|
hasFullVersion: true,
|
||||||
nextServerKeyRequestSeq: '1',
|
nextServerKeyRequestSeq: '1',
|
||||||
u2fKeysVersion: generateVersionId()
|
u2fKeysVersion: generateVersionId(),
|
||||||
}, { transaction })
|
fullVersionDebts: '0'
|
||||||
|
}, { transaction: transaction.legacy.transaction })
|
||||||
|
|
||||||
// create parent user
|
// create parent user
|
||||||
await database.user.create({
|
await transaction.legacy.database.user.create({
|
||||||
familyId,
|
familyId,
|
||||||
userId,
|
userId,
|
||||||
name: parentName,
|
name: parentName,
|
||||||
@@ -103,10 +104,10 @@ export async function createFamily ({
|
|||||||
mailNotificationFlags: maxMailNotificationFlags,
|
mailNotificationFlags: maxMailNotificationFlags,
|
||||||
blockedTimes: '',
|
blockedTimes: '',
|
||||||
flags: '0'
|
flags: '0'
|
||||||
}, { transaction })
|
}, { transaction: transaction.legacy.transaction })
|
||||||
|
|
||||||
// add parent device
|
// add parent device
|
||||||
await database.device.create(prepareDeviceEntry({
|
await transaction.legacy.database.device.create(prepareDeviceEntry({
|
||||||
familyId,
|
familyId,
|
||||||
deviceId,
|
deviceId,
|
||||||
deviceName,
|
deviceName,
|
||||||
@@ -114,14 +115,13 @@ export async function createFamily ({
|
|||||||
userId,
|
userId,
|
||||||
deviceAuthToken,
|
deviceAuthToken,
|
||||||
isUserKeptSignedIn: true
|
isUserKeptSignedIn: true
|
||||||
}), { transaction })
|
}), { transaction: transaction.legacy.transaction })
|
||||||
|
|
||||||
const data = await generateServerDataStatus({
|
const data = await generateServerDataStatus({
|
||||||
database,
|
transaction,
|
||||||
clientStatus: createEmptyClientDataStatus({ clientLevel }),
|
clientStatus: createEmptyClientDataStatus({ clientLevel }),
|
||||||
familyId,
|
familyId,
|
||||||
deviceId,
|
deviceId,
|
||||||
transaction,
|
|
||||||
eventHandler
|
eventHandler
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* server component for the TimeLimit App
|
* server component for the TimeLimit App
|
||||||
* Copyright (C) 2019 - 2021 Jonas Lochmann
|
* Copyright (C) 2019 - 2026 Jonas Lochmann
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU Affero General Public License as
|
* it under the terms of the GNU Affero General Public License as
|
||||||
@@ -15,22 +15,22 @@
|
|||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { Database, Transaction } from '../../database'
|
import { SimpleDatabaseTransaction } from '../../database/simple'
|
||||||
import { StaticMessageException } from '../../exception'
|
import { StaticMessageException } from '../../exception'
|
||||||
import { requireMailAndLocaleByAuthToken } from '../authentication'
|
import { requireMailAndLocaleByAuthToken } from '../authentication'
|
||||||
|
|
||||||
const getStatusByMailAddress = async ({
|
const getStatusByMailAddress = async ({
|
||||||
mail, database, transaction
|
mail, transaction
|
||||||
}: { mail: string, database: Database, transaction: Transaction }) => {
|
}: { mail: string, transaction: SimpleDatabaseTransaction }) => {
|
||||||
if (!mail) {
|
if (!mail) {
|
||||||
throw new StaticMessageException({ staticMessage: 'getStatusByMailAddress: no mail address provided' })
|
throw new StaticMessageException({ staticMessage: 'getStatusByMailAddress: no mail address provided' })
|
||||||
}
|
}
|
||||||
|
|
||||||
const entry = await database.user.findOne({
|
const entry = await transaction.legacy.database.user.findOne({
|
||||||
where: {
|
where: {
|
||||||
mail
|
mail
|
||||||
},
|
},
|
||||||
transaction
|
transaction: transaction.legacy.transaction
|
||||||
})
|
})
|
||||||
|
|
||||||
if (entry) {
|
if (entry) {
|
||||||
@@ -41,12 +41,12 @@ const getStatusByMailAddress = async ({
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const getStatusByMailToken = async ({
|
export const getStatusByMailToken = async ({
|
||||||
mailAuthToken, database, transaction
|
mailAuthToken, transaction
|
||||||
}: { mailAuthToken: string, database: Database, transaction: Transaction }) => {
|
}: { mailAuthToken: string, transaction: SimpleDatabaseTransaction }) => {
|
||||||
const mailInfo = await requireMailAndLocaleByAuthToken({ mailAuthToken, database, transaction, invalidate: false })
|
const mailInfo = await requireMailAndLocaleByAuthToken({ mailAuthToken, transaction, invalidate: false })
|
||||||
const mail = mailInfo.mail
|
const mail = mailInfo.mail
|
||||||
|
|
||||||
const status = await getStatusByMailAddress({ mail, database, transaction })
|
const status = await getStatusByMailAddress({ mail, transaction })
|
||||||
|
|
||||||
return { mail, status }
|
return { mail, status }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* server component for the TimeLimit App
|
* server component for the TimeLimit App
|
||||||
* Copyright (C) 2019 - 2022 Jonas Lochmann
|
* Copyright (C) 2019 - 2026 Jonas Lochmann
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU Affero General Public License as
|
* it under the terms of the GNU Affero General Public License as
|
||||||
@@ -16,7 +16,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { Conflict, Unauthorized } from 'http-errors'
|
import { Conflict, Unauthorized } from 'http-errors'
|
||||||
import { Database } from '../../database'
|
import { SimpleDatabase } from '../../database/simple'
|
||||||
import { generateVersionId } from '../../util/token'
|
import { generateVersionId } from '../../util/token'
|
||||||
import { WebsocketApi } from '../../websocket'
|
import { WebsocketApi } from '../../websocket'
|
||||||
import { requireMailAndLocaleByAuthToken } from '../authentication'
|
import { requireMailAndLocaleByAuthToken } from '../authentication'
|
||||||
@@ -27,16 +27,16 @@ export const linkMailAddress = async ({ mailAuthToken, deviceAuthToken, parentUs
|
|||||||
deviceAuthToken: string
|
deviceAuthToken: string
|
||||||
parentUserId: string
|
parentUserId: string
|
||||||
parentPasswordSecondHash: string
|
parentPasswordSecondHash: string
|
||||||
database: Database
|
database: SimpleDatabase
|
||||||
websocket: WebsocketApi
|
websocket: WebsocketApi
|
||||||
// no transaction here because this is directly called from an API endpoint
|
// no transaction here because this is directly called from an API endpoint
|
||||||
}) => {
|
}) => {
|
||||||
await database.transaction(async (transaction) => {
|
await database.transaction(async (transaction) => {
|
||||||
const deviceEntry = await database.device.findOne({
|
const deviceEntry = await transaction.legacy.database.device.findOne({
|
||||||
where: {
|
where: {
|
||||||
deviceAuthToken
|
deviceAuthToken
|
||||||
},
|
},
|
||||||
transaction
|
transaction: transaction.legacy.transaction
|
||||||
})
|
})
|
||||||
|
|
||||||
if (!deviceEntry) {
|
if (!deviceEntry) {
|
||||||
@@ -45,26 +45,26 @@ export const linkMailAddress = async ({ mailAuthToken, deviceAuthToken, parentUs
|
|||||||
|
|
||||||
const familyId = deviceEntry.familyId
|
const familyId = deviceEntry.familyId
|
||||||
|
|
||||||
const mailInfo = await requireMailAndLocaleByAuthToken({ mailAuthToken, database, transaction, invalidate: true })
|
const mailInfo = await requireMailAndLocaleByAuthToken({ mailAuthToken, transaction, invalidate: true })
|
||||||
|
|
||||||
const exisitingUser = await database.user.findOne({
|
const exisitingUser = await transaction.legacy.database.user.findOne({
|
||||||
where: {
|
where: {
|
||||||
mail: mailInfo.mail
|
mail: mailInfo.mail
|
||||||
},
|
},
|
||||||
transaction
|
transaction: transaction.legacy.transaction
|
||||||
})
|
})
|
||||||
|
|
||||||
if (exisitingUser) {
|
if (exisitingUser) {
|
||||||
throw new Conflict()
|
throw new Conflict()
|
||||||
}
|
}
|
||||||
|
|
||||||
const parentEntry = await database.user.findOne({
|
const parentEntry = await transaction.legacy.database.user.findOne({
|
||||||
where: {
|
where: {
|
||||||
type: 'parent',
|
type: 'parent',
|
||||||
familyId,
|
familyId,
|
||||||
userId: parentUserId
|
userId: parentUserId
|
||||||
},
|
},
|
||||||
transaction
|
transaction: transaction.legacy.transaction
|
||||||
})
|
})
|
||||||
|
|
||||||
if (!parentEntry) {
|
if (!parentEntry) {
|
||||||
@@ -85,16 +85,16 @@ export const linkMailAddress = async ({ mailAuthToken, deviceAuthToken, parentUs
|
|||||||
|
|
||||||
parentEntry.mail = mailInfo.mail
|
parentEntry.mail = mailInfo.mail
|
||||||
|
|
||||||
await parentEntry.save({ transaction })
|
await parentEntry.save({ transaction: transaction.legacy.transaction })
|
||||||
|
|
||||||
// invalidiate client caches
|
// invalidiate client caches
|
||||||
await database.family.update({
|
await transaction.legacy.database.family.update({
|
||||||
userListVersion: generateVersionId()
|
userListVersion: generateVersionId()
|
||||||
}, {
|
}, {
|
||||||
where: {
|
where: {
|
||||||
familyId
|
familyId
|
||||||
},
|
},
|
||||||
transaction
|
transaction: transaction.legacy.transaction
|
||||||
})
|
})
|
||||||
|
|
||||||
// notify
|
// notify
|
||||||
@@ -103,9 +103,8 @@ export const linkMailAddress = async ({ mailAuthToken, deviceAuthToken, parentUs
|
|||||||
sourceDeviceId: null,
|
sourceDeviceId: null,
|
||||||
generalLevel: 1,
|
generalLevel: 1,
|
||||||
targetedLevels: new Map(),
|
targetedLevels: new Map(),
|
||||||
database,
|
transaction,
|
||||||
websocket,
|
websocket
|
||||||
transaction
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* server component for the TimeLimit App
|
* server component for the TimeLimit App
|
||||||
* Copyright (C) 2019 - 2022 Jonas Lochmann
|
* Copyright (C) 2019 - 2026 Jonas Lochmann
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU Affero General Public License as
|
* it under the terms of the GNU Affero General Public License as
|
||||||
@@ -17,7 +17,7 @@
|
|||||||
|
|
||||||
import { Conflict } from 'http-errors'
|
import { Conflict } from 'http-errors'
|
||||||
import { PlaintextParentPassword, assertPlaintextParentPasswordValid } from '../../api/schema'
|
import { PlaintextParentPassword, assertPlaintextParentPasswordValid } from '../../api/schema'
|
||||||
import { Database } from '../../database'
|
import { SimpleDatabase } from '../../database/simple'
|
||||||
import { sendPasswordRecoveryUsedMail } from '../../util/mail'
|
import { sendPasswordRecoveryUsedMail } from '../../util/mail'
|
||||||
import { generateVersionId } from '../../util/token'
|
import { generateVersionId } from '../../util/token'
|
||||||
import { WebsocketApi } from '../../websocket'
|
import { WebsocketApi } from '../../websocket'
|
||||||
@@ -25,7 +25,7 @@ import { requireMailAndLocaleByAuthToken } from '../authentication'
|
|||||||
import { notifyClientsAboutChangesDelayed } from '../websocket'
|
import { notifyClientsAboutChangesDelayed } from '../websocket'
|
||||||
|
|
||||||
export const recoverParentPassword = async ({ database, websocket, password, mailAuthToken }: {
|
export const recoverParentPassword = async ({ database, websocket, password, mailAuthToken }: {
|
||||||
database: Database
|
database: SimpleDatabase
|
||||||
websocket: WebsocketApi
|
websocket: WebsocketApi
|
||||||
password: PlaintextParentPassword
|
password: PlaintextParentPassword
|
||||||
mailAuthToken: string
|
mailAuthToken: string
|
||||||
@@ -34,14 +34,14 @@ export const recoverParentPassword = async ({ database, websocket, password, mai
|
|||||||
assertPlaintextParentPasswordValid(password)
|
assertPlaintextParentPasswordValid(password)
|
||||||
|
|
||||||
await database.transaction(async (transaction) => {
|
await database.transaction(async (transaction) => {
|
||||||
const mailInfo = await requireMailAndLocaleByAuthToken({ mailAuthToken, database, transaction, invalidate: true })
|
const mailInfo = await requireMailAndLocaleByAuthToken({ mailAuthToken, transaction, invalidate: true })
|
||||||
|
|
||||||
// update the user entry
|
// update the user entry
|
||||||
const userEntry = await database.user.findOne({
|
const userEntry = await transaction.legacy.database.user.findOne({
|
||||||
where: {
|
where: {
|
||||||
mail: mailInfo.mail
|
mail: mailInfo.mail
|
||||||
},
|
},
|
||||||
transaction
|
transaction: transaction.legacy.transaction
|
||||||
})
|
})
|
||||||
|
|
||||||
if (!userEntry) {
|
if (!userEntry) {
|
||||||
@@ -52,29 +52,28 @@ export const recoverParentPassword = async ({ database, websocket, password, mai
|
|||||||
userEntry.secondPasswordHash = password.secondHash
|
userEntry.secondPasswordHash = password.secondHash
|
||||||
userEntry.secondPasswordSalt = password.secondSalt
|
userEntry.secondPasswordSalt = password.secondSalt
|
||||||
|
|
||||||
await userEntry.save({ transaction })
|
await userEntry.save({ transaction: transaction.legacy.transaction })
|
||||||
|
|
||||||
// invalidate the user list
|
// invalidate the user list
|
||||||
await database.family.update({
|
await transaction.legacy.database.family.update({
|
||||||
userListVersion: generateVersionId()
|
userListVersion: generateVersionId()
|
||||||
}, {
|
}, {
|
||||||
where: {
|
where: {
|
||||||
familyId: userEntry.familyId
|
familyId: userEntry.familyId
|
||||||
},
|
},
|
||||||
transaction
|
transaction: transaction.legacy.transaction
|
||||||
})
|
})
|
||||||
|
|
||||||
await notifyClientsAboutChangesDelayed({
|
await notifyClientsAboutChangesDelayed({
|
||||||
database,
|
transaction,
|
||||||
familyId: userEntry.familyId,
|
familyId: userEntry.familyId,
|
||||||
websocket,
|
websocket,
|
||||||
generalLevel: 2,
|
generalLevel: 2,
|
||||||
targetedLevels: new Map(),
|
targetedLevels: new Map(),
|
||||||
sourceDeviceId: null,
|
sourceDeviceId: null
|
||||||
transaction
|
|
||||||
})
|
})
|
||||||
|
|
||||||
transaction.afterCommit(async () => {
|
transaction.enqueueAfterCommit(async () => {
|
||||||
await sendPasswordRecoveryUsedMail({
|
await sendPasswordRecoveryUsedMail({
|
||||||
receiver: mailInfo.mail,
|
receiver: mailInfo.mail,
|
||||||
locale: mailInfo.locale
|
locale: mailInfo.locale
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* server component for the TimeLimit App
|
* server component for the TimeLimit App
|
||||||
* Copyright (C) 2019 - 2022 Jonas Lochmann
|
* Copyright (C) 2019 - 2026 Jonas Lochmann
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU Affero General Public License as
|
* it under the terms of the GNU Affero General Public License as
|
||||||
@@ -17,7 +17,7 @@
|
|||||||
|
|
||||||
import { Conflict } from 'http-errors'
|
import { Conflict } from 'http-errors'
|
||||||
import { NewDeviceInfo } from '../../api/schema'
|
import { NewDeviceInfo } from '../../api/schema'
|
||||||
import { Database } from '../../database'
|
import { SimpleDatabase } from '../../database/simple'
|
||||||
import { sendDeviceLinkedMail } from '../../util/mail'
|
import { sendDeviceLinkedMail } from '../../util/mail'
|
||||||
import { generateAuthToken, generateIdWithinFamily, generateVersionId } from '../../util/token'
|
import { generateAuthToken, generateIdWithinFamily, generateVersionId } from '../../util/token'
|
||||||
import { WebsocketApi } from '../../websocket'
|
import { WebsocketApi } from '../../websocket'
|
||||||
@@ -30,7 +30,7 @@ import { ServerDataStatus } from '../../object/serverdatastatus'
|
|||||||
import { createEmptyClientDataStatus } from '../../object/clientdatastatus'
|
import { createEmptyClientDataStatus } from '../../object/clientdatastatus'
|
||||||
|
|
||||||
export const signInIntoFamily = async ({ database, eventHandler, mailAuthToken, newDeviceInfo, deviceName, websocket, clientLevel }: {
|
export const signInIntoFamily = async ({ database, eventHandler, mailAuthToken, newDeviceInfo, deviceName, websocket, clientLevel }: {
|
||||||
database: Database
|
database: SimpleDatabase
|
||||||
eventHandler: EventHandler
|
eventHandler: EventHandler
|
||||||
mailAuthToken: string
|
mailAuthToken: string
|
||||||
newDeviceInfo: NewDeviceInfo
|
newDeviceInfo: NewDeviceInfo
|
||||||
@@ -40,14 +40,14 @@ export const signInIntoFamily = async ({ database, eventHandler, mailAuthToken,
|
|||||||
// no transaction here because this is directly called from an API endpoint
|
// no transaction here because this is directly called from an API endpoint
|
||||||
}): Promise<{ deviceId: string; deviceAuthToken: string; data: ServerDataStatus }> => {
|
}): Promise<{ deviceId: string; deviceAuthToken: string; data: ServerDataStatus }> => {
|
||||||
return database.transaction(async (transaction) => {
|
return database.transaction(async (transaction) => {
|
||||||
const mailInfo = await requireMailAndLocaleByAuthToken({ database, mailAuthToken, transaction, invalidate: true })
|
const mailInfo = await requireMailAndLocaleByAuthToken({ mailAuthToken, transaction, invalidate: true })
|
||||||
|
|
||||||
const userEntryUnsafe = await database.user.findOne({
|
const userEntryUnsafe = await transaction.legacy.database.user.findOne({
|
||||||
where: {
|
where: {
|
||||||
mail: mailInfo.mail
|
mail: mailInfo.mail
|
||||||
},
|
},
|
||||||
attributes: ['familyId', 'userId'],
|
attributes: ['familyId', 'userId'],
|
||||||
transaction
|
transaction: transaction.legacy.transaction
|
||||||
})
|
})
|
||||||
|
|
||||||
if (!userEntryUnsafe) {
|
if (!userEntryUnsafe) {
|
||||||
@@ -62,7 +62,7 @@ export const signInIntoFamily = async ({ database, eventHandler, mailAuthToken,
|
|||||||
const deviceAuthToken = generateAuthToken()
|
const deviceAuthToken = generateAuthToken()
|
||||||
const deviceId = generateIdWithinFamily()
|
const deviceId = generateIdWithinFamily()
|
||||||
|
|
||||||
await database.device.create(prepareDeviceEntry({
|
await transaction.legacy.database.device.create(prepareDeviceEntry({
|
||||||
familyId: userEntry.familyId,
|
familyId: userEntry.familyId,
|
||||||
deviceId,
|
deviceId,
|
||||||
userId: userEntry.userId,
|
userId: userEntry.userId,
|
||||||
@@ -70,29 +70,28 @@ export const signInIntoFamily = async ({ database, eventHandler, mailAuthToken,
|
|||||||
deviceAuthToken,
|
deviceAuthToken,
|
||||||
newDeviceInfo,
|
newDeviceInfo,
|
||||||
isUserKeptSignedIn: true
|
isUserKeptSignedIn: true
|
||||||
}), { transaction })
|
}), { transaction: transaction.legacy.transaction })
|
||||||
|
|
||||||
// notify about changes
|
// notify about changes
|
||||||
await database.family.update({
|
await transaction.legacy.database.family.update({
|
||||||
deviceListVersion: generateVersionId()
|
deviceListVersion: generateVersionId()
|
||||||
}, {
|
}, {
|
||||||
where: {
|
where: {
|
||||||
familyId: userEntry.familyId
|
familyId: userEntry.familyId
|
||||||
},
|
},
|
||||||
transaction
|
transaction: transaction.legacy.transaction
|
||||||
})
|
})
|
||||||
|
|
||||||
await notifyClientsAboutChangesDelayed({
|
await notifyClientsAboutChangesDelayed({
|
||||||
familyId: userEntry.familyId,
|
familyId: userEntry.familyId,
|
||||||
websocket,
|
websocket,
|
||||||
database,
|
transaction,
|
||||||
generalLevel: 1,
|
generalLevel: 1,
|
||||||
targetedLevels: new Map(),
|
targetedLevels: new Map(),
|
||||||
sourceDeviceId: deviceId,
|
sourceDeviceId: deviceId
|
||||||
transaction
|
|
||||||
})
|
})
|
||||||
|
|
||||||
transaction.afterCommit(async () => {
|
transaction.enqueueAfterCommit(async () => {
|
||||||
await sendDeviceLinkedMail({
|
await sendDeviceLinkedMail({
|
||||||
receiver: mailInfo.mail,
|
receiver: mailInfo.mail,
|
||||||
locale: mailInfo.locale,
|
locale: mailInfo.locale,
|
||||||
@@ -101,11 +100,10 @@ export const signInIntoFamily = async ({ database, eventHandler, mailAuthToken,
|
|||||||
})
|
})
|
||||||
|
|
||||||
const data = await generateServerDataStatus({
|
const data = await generateServerDataStatus({
|
||||||
database,
|
transaction,
|
||||||
clientStatus: createEmptyClientDataStatus({ clientLevel }),
|
clientStatus: createEmptyClientDataStatus({ clientLevel }),
|
||||||
familyId: userEntry.familyId,
|
familyId: userEntry.familyId,
|
||||||
deviceId,
|
deviceId,
|
||||||
transaction,
|
|
||||||
eventHandler
|
eventHandler
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* server component for the TimeLimit App
|
* server component for the TimeLimit App
|
||||||
* Copyright (C) 2019 - 2022 Jonas Lochmann
|
* Copyright (C) 2019 - 2026 Jonas Lochmann
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU Affero General Public License as
|
* it under the terms of the GNU Affero General Public License as
|
||||||
@@ -16,40 +16,40 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { Conflict } from 'http-errors'
|
import { Conflict } from 'http-errors'
|
||||||
import { Database, Transaction } from '../../database'
|
import { SimpleDatabaseTransaction } from '../../database/simple'
|
||||||
import { notifyClientsAboutChangesDelayed } from '../../function/websocket'
|
import { notifyClientsAboutChangesDelayed } from '../../function/websocket'
|
||||||
import { WebsocketApi } from '../../websocket'
|
import { WebsocketApi } from '../../websocket'
|
||||||
|
|
||||||
const day = 1000 * 60 * 60 * 24
|
const day = 1000 * 60 * 60 * 24
|
||||||
|
const week = day * 7
|
||||||
const month = day * 31
|
const month = day * 31
|
||||||
const year = day * 366
|
const year = day * 366
|
||||||
|
|
||||||
export const addPurchase = async ({ database, familyId, type, service, transactionId, websocket, transaction }: {
|
export const addPurchase = async ({ familyId, type, service, transactionId, websocket, transaction }: {
|
||||||
database: Database
|
transaction: SimpleDatabaseTransaction
|
||||||
familyId: string
|
familyId: string
|
||||||
type: 'month' | 'year'
|
type: 'month' | 'year' | 'unpaid14'
|
||||||
service: 'googleplay' | 'directpurchase'
|
service: 'googleplay' | 'directpurchase'
|
||||||
transactionId: string
|
transactionId: string
|
||||||
websocket: WebsocketApi
|
websocket: WebsocketApi
|
||||||
transaction: Transaction
|
|
||||||
}) => {
|
}) => {
|
||||||
const oldPurchaseEntry = await database.purchase.findOne({
|
const oldPurchaseEntry = await transaction.legacy.database.purchase.findOne({
|
||||||
where: {
|
where: {
|
||||||
service,
|
service,
|
||||||
transactionId
|
transactionId
|
||||||
},
|
},
|
||||||
transaction
|
transaction: transaction.legacy.transaction
|
||||||
})
|
})
|
||||||
|
|
||||||
if (oldPurchaseEntry) {
|
if (oldPurchaseEntry) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
const familyEntry = await database.family.findOne({
|
const familyEntry = await transaction.legacy.database.family.findOne({
|
||||||
where: {
|
where: {
|
||||||
familyId
|
familyId
|
||||||
},
|
},
|
||||||
transaction
|
transaction: transaction.legacy.transaction
|
||||||
})
|
})
|
||||||
|
|
||||||
if (!familyEntry) {
|
if (!familyEntry) {
|
||||||
@@ -57,33 +57,63 @@ export const addPurchase = async ({ database, familyId, type, service, transacti
|
|||||||
}
|
}
|
||||||
|
|
||||||
const previousFullVersionEndTime = familyEntry.fullVersionUntil
|
const previousFullVersionEndTime = familyEntry.fullVersionUntil
|
||||||
|
const previousFullVersionDebts = parseInt(familyEntry.fullVersionDebts, 10)
|
||||||
|
|
||||||
const newFullVersionUntil = Math.max(parseInt(familyEntry.fullVersionUntil, 10), Date.now()) + (type === 'year' ? year : month)
|
if (type === 'month' || type === 'year') {
|
||||||
|
const typeDuration = type === 'year' ? year : month
|
||||||
|
|
||||||
familyEntry.fullVersionUntil = newFullVersionUntil.toString(10)
|
if (typeDuration > previousFullVersionDebts) {
|
||||||
familyEntry.hasFullVersion = true
|
const newFullVersionUntil = Math.max(parseInt(familyEntry.fullVersionUntil, 10), Date.now()) + typeDuration - previousFullVersionDebts
|
||||||
|
|
||||||
await familyEntry.save({ transaction })
|
familyEntry.fullVersionUntil = newFullVersionUntil.toString(10)
|
||||||
|
familyEntry.fullVersionDebts = '0'
|
||||||
|
familyEntry.hasFullVersion = true
|
||||||
|
} else {
|
||||||
|
familyEntry.fullVersionDebts = (previousFullVersionDebts - typeDuration).toString(10)
|
||||||
|
}
|
||||||
|
} else if (type === 'unpaid14') {
|
||||||
|
const debtsAdd = 2 * week
|
||||||
|
const debtsMax = 3 * week
|
||||||
|
|
||||||
await database.purchase.create({
|
const newDebts = Math.min(debtsMax, previousFullVersionDebts + debtsAdd)
|
||||||
|
|
||||||
|
if (newDebts <= previousFullVersionDebts) {
|
||||||
|
// do not save anything
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
const durationToAdd = newDebts - previousFullVersionDebts
|
||||||
|
|
||||||
|
const newFullVersionUntil = Math.max(parseInt(familyEntry.fullVersionUntil, 10), Date.now()) + durationToAdd
|
||||||
|
|
||||||
|
familyEntry.fullVersionUntil = newFullVersionUntil.toString(10)
|
||||||
|
familyEntry.fullVersionDebts = newDebts.toString(10)
|
||||||
|
familyEntry.hasFullVersion = true
|
||||||
|
} else {
|
||||||
|
throw new Error()
|
||||||
|
}
|
||||||
|
|
||||||
|
await familyEntry.save({ transaction: transaction.legacy.transaction })
|
||||||
|
|
||||||
|
await transaction.legacy.database.purchase.create({
|
||||||
familyId,
|
familyId,
|
||||||
service,
|
service,
|
||||||
transactionId,
|
transactionId,
|
||||||
type,
|
type,
|
||||||
loggedAt: Date.now().toString(10),
|
loggedAt: Date.now().toString(10),
|
||||||
previousFullVersionEndTime,
|
previousFullVersionEndTime,
|
||||||
newFullVersionEndTime: newFullVersionUntil.toString(10)
|
newFullVersionEndTime: familyEntry.fullVersionUntil
|
||||||
}, {
|
}, {
|
||||||
transaction
|
transaction: transaction.legacy.transaction
|
||||||
})
|
})
|
||||||
|
|
||||||
await notifyClientsAboutChangesDelayed({
|
await notifyClientsAboutChangesDelayed({
|
||||||
familyId,
|
familyId,
|
||||||
sourceDeviceId: null,
|
sourceDeviceId: null,
|
||||||
database,
|
transaction,
|
||||||
websocket,
|
websocket,
|
||||||
generalLevel: 2,
|
generalLevel: 2,
|
||||||
targetedLevels: new Map(),
|
targetedLevels: new Map()
|
||||||
transaction
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* server component for the TimeLimit App
|
* server component for the TimeLimit App
|
||||||
* Copyright (C) 2019 Jonas Lochmann
|
* Copyright (C) 2019 - 2026 Jonas Lochmann
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU Affero General Public License as
|
* it under the terms of the GNU Affero General Public License as
|
||||||
@@ -15,6 +15,9 @@
|
|||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
export const canDoNextPurchase = ({ fullVersionUntil }: {fullVersionUntil: number}) => (
|
export const canDoNextPurchase = ({ fullVersionUntil, fullVersionDebts }: {
|
||||||
fullVersionUntil < (Date.now() + 1000 * 60 * 60 * 24 * 31) // 31 days
|
fullVersionUntil: number
|
||||||
|
fullVersionDebts: number
|
||||||
|
}) => (
|
||||||
|
(fullVersionUntil - fullVersionDebts) < (Date.now() + 1000 * 60 * 60 * 24 * 31) // 31 days
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* server component for the TimeLimit App
|
* server component for the TimeLimit App
|
||||||
* Copyright (C) 2019 - 2020 Jonas Lochmann
|
* Copyright (C) 2019 - 2026 Jonas Lochmann
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU Affero General Public License as
|
* it under the terms of the GNU Affero General Public License as
|
||||||
@@ -16,19 +16,18 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { InternalServerError, Unauthorized } from 'http-errors'
|
import { InternalServerError, Unauthorized } from 'http-errors'
|
||||||
import { Database, Transaction } from '../../database'
|
import { SimpleDatabaseTransaction } from '../../database/simple'
|
||||||
|
|
||||||
export const requireFamilyEntry = async ({ database, deviceAuthToken, transaction }: {
|
export const requireFamilyEntry = async ({ transaction, deviceAuthToken }: {
|
||||||
database: Database
|
transaction: SimpleDatabaseTransaction
|
||||||
deviceAuthToken: string
|
deviceAuthToken: string
|
||||||
transaction: Transaction
|
|
||||||
}) => {
|
}) => {
|
||||||
const deviceEntryUnsafe = await database.device.findOne({
|
const deviceEntryUnsafe = await transaction.legacy.database.device.findOne({
|
||||||
where: {
|
where: {
|
||||||
deviceAuthToken
|
deviceAuthToken
|
||||||
},
|
},
|
||||||
attributes: ['familyId'],
|
attributes: ['familyId'],
|
||||||
transaction
|
transaction: transaction.legacy.transaction
|
||||||
})
|
})
|
||||||
|
|
||||||
if (!deviceEntryUnsafe) {
|
if (!deviceEntryUnsafe) {
|
||||||
@@ -39,12 +38,12 @@ export const requireFamilyEntry = async ({ database, deviceAuthToken, transactio
|
|||||||
familyId: deviceEntryUnsafe.familyId
|
familyId: deviceEntryUnsafe.familyId
|
||||||
}
|
}
|
||||||
|
|
||||||
const familyEntryUnsafe = await database.family.findOne({
|
const familyEntryUnsafe = await transaction.legacy.database.family.findOne({
|
||||||
where: {
|
where: {
|
||||||
familyId: deviceEntry.familyId
|
familyId: deviceEntry.familyId
|
||||||
},
|
},
|
||||||
attributes: ['fullVersionUntil'],
|
attributes: ['fullVersionUntil', 'fullVersionDebts'],
|
||||||
transaction
|
transaction: transaction.legacy.transaction
|
||||||
})
|
})
|
||||||
|
|
||||||
if (!familyEntryUnsafe) {
|
if (!familyEntryUnsafe) {
|
||||||
@@ -52,7 +51,8 @@ export const requireFamilyEntry = async ({ database, deviceAuthToken, transactio
|
|||||||
}
|
}
|
||||||
|
|
||||||
const familyEntry = {
|
const familyEntry = {
|
||||||
fullVersionUntil: familyEntryUnsafe.fullVersionUntil
|
fullVersionUntil: familyEntryUnsafe.fullVersionUntil,
|
||||||
|
fullVersionDebts: familyEntryUnsafe.fullVersionDebts,
|
||||||
}
|
}
|
||||||
|
|
||||||
return familyEntry
|
return familyEntry
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* server component for the TimeLimit App
|
* server component for the TimeLimit App
|
||||||
* Copyright (C) 2019 - 2020 Jonas Lochmann
|
* Copyright (C) 2019 - 2026 Jonas Lochmann
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU Affero General Public License as
|
* it under the terms of the GNU Affero General Public License as
|
||||||
@@ -15,37 +15,39 @@
|
|||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import * as Sequelize from 'sequelize'
|
import { SimpleDatabase, SimpleDatabaseTransaction } from '../../database/simple'
|
||||||
import { Database } from '../../database'
|
|
||||||
import { configItemIds } from '../../database/config'
|
import { configItemIds } from '../../database/config'
|
||||||
|
|
||||||
export const getStatusMessage = async ({ database, transaction }: {
|
export const getStatusMessage = async ({ transaction }: {
|
||||||
database: Database
|
transaction: SimpleDatabaseTransaction
|
||||||
transaction?: Sequelize.Transaction
|
|
||||||
}) => {
|
}) => {
|
||||||
const currentStatusMessageItem = await database.config.findByPk(configItemIds.statusMessage, { transaction })
|
const currentStatusMessageItem = await transaction.legacy.database.config.findByPk(
|
||||||
|
configItemIds.statusMessage,
|
||||||
|
{ transaction: transaction.legacy.transaction }
|
||||||
|
)
|
||||||
|
|
||||||
const currentStatusMessage = (currentStatusMessageItem ? currentStatusMessageItem.value : null) || ''
|
const currentStatusMessage = (currentStatusMessageItem ? currentStatusMessageItem.value : null) || ''
|
||||||
|
|
||||||
return currentStatusMessage
|
return currentStatusMessage
|
||||||
}
|
}
|
||||||
|
|
||||||
export const setStatusMessage = async ({ database, newStatusMessage }: {
|
export const setStatusMessage = async ({ database, newStatusMessage }: {
|
||||||
database: Database
|
database: SimpleDatabase
|
||||||
newStatusMessage: string
|
newStatusMessage: string
|
||||||
}) => {
|
}) => {
|
||||||
await database.transaction(async (transaction) => {
|
await database.transaction(async (transaction) => {
|
||||||
if (newStatusMessage === '') {
|
if (newStatusMessage === '') {
|
||||||
await database.config.destroy({
|
await transaction.legacy.database.config.destroy({
|
||||||
where: {
|
where: {
|
||||||
id: configItemIds.statusMessage
|
id: configItemIds.statusMessage
|
||||||
},
|
},
|
||||||
transaction
|
transaction: transaction.legacy.transaction
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
await database.config.upsert({
|
await transaction.legacy.database.config.upsert({
|
||||||
id: configItemIds.statusMessage,
|
id: configItemIds.statusMessage,
|
||||||
value: newStatusMessage
|
value: newStatusMessage
|
||||||
}, { transaction })
|
}, { transaction: transaction.legacy.transaction })
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* server component for the TimeLimit App
|
* server component for the TimeLimit App
|
||||||
* Copyright (C) 2019 - 2020 Jonas Lochmann
|
* Copyright (C) 2019 - 2026 Jonas Lochmann
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU Affero General Public License as
|
* it under the terms of the GNU Affero General Public License as
|
||||||
@@ -16,7 +16,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { Unauthorized } from 'http-errors'
|
import { Unauthorized } from 'http-errors'
|
||||||
import { Database, Transaction } from '../../../database'
|
import { SimpleDatabaseTransaction } from '../../../database/simple'
|
||||||
import { SourceFamilyNotFoundException } from './exception/illegal-state'
|
import { SourceFamilyNotFoundException } from './exception/illegal-state'
|
||||||
|
|
||||||
export interface ApplyActionBaseInfo {
|
export interface ApplyActionBaseInfo {
|
||||||
@@ -26,15 +26,14 @@ export interface ApplyActionBaseInfo {
|
|||||||
hasFullVersion: boolean
|
hasFullVersion: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getApplyActionBaseInfo ({ database, transaction, deviceAuthToken }: {
|
export async function getApplyActionBaseInfo ({ transaction, deviceAuthToken }: {
|
||||||
database: Database
|
transaction: SimpleDatabaseTransaction
|
||||||
transaction: Transaction
|
|
||||||
deviceAuthToken: string
|
deviceAuthToken: string
|
||||||
}): Promise<ApplyActionBaseInfo> {
|
}): Promise<ApplyActionBaseInfo> {
|
||||||
const deviceEntryUnsafe = await database.device.findOne({
|
const deviceEntryUnsafe = await transaction.legacy.database.device.findOne({
|
||||||
where: { deviceAuthToken },
|
where: { deviceAuthToken },
|
||||||
attributes: ['familyId', 'deviceId', 'nextSequenceNumber'],
|
attributes: ['familyId', 'deviceId', 'nextSequenceNumber'],
|
||||||
transaction
|
transaction: transaction.legacy.transaction
|
||||||
})
|
})
|
||||||
|
|
||||||
if (!deviceEntryUnsafe) {
|
if (!deviceEntryUnsafe) {
|
||||||
@@ -47,11 +46,11 @@ export async function getApplyActionBaseInfo ({ database, transaction, deviceAut
|
|||||||
nextSequenceNumber: deviceEntryUnsafe.nextSequenceNumber
|
nextSequenceNumber: deviceEntryUnsafe.nextSequenceNumber
|
||||||
}
|
}
|
||||||
|
|
||||||
const familyEntryUnsafe = await database.family.findOne({
|
const familyEntryUnsafe = await transaction.legacy.database.family.findOne({
|
||||||
where: {
|
where: {
|
||||||
familyId: deviceEntry.familyId
|
familyId: deviceEntry.familyId
|
||||||
},
|
},
|
||||||
transaction,
|
transaction: transaction.legacy.transaction,
|
||||||
attributes: ['hasFullVersion']
|
attributes: ['hasFullVersion']
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* server component for the TimeLimit App
|
* server component for the TimeLimit App
|
||||||
* Copyright (C) 2019 - 2022 Jonas Lochmann
|
* Copyright (C) 2019 - 2026 Jonas Lochmann
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU Affero General Public License as
|
* it under the terms of the GNU Affero General Public License as
|
||||||
@@ -19,7 +19,7 @@ import { memoize } from 'lodash'
|
|||||||
import * as Sequelize from 'sequelize'
|
import * as Sequelize from 'sequelize'
|
||||||
import { config } from '../../../config'
|
import { config } from '../../../config'
|
||||||
import { VisibleConnectedDevicesManager } from '../../../connected-devices'
|
import { VisibleConnectedDevicesManager } from '../../../connected-devices'
|
||||||
import { Database } from '../../../database'
|
import { SimpleDatabaseTransaction } from '../../../database/simple'
|
||||||
import { setToList } from '../../../util/list'
|
import { setToList } from '../../../util/list'
|
||||||
import { generateVersionId } from '../../../util/token'
|
import { generateVersionId } from '../../../util/token'
|
||||||
import { SourceUserNotFoundException } from './exception/illegal-state'
|
import { SourceUserNotFoundException } from './exception/illegal-state'
|
||||||
@@ -29,8 +29,7 @@ export class Cache {
|
|||||||
readonly familyId: string
|
readonly familyId: string
|
||||||
readonly deviceId: string
|
readonly deviceId: string
|
||||||
readonly hasFullVersion: boolean
|
readonly hasFullVersion: boolean
|
||||||
transaction: Sequelize.Transaction
|
transaction: SimpleDatabaseTransaction
|
||||||
readonly database: Database
|
|
||||||
readonly connectedDevicesManager: VisibleConnectedDevicesManager
|
readonly connectedDevicesManager: VisibleConnectedDevicesManager
|
||||||
private requireSenderDoFullSync = false
|
private requireSenderDoFullSync = false
|
||||||
|
|
||||||
@@ -48,18 +47,16 @@ export class Cache {
|
|||||||
triggeredSyncLevel: 0 | 1 | 2 = 0 // 0 = no, 1 = unimportant, 2 = important
|
triggeredSyncLevel: 0 | 1 | 2 = 0 // 0 = no, 1 = unimportant, 2 = important
|
||||||
targetedTriggeredSyncLevels = new Map<string, 0 | 1 | 2>()
|
targetedTriggeredSyncLevels = new Map<string, 0 | 1 | 2>()
|
||||||
|
|
||||||
constructor ({ familyId, deviceId, hasFullVersion, database, transaction, connectedDevicesManager }: {
|
constructor ({ familyId, deviceId, hasFullVersion, transaction, connectedDevicesManager }: {
|
||||||
familyId: string
|
familyId: string
|
||||||
deviceId: string
|
deviceId: string
|
||||||
hasFullVersion: boolean
|
hasFullVersion: boolean
|
||||||
database: Database
|
transaction: SimpleDatabaseTransaction
|
||||||
transaction: Sequelize.Transaction
|
|
||||||
connectedDevicesManager: VisibleConnectedDevicesManager
|
connectedDevicesManager: VisibleConnectedDevicesManager
|
||||||
}) {
|
}) {
|
||||||
this.familyId = familyId
|
this.familyId = familyId
|
||||||
this.deviceId = deviceId
|
this.deviceId = deviceId
|
||||||
this.hasFullVersion = hasFullVersion || config.alwaysPro
|
this.hasFullVersion = hasFullVersion || config.alwaysPro
|
||||||
this.database = database
|
|
||||||
this.transaction = transaction
|
this.transaction = transaction
|
||||||
this.connectedDevicesManager = connectedDevicesManager
|
this.connectedDevicesManager = connectedDevicesManager
|
||||||
}
|
}
|
||||||
@@ -77,7 +74,7 @@ export class Cache {
|
|||||||
async subtransaction<T> (callback: () => Promise<T>): Promise<T> {
|
async subtransaction<T> (callback: () => Promise<T>): Promise<T> {
|
||||||
const oldTransaction = this.transaction
|
const oldTransaction = this.transaction
|
||||||
|
|
||||||
return this.database.transaction(async (newTransaction) => {
|
return this.transaction.transaction(async (newTransaction) => {
|
||||||
try {
|
try {
|
||||||
this.transaction = newTransaction
|
this.transaction = newTransaction
|
||||||
|
|
||||||
@@ -87,18 +84,18 @@ export class Cache {
|
|||||||
} finally {
|
} finally {
|
||||||
this.transaction = oldTransaction
|
this.transaction = oldTransaction
|
||||||
}
|
}
|
||||||
}, { transaction: oldTransaction })
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
getSecondPasswordHashOfParent = memoize(async (parentId: string) => {
|
getSecondPasswordHashOfParent = memoize(async (parentId: string) => {
|
||||||
const userEntryUnsafe = await this.database.user.findOne({
|
const userEntryUnsafe = await this.transaction.legacy.database.user.findOne({
|
||||||
where: {
|
where: {
|
||||||
familyId: this.familyId,
|
familyId: this.familyId,
|
||||||
userId: parentId,
|
userId: parentId,
|
||||||
type: 'parent'
|
type: 'parent'
|
||||||
},
|
},
|
||||||
attributes: ['secondPasswordHash'],
|
attributes: ['secondPasswordHash'],
|
||||||
transaction: this.transaction
|
transaction: this.transaction.legacy.transaction
|
||||||
})
|
})
|
||||||
|
|
||||||
if (!userEntryUnsafe) {
|
if (!userEntryUnsafe) {
|
||||||
@@ -109,14 +106,14 @@ export class Cache {
|
|||||||
})
|
})
|
||||||
|
|
||||||
getSecondPasswordHashOfChild = memoize(async (childId: string) => {
|
getSecondPasswordHashOfChild = memoize(async (childId: string) => {
|
||||||
const userEntryUnsafe = await this.database.user.findOne({
|
const userEntryUnsafe = await this.transaction.legacy.database.user.findOne({
|
||||||
where: {
|
where: {
|
||||||
familyId: this.familyId,
|
familyId: this.familyId,
|
||||||
userId: childId,
|
userId: childId,
|
||||||
type: 'child'
|
type: 'child'
|
||||||
},
|
},
|
||||||
attributes: ['secondPasswordHash'],
|
attributes: ['secondPasswordHash'],
|
||||||
transaction: this.transaction
|
transaction: this.transaction.legacy.transaction
|
||||||
})
|
})
|
||||||
|
|
||||||
if (!userEntryUnsafe) {
|
if (!userEntryUnsafe) {
|
||||||
@@ -131,24 +128,24 @@ export class Cache {
|
|||||||
})
|
})
|
||||||
|
|
||||||
doesCategoryExist = memoize(async (categoryId: string) => {
|
doesCategoryExist = memoize(async (categoryId: string) => {
|
||||||
const categoryEntry = await this.database.category.findOne({
|
const categoryEntry = await this.transaction.legacy.database.category.findOne({
|
||||||
where: {
|
where: {
|
||||||
familyId: this.familyId,
|
familyId: this.familyId,
|
||||||
categoryId
|
categoryId
|
||||||
},
|
},
|
||||||
transaction: this.transaction
|
transaction: this.transaction.legacy.transaction
|
||||||
})
|
})
|
||||||
|
|
||||||
return !!categoryEntry
|
return !!categoryEntry
|
||||||
})
|
})
|
||||||
|
|
||||||
doesUserExist = memoize(async (userId: string) => {
|
doesUserExist = memoize(async (userId: string) => {
|
||||||
const userEntry = await this.database.user.findOne({
|
const userEntry = await this.transaction.legacy.database.user.findOne({
|
||||||
where: {
|
where: {
|
||||||
familyId: this.familyId,
|
familyId: this.familyId,
|
||||||
userId
|
userId
|
||||||
},
|
},
|
||||||
transaction: this.transaction
|
transaction: this.transaction.legacy.transaction
|
||||||
})
|
})
|
||||||
|
|
||||||
return !!userEntry
|
return !!userEntry
|
||||||
@@ -158,10 +155,10 @@ export class Cache {
|
|||||||
requireSenderFullSync: () => void = () => this.requireSenderDoFullSync = true
|
requireSenderFullSync: () => void = () => this.requireSenderDoFullSync = true
|
||||||
|
|
||||||
async saveModifiedVersionNumbers () {
|
async saveModifiedVersionNumbers () {
|
||||||
const { database, transaction, familyId } = this
|
const { familyId } = this
|
||||||
|
|
||||||
if (this.categoriesWithModifiedApps.size > 0) {
|
if (this.categoriesWithModifiedApps.size > 0) {
|
||||||
await database.category.update({
|
await this.transaction.legacy.database.category.update({
|
||||||
assignedAppsVersion: generateVersionId()
|
assignedAppsVersion: generateVersionId()
|
||||||
}, {
|
}, {
|
||||||
where: {
|
where: {
|
||||||
@@ -170,14 +167,14 @@ export class Cache {
|
|||||||
[Sequelize.Op.in]: setToList(this.categoriesWithModifiedApps)
|
[Sequelize.Op.in]: setToList(this.categoriesWithModifiedApps)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
transaction
|
transaction: this.transaction.legacy.transaction
|
||||||
})
|
})
|
||||||
|
|
||||||
this.categoriesWithModifiedApps.clear()
|
this.categoriesWithModifiedApps.clear()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.categoriesWithModifiedBaseData.size > 0) {
|
if (this.categoriesWithModifiedBaseData.size > 0) {
|
||||||
await database.category.update({
|
await this.transaction.legacy.database.category.update({
|
||||||
baseVersion: generateVersionId()
|
baseVersion: generateVersionId()
|
||||||
}, {
|
}, {
|
||||||
where: {
|
where: {
|
||||||
@@ -186,14 +183,14 @@ export class Cache {
|
|||||||
[Sequelize.Op.in]: setToList(this.categoriesWithModifiedBaseData)
|
[Sequelize.Op.in]: setToList(this.categoriesWithModifiedBaseData)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
transaction
|
transaction: this.transaction.legacy.transaction
|
||||||
})
|
})
|
||||||
|
|
||||||
this.categoriesWithModifiedBaseData.clear()
|
this.categoriesWithModifiedBaseData.clear()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.categoriesWithModifiedTimeLimitRules.size > 0) {
|
if (this.categoriesWithModifiedTimeLimitRules.size > 0) {
|
||||||
await database.category.update({
|
await this.transaction.legacy.database.category.update({
|
||||||
timeLimitRulesVersion: generateVersionId()
|
timeLimitRulesVersion: generateVersionId()
|
||||||
}, {
|
}, {
|
||||||
where: {
|
where: {
|
||||||
@@ -202,14 +199,14 @@ export class Cache {
|
|||||||
[Sequelize.Op.in]: setToList(this.categoriesWithModifiedTimeLimitRules)
|
[Sequelize.Op.in]: setToList(this.categoriesWithModifiedTimeLimitRules)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
transaction
|
transaction: this.transaction.legacy.transaction
|
||||||
})
|
})
|
||||||
|
|
||||||
this.categoriesWithModifiedTimeLimitRules.clear()
|
this.categoriesWithModifiedTimeLimitRules.clear()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.categoriesWithModifiedUsedTimes.size > 0) {
|
if (this.categoriesWithModifiedUsedTimes.size > 0) {
|
||||||
await database.category.update({
|
await this.transaction.legacy.database.category.update({
|
||||||
usedTimesVersion: generateVersionId()
|
usedTimesVersion: generateVersionId()
|
||||||
}, {
|
}, {
|
||||||
where: {
|
where: {
|
||||||
@@ -218,14 +215,14 @@ export class Cache {
|
|||||||
[Sequelize.Op.in]: setToList(this.categoriesWithModifiedUsedTimes)
|
[Sequelize.Op.in]: setToList(this.categoriesWithModifiedUsedTimes)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
transaction
|
transaction: this.transaction.legacy.transaction
|
||||||
})
|
})
|
||||||
|
|
||||||
this.categoriesWithModifiedUsedTimes.clear()
|
this.categoriesWithModifiedUsedTimes.clear()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.categoriesWithModifiedTasks.size > 0) {
|
if (this.categoriesWithModifiedTasks.size > 0) {
|
||||||
await database.category.update({
|
await this.transaction.legacy.database.category.update({
|
||||||
taskListVersion: generateVersionId()
|
taskListVersion: generateVersionId()
|
||||||
}, {
|
}, {
|
||||||
where: {
|
where: {
|
||||||
@@ -234,46 +231,46 @@ export class Cache {
|
|||||||
[Sequelize.Op.in]: setToList(this.categoriesWithModifiedTasks)
|
[Sequelize.Op.in]: setToList(this.categoriesWithModifiedTasks)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
transaction
|
transaction: this.transaction.legacy.transaction
|
||||||
})
|
})
|
||||||
|
|
||||||
this.categoriesWithModifiedUsedTimes.clear()
|
this.categoriesWithModifiedUsedTimes.clear()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.invalidiateUserList) {
|
if (this.invalidiateUserList) {
|
||||||
await database.family.update({
|
await this.transaction.legacy.database.family.update({
|
||||||
userListVersion: generateVersionId()
|
userListVersion: generateVersionId()
|
||||||
}, {
|
}, {
|
||||||
where: {
|
where: {
|
||||||
familyId: this.familyId
|
familyId: this.familyId
|
||||||
},
|
},
|
||||||
transaction
|
transaction: this.transaction.legacy.transaction
|
||||||
})
|
})
|
||||||
|
|
||||||
this.invalidiateUserList = false
|
this.invalidiateUserList = false
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.invalidiateDeviceList) {
|
if (this.invalidiateDeviceList) {
|
||||||
await database.family.update({
|
await this.transaction.legacy.database.family.update({
|
||||||
deviceListVersion: generateVersionId()
|
deviceListVersion: generateVersionId()
|
||||||
}, {
|
}, {
|
||||||
where: {
|
where: {
|
||||||
familyId: this.familyId
|
familyId: this.familyId
|
||||||
},
|
},
|
||||||
transaction
|
transaction: this.transaction.legacy.transaction
|
||||||
})
|
})
|
||||||
|
|
||||||
this.invalidiateDeviceList = false
|
this.invalidiateDeviceList = false
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.invalidateU2fList) {
|
if (this.invalidateU2fList) {
|
||||||
await database.family.update({
|
await this.transaction.legacy.database.family.update({
|
||||||
u2fKeysVersion: generateVersionId()
|
u2fKeysVersion: generateVersionId()
|
||||||
}, {
|
}, {
|
||||||
where: {
|
where: {
|
||||||
familyId: this.familyId
|
familyId: this.familyId
|
||||||
},
|
},
|
||||||
transaction
|
transaction: this.transaction.legacy.transaction
|
||||||
})
|
})
|
||||||
|
|
||||||
this.invalidateU2fList = false
|
this.invalidateU2fList = false
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* server component for the TimeLimit App
|
* server component for the TimeLimit App
|
||||||
* Copyright (C) 2019 - 2022 Jonas Lochmann
|
* Copyright (C) 2019 - 2026 Jonas Lochmann
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU Affero General Public License as
|
* it under the terms of the GNU Affero General Public License as
|
||||||
@@ -37,12 +37,12 @@ export async function dispatchAddUsedTime ({ action, cache }: {
|
|||||||
}) {
|
}) {
|
||||||
const roundedTimestamp = getRoundedTimestamp().toString(10)
|
const roundedTimestamp = getRoundedTimestamp().toString(10)
|
||||||
|
|
||||||
const categoryEntryUnsafe = await cache.database.category.findOne({
|
const categoryEntryUnsafe = await cache.transaction.legacy.database.category.findOne({
|
||||||
where: {
|
where: {
|
||||||
familyId: cache.familyId,
|
familyId: cache.familyId,
|
||||||
categoryId: action.categoryId
|
categoryId: action.categoryId
|
||||||
},
|
},
|
||||||
transaction: cache.transaction,
|
transaction: cache.transaction.legacy.transaction,
|
||||||
attributes: [
|
attributes: [
|
||||||
'childId',
|
'childId',
|
||||||
'parentCategoryId',
|
'parentCategoryId',
|
||||||
@@ -65,7 +65,7 @@ export async function dispatchAddUsedTime ({ action, cache }: {
|
|||||||
currentExtraTime: number
|
currentExtraTime: number
|
||||||
}) => {
|
}) => {
|
||||||
if (action.timeToAdd !== 0) {
|
if (action.timeToAdd !== 0) {
|
||||||
const oldItem = await cache.database.usedTime.findOne({
|
const oldItem = await cache.transaction.legacy.database.usedTime.findOne({
|
||||||
where: {
|
where: {
|
||||||
familyId: cache.familyId,
|
familyId: cache.familyId,
|
||||||
categoryId: action.categoryId,
|
categoryId: action.categoryId,
|
||||||
@@ -73,7 +73,7 @@ export async function dispatchAddUsedTime ({ action, cache }: {
|
|||||||
startMinuteOfDay: MinuteOfDay.MIN,
|
startMinuteOfDay: MinuteOfDay.MIN,
|
||||||
endMinuteOfDay: MinuteOfDay.MAX
|
endMinuteOfDay: MinuteOfDay.MAX
|
||||||
},
|
},
|
||||||
transaction: cache.transaction
|
transaction: cache.transaction.legacy.transaction
|
||||||
})
|
})
|
||||||
|
|
||||||
if (oldItem) {
|
if (oldItem) {
|
||||||
@@ -84,7 +84,7 @@ export async function dispatchAddUsedTime ({ action, cache }: {
|
|||||||
const newLastUpdate = parseInt(roundedTimestamp, 10)
|
const newLastUpdate = parseInt(roundedTimestamp, 10)
|
||||||
|
|
||||||
if (oldUsedTime !== newUsedTime || oldLastUpdate !== newLastUpdate) {
|
if (oldUsedTime !== newUsedTime || oldLastUpdate !== newLastUpdate) {
|
||||||
const [updatedRows] = await cache.database.usedTime.update({
|
const [updatedRows] = await cache.transaction.legacy.database.usedTime.update({
|
||||||
usedTime: newUsedTime,
|
usedTime: newUsedTime,
|
||||||
lastUpdate: newLastUpdate.toString(10)
|
lastUpdate: newLastUpdate.toString(10)
|
||||||
}, {
|
}, {
|
||||||
@@ -95,7 +95,7 @@ export async function dispatchAddUsedTime ({ action, cache }: {
|
|||||||
startMinuteOfDay: MinuteOfDay.MIN,
|
startMinuteOfDay: MinuteOfDay.MIN,
|
||||||
endMinuteOfDay: MinuteOfDay.MAX
|
endMinuteOfDay: MinuteOfDay.MAX
|
||||||
},
|
},
|
||||||
transaction: cache.transaction
|
transaction: cache.transaction.legacy.transaction
|
||||||
})
|
})
|
||||||
|
|
||||||
if (updatedRows === 0) {
|
if (updatedRows === 0) {
|
||||||
@@ -103,7 +103,7 @@ export async function dispatchAddUsedTime ({ action, cache }: {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
await cache.database.usedTime.create({
|
await cache.transaction.legacy.database.usedTime.create({
|
||||||
familyId: cache.familyId,
|
familyId: cache.familyId,
|
||||||
categoryId: action.categoryId,
|
categoryId: action.categoryId,
|
||||||
dayOfEpoch: action.dayOfEpoch,
|
dayOfEpoch: action.dayOfEpoch,
|
||||||
@@ -112,20 +112,20 @@ export async function dispatchAddUsedTime ({ action, cache }: {
|
|||||||
startMinuteOfDay: MinuteOfDay.MIN,
|
startMinuteOfDay: MinuteOfDay.MIN,
|
||||||
endMinuteOfDay: MinuteOfDay.MAX
|
endMinuteOfDay: MinuteOfDay.MAX
|
||||||
}, {
|
}, {
|
||||||
transaction: cache.transaction
|
transaction: cache.transaction.legacy.transaction
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (action.extraTimeToSubtract !== 0) {
|
if (action.extraTimeToSubtract !== 0) {
|
||||||
await cache.database.category.update({
|
await cache.transaction.legacy.database.category.update({
|
||||||
extraTimeInMillis: Math.max(0, currentExtraTime - action.extraTimeToSubtract)
|
extraTimeInMillis: Math.max(0, currentExtraTime - action.extraTimeToSubtract)
|
||||||
}, {
|
}, {
|
||||||
where: {
|
where: {
|
||||||
familyId: cache.familyId,
|
familyId: cache.familyId,
|
||||||
categoryId: categoryId
|
categoryId: categoryId
|
||||||
},
|
},
|
||||||
transaction: cache.transaction
|
transaction: cache.transaction.legacy.transaction
|
||||||
})
|
})
|
||||||
|
|
||||||
cache.categoriesWithModifiedBaseData.add(categoryId)
|
cache.categoriesWithModifiedBaseData.add(categoryId)
|
||||||
@@ -140,13 +140,13 @@ export async function dispatchAddUsedTime ({ action, cache }: {
|
|||||||
})
|
})
|
||||||
|
|
||||||
if (categoryEntry.parentCategoryId !== '') {
|
if (categoryEntry.parentCategoryId !== '') {
|
||||||
const parentCategoryEntry = await cache.database.category.findOne({
|
const parentCategoryEntry = await cache.transaction.legacy.database.category.findOne({
|
||||||
where: {
|
where: {
|
||||||
familyId: cache.familyId,
|
familyId: cache.familyId,
|
||||||
categoryId: categoryEntry.parentCategoryId,
|
categoryId: categoryEntry.parentCategoryId,
|
||||||
childId: categoryEntry.childId
|
childId: categoryEntry.childId
|
||||||
},
|
},
|
||||||
transaction: cache.transaction
|
transaction: cache.transaction.legacy.transaction
|
||||||
})
|
})
|
||||||
|
|
||||||
if (parentCategoryEntry) {
|
if (parentCategoryEntry) {
|
||||||
|
|||||||
@@ -37,13 +37,13 @@ export async function dispatchAddUsedTimeVersion2 ({ deviceId, action, cache, ev
|
|||||||
cache: Cache
|
cache: Cache
|
||||||
eventHandler: EventHandler
|
eventHandler: EventHandler
|
||||||
}) {
|
}) {
|
||||||
const deviceEntryUnsafe = await cache.database.device.findOne({
|
const deviceEntryUnsafe = await cache.transaction.legacy.database.device.findOne({
|
||||||
where: {
|
where: {
|
||||||
familyId: cache.familyId,
|
familyId: cache.familyId,
|
||||||
deviceId: deviceId
|
deviceId: deviceId
|
||||||
},
|
},
|
||||||
attributes: ['currentUserId'],
|
attributes: ['currentUserId'],
|
||||||
transaction: cache.transaction
|
transaction: cache.transaction.legacy.transaction
|
||||||
})
|
})
|
||||||
|
|
||||||
if (!deviceEntryUnsafe) {
|
if (!deviceEntryUnsafe) {
|
||||||
@@ -60,12 +60,12 @@ export async function dispatchAddUsedTimeVersion2 ({ deviceId, action, cache, ev
|
|||||||
let addUsedTimeForADifferentUserThanTheCurrentUserOfTheDevice = false
|
let addUsedTimeForADifferentUserThanTheCurrentUserOfTheDevice = false
|
||||||
|
|
||||||
for (const item of action.items) {
|
for (const item of action.items) {
|
||||||
const categoryEntryUnsafe = await cache.database.category.findOne({
|
const categoryEntryUnsafe = await cache.transaction.legacy.database.category.findOne({
|
||||||
where: {
|
where: {
|
||||||
familyId: cache.familyId,
|
familyId: cache.familyId,
|
||||||
categoryId: item.categoryId
|
categoryId: item.categoryId
|
||||||
},
|
},
|
||||||
transaction: cache.transaction,
|
transaction: cache.transaction.legacy.transaction,
|
||||||
attributes: [
|
attributes: [
|
||||||
'childId',
|
'childId',
|
||||||
'extraTimeInMillis'
|
'extraTimeInMillis'
|
||||||
@@ -93,7 +93,7 @@ export async function dispatchAddUsedTimeVersion2 ({ deviceId, action, cache, ev
|
|||||||
const lengthInMinutes = (end - start) + 1
|
const lengthInMinutes = (end - start) + 1
|
||||||
const lengthInMs = lengthInMinutes * 1000 * 60
|
const lengthInMs = lengthInMinutes * 1000 * 60
|
||||||
|
|
||||||
const oldItem = await cache.database.usedTime.findOne({
|
const oldItem = await cache.transaction.legacy.database.usedTime.findOne({
|
||||||
where: {
|
where: {
|
||||||
familyId: cache.familyId,
|
familyId: cache.familyId,
|
||||||
categoryId: item.categoryId,
|
categoryId: item.categoryId,
|
||||||
@@ -101,7 +101,7 @@ export async function dispatchAddUsedTimeVersion2 ({ deviceId, action, cache, ev
|
|||||||
startMinuteOfDay: start,
|
startMinuteOfDay: start,
|
||||||
endMinuteOfDay: end
|
endMinuteOfDay: end
|
||||||
},
|
},
|
||||||
transaction: cache.transaction
|
transaction: cache.transaction.legacy.transaction
|
||||||
})
|
})
|
||||||
|
|
||||||
if (oldItem) {
|
if (oldItem) {
|
||||||
@@ -112,7 +112,7 @@ export async function dispatchAddUsedTimeVersion2 ({ deviceId, action, cache, ev
|
|||||||
const newLastUpdate = parseInt(roundedTimestampForUsedTime, 10)
|
const newLastUpdate = parseInt(roundedTimestampForUsedTime, 10)
|
||||||
|
|
||||||
if (oldUsedTime !== newUsedTime || oldLastUpdate !== newLastUpdate) {
|
if (oldUsedTime !== newUsedTime || oldLastUpdate !== newLastUpdate) {
|
||||||
const [updatedRows] = await cache.database.usedTime.update({
|
const [updatedRows] = await cache.transaction.legacy.database.usedTime.update({
|
||||||
usedTime: newUsedTime,
|
usedTime: newUsedTime,
|
||||||
lastUpdate: newLastUpdate.toString(10)
|
lastUpdate: newLastUpdate.toString(10)
|
||||||
}, {
|
}, {
|
||||||
@@ -123,7 +123,7 @@ export async function dispatchAddUsedTimeVersion2 ({ deviceId, action, cache, ev
|
|||||||
startMinuteOfDay: start,
|
startMinuteOfDay: start,
|
||||||
endMinuteOfDay: end
|
endMinuteOfDay: end
|
||||||
},
|
},
|
||||||
transaction: cache.transaction
|
transaction: cache.transaction.legacy.transaction
|
||||||
})
|
})
|
||||||
|
|
||||||
if (updatedRows === 0) {
|
if (updatedRows === 0) {
|
||||||
@@ -131,7 +131,7 @@ export async function dispatchAddUsedTimeVersion2 ({ deviceId, action, cache, ev
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
const oldTime: number | null = await cache.database.usedTime.aggregate(
|
const oldTime: number | null = await cache.transaction.legacy.database.usedTime.aggregate(
|
||||||
'usedTime',
|
'usedTime',
|
||||||
'MAX',
|
'MAX',
|
||||||
{
|
{
|
||||||
@@ -146,13 +146,13 @@ export async function dispatchAddUsedTimeVersion2 ({ deviceId, action, cache, ev
|
|||||||
[Sequelize.Op.lte]: end
|
[Sequelize.Op.lte]: end
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
transaction: cache.transaction
|
transaction: cache.transaction.legacy.transaction
|
||||||
}
|
}
|
||||||
) || 0
|
) || 0
|
||||||
|
|
||||||
if (oldTime !== null && typeof oldTime !== 'number') throw new Error()
|
if (oldTime !== null && typeof oldTime !== 'number') throw new Error()
|
||||||
|
|
||||||
await cache.database.usedTime.create({
|
await cache.transaction.legacy.database.usedTime.create({
|
||||||
familyId: cache.familyId,
|
familyId: cache.familyId,
|
||||||
categoryId: item.categoryId,
|
categoryId: item.categoryId,
|
||||||
dayOfEpoch: action.dayOfEpoch,
|
dayOfEpoch: action.dayOfEpoch,
|
||||||
@@ -161,7 +161,7 @@ export async function dispatchAddUsedTimeVersion2 ({ deviceId, action, cache, ev
|
|||||||
startMinuteOfDay: start,
|
startMinuteOfDay: start,
|
||||||
endMinuteOfDay: end
|
endMinuteOfDay: end
|
||||||
}, {
|
}, {
|
||||||
transaction: cache.transaction
|
transaction: cache.transaction.legacy.transaction
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -179,7 +179,7 @@ export async function dispatchAddUsedTimeVersion2 ({ deviceId, action, cache, ev
|
|||||||
for (let j = 0; j < item.sessionDurationLimits.length; j++) {
|
for (let j = 0; j < item.sessionDurationLimits.length; j++) {
|
||||||
const limit = item.sessionDurationLimits[j]
|
const limit = item.sessionDurationLimits[j]
|
||||||
|
|
||||||
const oldItem = await cache.database.sessionDuration.findOne({
|
const oldItem = await cache.transaction.legacy.database.sessionDuration.findOne({
|
||||||
where: {
|
where: {
|
||||||
familyId: cache.familyId,
|
familyId: cache.familyId,
|
||||||
categoryId: item.categoryId,
|
categoryId: item.categoryId,
|
||||||
@@ -188,11 +188,11 @@ export async function dispatchAddUsedTimeVersion2 ({ deviceId, action, cache, ev
|
|||||||
startMinuteOfDay: limit.start,
|
startMinuteOfDay: limit.start,
|
||||||
endMinuteOfDay: limit.end
|
endMinuteOfDay: limit.end
|
||||||
},
|
},
|
||||||
transaction: cache.transaction
|
transaction: cache.transaction.legacy.transaction
|
||||||
})
|
})
|
||||||
|
|
||||||
const oldDuration: () => Promise<number> = async () => {
|
const oldDuration: () => Promise<number> = async () => {
|
||||||
const fittingDurationItems = await cache.database.sessionDuration.findAll({
|
const fittingDurationItems = await cache.transaction.legacy.database.sessionDuration.findAll({
|
||||||
where: {
|
where: {
|
||||||
familyId: cache.familyId,
|
familyId: cache.familyId,
|
||||||
categoryId: item.categoryId,
|
categoryId: item.categoryId,
|
||||||
@@ -209,7 +209,7 @@ export async function dispatchAddUsedTimeVersion2 ({ deviceId, action, cache, ev
|
|||||||
[Sequelize.Op.lte]: limit.pause
|
[Sequelize.Op.lte]: limit.pause
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
transaction: cache.transaction
|
transaction: cache.transaction.legacy.transaction
|
||||||
})
|
})
|
||||||
|
|
||||||
const fittingDurationItemsLastUsageFiltered =
|
const fittingDurationItemsLastUsageFiltered =
|
||||||
@@ -259,9 +259,9 @@ export async function dispatchAddUsedTimeVersion2 ({ deviceId, action, cache, ev
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
await oldItem.save({ transaction: cache.transaction })
|
await oldItem.save({ transaction: cache.transaction.legacy.transaction })
|
||||||
} else {
|
} else {
|
||||||
await cache.database.sessionDuration.create({
|
await cache.transaction.legacy.database.sessionDuration.create({
|
||||||
familyId: cache.familyId,
|
familyId: cache.familyId,
|
||||||
categoryId: item.categoryId,
|
categoryId: item.categoryId,
|
||||||
maxSessionDuration: limit.duration,
|
maxSessionDuration: limit.duration,
|
||||||
@@ -272,21 +272,21 @@ export async function dispatchAddUsedTimeVersion2 ({ deviceId, action, cache, ev
|
|||||||
lastUsage: action.trustedTimestamp.toString(10),
|
lastUsage: action.trustedTimestamp.toString(10),
|
||||||
lastSessionDuration: await oldDuration() + item.timeToAdd,
|
lastSessionDuration: await oldDuration() + item.timeToAdd,
|
||||||
roundedLastUpdate: roundedTimestampForSessionDuration
|
roundedLastUpdate: roundedTimestampForSessionDuration
|
||||||
}, { transaction: cache.transaction })
|
}, { transaction: cache.transaction.legacy.transaction })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
cache.categoriesWithModifiedUsedTimes.add(item.categoryId)
|
cache.categoriesWithModifiedUsedTimes.add(item.categoryId)
|
||||||
|
|
||||||
if (item.extraTimeToSubtract !== 0) {
|
if (item.extraTimeToSubtract !== 0) {
|
||||||
await cache.database.category.update({
|
await cache.transaction.legacy.database.category.update({
|
||||||
extraTimeInMillis: Math.max(0, categoryEntry.extraTimeInMillis - item.extraTimeToSubtract)
|
extraTimeInMillis: Math.max(0, categoryEntry.extraTimeInMillis - item.extraTimeToSubtract)
|
||||||
}, {
|
}, {
|
||||||
where: {
|
where: {
|
||||||
familyId: cache.familyId,
|
familyId: cache.familyId,
|
||||||
categoryId: item.categoryId
|
categoryId: item.categoryId
|
||||||
},
|
},
|
||||||
transaction: cache.transaction
|
transaction: cache.transaction.legacy.transaction
|
||||||
})
|
})
|
||||||
|
|
||||||
cache.categoriesWithModifiedBaseData.add(item.categoryId)
|
cache.categoriesWithModifiedBaseData.add(item.categoryId)
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* server component for the TimeLimit App
|
* server component for the TimeLimit App
|
||||||
* Copyright (C) 2019 - 2022 Jonas Lochmann
|
* Copyright (C) 2019 - 2026 Jonas Lochmann
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU Affero General Public License as
|
* it under the terms of the GNU Affero General Public License as
|
||||||
@@ -23,13 +23,13 @@ export async function dispatchFinishKeyRequestAction ({ action, cache, deviceId
|
|||||||
action: FinishKeyRequestAction
|
action: FinishKeyRequestAction
|
||||||
cache: Cache
|
cache: Cache
|
||||||
}) {
|
}) {
|
||||||
await cache.database.keyRequest.destroy({
|
await cache.transaction.legacy.database.keyRequest.destroy({
|
||||||
where: {
|
where: {
|
||||||
familyId: cache.familyId,
|
familyId: cache.familyId,
|
||||||
senderDeviceId: deviceId,
|
senderDeviceId: deviceId,
|
||||||
senderSequenceNumber: action.deviceSequenceNumber.toString(10)
|
senderSequenceNumber: action.deviceSequenceNumber.toString(10)
|
||||||
},
|
},
|
||||||
transaction: cache.transaction
|
transaction: cache.transaction.legacy.transaction
|
||||||
})
|
})
|
||||||
|
|
||||||
// no sync triggered
|
// no sync triggered
|
||||||
|
|||||||
+13
-13
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* server component for the TimeLimit App
|
* server component for the TimeLimit App
|
||||||
* Copyright (C) 2019 - 2022 Jonas Lochmann
|
* Copyright (C) 2019 - 2026 Jonas Lochmann
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU Affero General Public License as
|
* it under the terms of the GNU Affero General Public License as
|
||||||
@@ -26,12 +26,12 @@ export async function dispatchMarkTaskPendingAction ({ action, cache, deviceId }
|
|||||||
action: MarkTaskPendingAction
|
action: MarkTaskPendingAction
|
||||||
cache: Cache
|
cache: Cache
|
||||||
}) {
|
}) {
|
||||||
const taskInfoUnsafe = await cache.database.childTask.findOne({
|
const taskInfoUnsafe = await cache.transaction.legacy.database.childTask.findOne({
|
||||||
where: {
|
where: {
|
||||||
familyId: cache.familyId,
|
familyId: cache.familyId,
|
||||||
taskId: action.taskId
|
taskId: action.taskId
|
||||||
},
|
},
|
||||||
transaction: cache.transaction,
|
transaction: cache.transaction.legacy.transaction,
|
||||||
attributes: ['categoryId', 'pendingRequest', 'taskTitle']
|
attributes: ['categoryId', 'pendingRequest', 'taskTitle']
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -45,13 +45,13 @@ export async function dispatchMarkTaskPendingAction ({ action, cache, deviceId }
|
|||||||
|
|
||||||
if (taskInfo.pendingRequest !== 0) return // review already requested
|
if (taskInfo.pendingRequest !== 0) return // review already requested
|
||||||
|
|
||||||
const categoryInfoUnsafe = await cache.database.category.findOne({
|
const categoryInfoUnsafe = await cache.transaction.legacy.database.category.findOne({
|
||||||
where: {
|
where: {
|
||||||
familyId: cache.familyId,
|
familyId: cache.familyId,
|
||||||
categoryId: taskInfo.categoryId
|
categoryId: taskInfo.categoryId
|
||||||
},
|
},
|
||||||
attributes: ['childId'],
|
attributes: ['childId'],
|
||||||
transaction: cache.transaction
|
transaction: cache.transaction.legacy.transaction
|
||||||
})
|
})
|
||||||
|
|
||||||
if (categoryInfoUnsafe === null) {
|
if (categoryInfoUnsafe === null) {
|
||||||
@@ -60,13 +60,13 @@ export async function dispatchMarkTaskPendingAction ({ action, cache, deviceId }
|
|||||||
|
|
||||||
const categoryInfo = { childId: categoryInfoUnsafe.childId }
|
const categoryInfo = { childId: categoryInfoUnsafe.childId }
|
||||||
|
|
||||||
const deviceInfoUnsafe = await cache.database.device.findOne({
|
const deviceInfoUnsafe = await cache.transaction.legacy.database.device.findOne({
|
||||||
where: {
|
where: {
|
||||||
familyId: cache.familyId,
|
familyId: cache.familyId,
|
||||||
deviceId
|
deviceId
|
||||||
},
|
},
|
||||||
attributes: ['currentUserId'],
|
attributes: ['currentUserId'],
|
||||||
transaction: cache.transaction
|
transaction: cache.transaction.legacy.transaction
|
||||||
})
|
})
|
||||||
|
|
||||||
if (deviceInfoUnsafe === null) throw new SourceDeviceNotFoundException()
|
if (deviceInfoUnsafe === null) throw new SourceDeviceNotFoundException()
|
||||||
@@ -77,33 +77,33 @@ export async function dispatchMarkTaskPendingAction ({ action, cache, deviceId }
|
|||||||
throw new IllegalStateException({ staticMessage: 'Can not mark task pending for other user than the current user' })
|
throw new IllegalStateException({ staticMessage: 'Can not mark task pending for other user than the current user' })
|
||||||
}
|
}
|
||||||
|
|
||||||
const childInfoUnsafe = await cache.database.user.findOne({
|
const childInfoUnsafe = await cache.transaction.legacy.database.user.findOne({
|
||||||
where: {
|
where: {
|
||||||
familyId: cache.familyId,
|
familyId: cache.familyId,
|
||||||
userId: categoryInfo.childId
|
userId: categoryInfo.childId
|
||||||
},
|
},
|
||||||
attributes: ['name'],
|
attributes: ['name'],
|
||||||
transaction: cache.transaction
|
transaction: cache.transaction.legacy.transaction
|
||||||
})
|
})
|
||||||
|
|
||||||
if (childInfoUnsafe === null) throw new SourceUserNotFoundException()
|
if (childInfoUnsafe === null) throw new SourceUserNotFoundException()
|
||||||
|
|
||||||
const childInfo = { name: childInfoUnsafe.name }
|
const childInfo = { name: childInfoUnsafe.name }
|
||||||
|
|
||||||
await cache.database.childTask.update({ pendingRequest: 1 }, {
|
await cache.transaction.legacy.database.childTask.update({ pendingRequest: 1 }, {
|
||||||
where: {
|
where: {
|
||||||
familyId: cache.familyId,
|
familyId: cache.familyId,
|
||||||
taskId: action.taskId
|
taskId: action.taskId
|
||||||
},
|
},
|
||||||
transaction: cache.transaction
|
transaction: cache.transaction.legacy.transaction
|
||||||
})
|
})
|
||||||
|
|
||||||
cache.categoriesWithModifiedTasks.add(taskInfo.categoryId)
|
cache.categoriesWithModifiedTasks.add(taskInfo.categoryId)
|
||||||
cache.incrementTriggeredSyncLevel(1) // parents are not faster reachable
|
cache.incrementTriggeredSyncLevel(1) // parents are not faster reachable
|
||||||
|
|
||||||
await sendTaskDoneMails({
|
await sendTaskDoneMails({
|
||||||
database: cache.database,
|
database: cache.transaction.legacy.database,
|
||||||
transaction: cache.transaction,
|
transaction: cache.transaction.legacy.transaction,
|
||||||
familyId: cache.familyId,
|
familyId: cache.familyId,
|
||||||
childName: childInfo.name,
|
childName: childInfo.name,
|
||||||
taskTitle: taskInfo.taskTitle
|
taskTitle: taskInfo.taskTitle
|
||||||
|
|||||||
@@ -33,25 +33,25 @@ export async function dispatchPingAction ({ action, cache, deviceId }: {
|
|||||||
else throw new Error()
|
else throw new Error()
|
||||||
|
|
||||||
// delete any previous ping/pong
|
// delete any previous ping/pong
|
||||||
await cache.database.ping.destroy({
|
await cache.transaction.legacy.database.ping.destroy({
|
||||||
where: {
|
where: {
|
||||||
familyId: cache.familyId,
|
familyId: cache.familyId,
|
||||||
receiverDeviceId: action.deviceId,
|
receiverDeviceId: action.deviceId,
|
||||||
senderDeviceId: deviceId,
|
senderDeviceId: deviceId,
|
||||||
type: type
|
type: type
|
||||||
},
|
},
|
||||||
transaction: cache.transaction
|
transaction: cache.transaction.legacy.transaction
|
||||||
})
|
})
|
||||||
|
|
||||||
// insert
|
// insert
|
||||||
await cache.database.ping.create({
|
await cache.transaction.legacy.database.ping.create({
|
||||||
familyId: cache.familyId,
|
familyId: cache.familyId,
|
||||||
receiverDeviceId: action.deviceId,
|
receiverDeviceId: action.deviceId,
|
||||||
senderDeviceId: deviceId,
|
senderDeviceId: deviceId,
|
||||||
type,
|
type,
|
||||||
token: action.token
|
token: action.token
|
||||||
}, {
|
}, {
|
||||||
transaction: cache.transaction
|
transaction: cache.transaction.legacy.transaction
|
||||||
})
|
})
|
||||||
|
|
||||||
// notify
|
// notify
|
||||||
@@ -60,14 +60,14 @@ export async function dispatchPingAction ({ action, cache, deviceId }: {
|
|||||||
|
|
||||||
// handle deleting
|
// handle deleting
|
||||||
if (action.event === 'pong' || action.event === 'clear') {
|
if (action.event === 'pong' || action.event === 'clear') {
|
||||||
await cache.database.ping.destroy({
|
await cache.transaction.legacy.database.ping.destroy({
|
||||||
where: {
|
where: {
|
||||||
familyId: cache.familyId,
|
familyId: cache.familyId,
|
||||||
receiverDeviceId: deviceId,
|
receiverDeviceId: deviceId,
|
||||||
senderDeviceId: action.deviceId,
|
senderDeviceId: action.deviceId,
|
||||||
token: action.token
|
token: action.token
|
||||||
},
|
},
|
||||||
transaction: cache.transaction
|
transaction: cache.transaction.legacy.transaction
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* server component for the TimeLimit App
|
* server component for the TimeLimit App
|
||||||
* Copyright (C) 2019 - 2022 Jonas Lochmann
|
* Copyright (C) 2019 - 2026 Jonas Lochmann
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU Affero General Public License as
|
* it under the terms of the GNU Affero General Public License as
|
||||||
@@ -26,13 +26,13 @@ export async function dispatchReplyToKeyRequestAction ({ deviceId, action, cache
|
|||||||
cache: Cache
|
cache: Cache
|
||||||
eventHandler: EventHandler
|
eventHandler: EventHandler
|
||||||
}) {
|
}) {
|
||||||
const requestUnsafe = await cache.database.keyRequest.findOne({
|
const requestUnsafe = await cache.transaction.legacy.database.keyRequest.findOne({
|
||||||
where: {
|
where: {
|
||||||
familyId: cache.familyId,
|
familyId: cache.familyId,
|
||||||
serverSequenceNumber: action.requestServerSequenceNumber.toString(10)
|
serverSequenceNumber: action.requestServerSequenceNumber.toString(10)
|
||||||
},
|
},
|
||||||
attributes: ['senderDeviceId', 'senderSequenceNumber'],
|
attributes: ['senderDeviceId', 'senderSequenceNumber'],
|
||||||
transaction: cache.transaction
|
transaction: cache.transaction.legacy.transaction
|
||||||
})
|
})
|
||||||
|
|
||||||
if (!requestUnsafe) {
|
if (!requestUnsafe) {
|
||||||
@@ -46,14 +46,14 @@ export async function dispatchReplyToKeyRequestAction ({ deviceId, action, cache
|
|||||||
senderSequenceNumber: requestUnsafe.senderSequenceNumber
|
senderSequenceNumber: requestUnsafe.senderSequenceNumber
|
||||||
}
|
}
|
||||||
|
|
||||||
const oldReplyCounter = await cache.database.keyResponse.count({
|
const oldReplyCounter = await cache.transaction.legacy.database.keyResponse.count({
|
||||||
where: {
|
where: {
|
||||||
familyId: cache.familyId,
|
familyId: cache.familyId,
|
||||||
receiverDeviceId: request.senderDeviceId,
|
receiverDeviceId: request.senderDeviceId,
|
||||||
requestServerSequenceNumber: action.requestServerSequenceNumber.toString(10),
|
requestServerSequenceNumber: action.requestServerSequenceNumber.toString(10),
|
||||||
senderDeviceId: deviceId
|
senderDeviceId: deviceId
|
||||||
},
|
},
|
||||||
transaction: cache.transaction
|
transaction: cache.transaction.legacy.transaction
|
||||||
})
|
})
|
||||||
|
|
||||||
if (oldReplyCounter !== 0) {
|
if (oldReplyCounter !== 0) {
|
||||||
@@ -62,12 +62,12 @@ export async function dispatchReplyToKeyRequestAction ({ deviceId, action, cache
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
const deviceEntryUnsafe = await cache.database.device.findOne({
|
const deviceEntryUnsafe = await cache.transaction.legacy.database.device.findOne({
|
||||||
where: {
|
where: {
|
||||||
familyId: cache.familyId,
|
familyId: cache.familyId,
|
||||||
deviceId: request.senderDeviceId
|
deviceId: request.senderDeviceId
|
||||||
},
|
},
|
||||||
transaction: cache.transaction,
|
transaction: cache.transaction.legacy.transaction,
|
||||||
attributes: ['nextKeyReplySequenceNumber']
|
attributes: ['nextKeyReplySequenceNumber']
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -81,17 +81,17 @@ export async function dispatchReplyToKeyRequestAction ({ deviceId, action, cache
|
|||||||
nextKeyReplySequenceNumber: deviceEntryUnsafe.nextKeyReplySequenceNumber
|
nextKeyReplySequenceNumber: deviceEntryUnsafe.nextKeyReplySequenceNumber
|
||||||
}
|
}
|
||||||
|
|
||||||
await cache.database.device.update({
|
await cache.transaction.legacy.database.device.update({
|
||||||
nextKeyReplySequenceNumber: (parseInt(deviceEntry.nextKeyReplySequenceNumber) + 1).toString(10)
|
nextKeyReplySequenceNumber: (parseInt(deviceEntry.nextKeyReplySequenceNumber) + 1).toString(10)
|
||||||
}, {
|
}, {
|
||||||
where: {
|
where: {
|
||||||
familyId: cache.familyId,
|
familyId: cache.familyId,
|
||||||
deviceId: request.senderDeviceId
|
deviceId: request.senderDeviceId
|
||||||
},
|
},
|
||||||
transaction: cache.transaction
|
transaction: cache.transaction.legacy.transaction
|
||||||
})
|
})
|
||||||
|
|
||||||
await cache.database.keyResponse.create({
|
await cache.transaction.legacy.database.keyResponse.create({
|
||||||
familyId: cache.familyId,
|
familyId: cache.familyId,
|
||||||
receiverDeviceId: request.senderDeviceId,
|
receiverDeviceId: request.senderDeviceId,
|
||||||
requestServerSequenceNumber: action.requestServerSequenceNumber.toString(10),
|
requestServerSequenceNumber: action.requestServerSequenceNumber.toString(10),
|
||||||
@@ -102,7 +102,7 @@ export async function dispatchReplyToKeyRequestAction ({ deviceId, action, cache
|
|||||||
encryptedKey: action.encryptedKey,
|
encryptedKey: action.encryptedKey,
|
||||||
signature: action.signature
|
signature: action.signature
|
||||||
}, {
|
}, {
|
||||||
transaction: cache.transaction
|
transaction: cache.transaction.legacy.transaction
|
||||||
})
|
})
|
||||||
|
|
||||||
cache.incrementTargetedTriggeredSyncLevel(request.senderDeviceId, 2)
|
cache.incrementTargetedTriggeredSyncLevel(request.senderDeviceId, 2)
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* server component for the TimeLimit App
|
* server component for the TimeLimit App
|
||||||
* Copyright (C) 2019 - 2022 Jonas Lochmann
|
* Copyright (C) 2019 - 2026 Jonas Lochmann
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU Affero General Public License as
|
* it under the terms of the GNU Affero General Public License as
|
||||||
@@ -24,11 +24,11 @@ export async function dispatchSendKeyRequestAction ({ action, cache, deviceId }:
|
|||||||
action: SendKeyRequestAction
|
action: SendKeyRequestAction
|
||||||
cache: Cache
|
cache: Cache
|
||||||
}) {
|
}) {
|
||||||
const familyEntryUnsafe = await cache.database.family.findOne({
|
const familyEntryUnsafe = await cache.transaction.legacy.database.family.findOne({
|
||||||
where: {
|
where: {
|
||||||
familyId: cache.familyId
|
familyId: cache.familyId
|
||||||
},
|
},
|
||||||
transaction: cache.transaction,
|
transaction: cache.transaction.legacy.transaction,
|
||||||
attributes: ['nextServerKeyRequestSeq']
|
attributes: ['nextServerKeyRequestSeq']
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -38,16 +38,16 @@ export async function dispatchSendKeyRequestAction ({ action, cache, deviceId }:
|
|||||||
|
|
||||||
const serverSequenceNumber = familyEntryUnsafe.nextServerKeyRequestSeq
|
const serverSequenceNumber = familyEntryUnsafe.nextServerKeyRequestSeq
|
||||||
|
|
||||||
await cache.database.family.update({
|
await cache.transaction.legacy.database.family.update({
|
||||||
nextServerKeyRequestSeq: (parseInt(serverSequenceNumber, 10) + 1).toString(10)
|
nextServerKeyRequestSeq: (parseInt(serverSequenceNumber, 10) + 1).toString(10)
|
||||||
}, {
|
}, {
|
||||||
where: {
|
where: {
|
||||||
familyId: cache.familyId
|
familyId: cache.familyId
|
||||||
},
|
},
|
||||||
transaction: cache.transaction
|
transaction: cache.transaction.legacy.transaction
|
||||||
})
|
})
|
||||||
|
|
||||||
await cache.database.keyRequest.destroy({
|
await cache.transaction.legacy.database.keyRequest.destroy({
|
||||||
where: {
|
where: {
|
||||||
familyId: cache.familyId,
|
familyId: cache.familyId,
|
||||||
senderDeviceId: deviceId,
|
senderDeviceId: deviceId,
|
||||||
@@ -55,10 +55,10 @@ export async function dispatchSendKeyRequestAction ({ action, cache, deviceId }:
|
|||||||
deviceId: action.deviceId || null,
|
deviceId: action.deviceId || null,
|
||||||
categoryId: action.categoryId || null
|
categoryId: action.categoryId || null
|
||||||
},
|
},
|
||||||
transaction: cache.transaction
|
transaction: cache.transaction.legacy.transaction
|
||||||
})
|
})
|
||||||
|
|
||||||
await cache.database.keyRequest.create({
|
await cache.transaction.legacy.database.keyRequest.create({
|
||||||
familyId: cache.familyId,
|
familyId: cache.familyId,
|
||||||
serverSequenceNumber: serverSequenceNumber,
|
serverSequenceNumber: serverSequenceNumber,
|
||||||
senderDeviceId: deviceId,
|
senderDeviceId: deviceId,
|
||||||
@@ -69,7 +69,7 @@ export async function dispatchSendKeyRequestAction ({ action, cache, deviceId }:
|
|||||||
tempKey: action.tempKey,
|
tempKey: action.tempKey,
|
||||||
signature: action.signature
|
signature: action.signature
|
||||||
}, {
|
}, {
|
||||||
transaction: cache.transaction
|
transaction: cache.transaction.legacy.transaction
|
||||||
})
|
})
|
||||||
|
|
||||||
cache.incrementTriggeredSyncLevel(2)
|
cache.incrementTriggeredSyncLevel(2)
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* server component for the TimeLimit App
|
* server component for the TimeLimit App
|
||||||
* Copyright (C) 2019 - 2022 Jonas Lochmann
|
* Copyright (C) 2019 - 2026 Jonas Lochmann
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU Affero General Public License as
|
* it under the terms of the GNU Affero General Public License as
|
||||||
@@ -30,12 +30,12 @@ export async function dispatchSignOutAtDevice ({ deviceId, cache }: {
|
|||||||
throw new PremiumVersionMissingException()
|
throw new PremiumVersionMissingException()
|
||||||
}
|
}
|
||||||
|
|
||||||
const deviceEntry = await cache.database.device.findOne({
|
const deviceEntry = await cache.transaction.legacy.database.device.findOne({
|
||||||
where: {
|
where: {
|
||||||
familyId: cache.familyId,
|
familyId: cache.familyId,
|
||||||
deviceId
|
deviceId
|
||||||
},
|
},
|
||||||
transaction: cache.transaction
|
transaction: cache.transaction.legacy.transaction
|
||||||
})
|
})
|
||||||
|
|
||||||
if (!deviceEntry) {
|
if (!deviceEntry) {
|
||||||
|
|||||||
+4
-5
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* server component for the TimeLimit App
|
* server component for the TimeLimit App
|
||||||
* Copyright (C) 2019 - 2022 Jonas Lochmann
|
* Copyright (C) 2019 - 2026 Jonas Lochmann
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU Affero General Public License as
|
* it under the terms of the GNU Affero General Public License as
|
||||||
@@ -26,12 +26,12 @@ export async function dispatchTriedDisablingDeviceAdmin ({ deviceId, cache }: {
|
|||||||
action: TriedDisablingDeviceAdminAction
|
action: TriedDisablingDeviceAdminAction
|
||||||
cache: Cache
|
cache: Cache
|
||||||
}) {
|
}) {
|
||||||
const deviceEntry = await cache.database.device.findOne({
|
const deviceEntry = await cache.transaction.legacy.database.device.findOne({
|
||||||
where: {
|
where: {
|
||||||
familyId: cache.familyId,
|
familyId: cache.familyId,
|
||||||
deviceId
|
deviceId
|
||||||
},
|
},
|
||||||
transaction: cache.transaction
|
transaction: cache.transaction.legacy.transaction
|
||||||
})
|
})
|
||||||
|
|
||||||
if (deviceEntry === null) {
|
if (deviceEntry === null) {
|
||||||
@@ -43,7 +43,7 @@ export async function dispatchTriedDisablingDeviceAdmin ({ deviceId, cache }: {
|
|||||||
if (!deviceEntry.triedDisablingDeviceAdmin) {
|
if (!deviceEntry.triedDisablingDeviceAdmin) {
|
||||||
deviceEntry.triedDisablingDeviceAdmin = true
|
deviceEntry.triedDisablingDeviceAdmin = true
|
||||||
|
|
||||||
await deviceEntry.save({ transaction: cache.transaction })
|
await deviceEntry.save({ transaction: cache.transaction.legacy.transaction })
|
||||||
|
|
||||||
cache.invalidiateDeviceList = true
|
cache.invalidiateDeviceList = true
|
||||||
cache.incrementTriggeredSyncLevel(1)
|
cache.incrementTriggeredSyncLevel(1)
|
||||||
@@ -51,7 +51,6 @@ export async function dispatchTriedDisablingDeviceAdmin ({ deviceId, cache }: {
|
|||||||
|
|
||||||
if (!hadManipulationBefore) {
|
if (!hadManipulationBefore) {
|
||||||
await sendManipulationWarnings({
|
await sendManipulationWarnings({
|
||||||
database: cache.database,
|
|
||||||
transaction: cache.transaction,
|
transaction: cache.transaction,
|
||||||
deviceName: deviceEntry.name,
|
deviceName: deviceEntry.name,
|
||||||
familyId: cache.familyId
|
familyId: cache.familyId
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* server component for the TimeLimit App
|
* server component for the TimeLimit App
|
||||||
* Copyright (C) 2019 - 2023 Jonas Lochmann
|
* Copyright (C) 2019 - 2026 Jonas Lochmann
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU Affero General Public License as
|
* it under the terms of the GNU Affero General Public License as
|
||||||
@@ -30,12 +30,12 @@ export async function dispatchUpdateDeviceStatus ({ deviceId, action, cache }: {
|
|||||||
action: UpdateDeviceStatusAction
|
action: UpdateDeviceStatusAction
|
||||||
cache: Cache
|
cache: Cache
|
||||||
}) {
|
}) {
|
||||||
const deviceEntry = await cache.database.device.findOne({
|
const deviceEntry = await cache.transaction.legacy.database.device.findOne({
|
||||||
where: {
|
where: {
|
||||||
familyId: cache.familyId,
|
familyId: cache.familyId,
|
||||||
deviceId
|
deviceId
|
||||||
},
|
},
|
||||||
transaction: cache.transaction
|
transaction: cache.transaction.legacy.transaction
|
||||||
})
|
})
|
||||||
|
|
||||||
if (!deviceEntry) {
|
if (!deviceEntry) {
|
||||||
@@ -175,12 +175,11 @@ export async function dispatchUpdateDeviceStatus ({ deviceId, action, cache }: {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
await deviceEntry.save({ transaction: cache.transaction })
|
await deviceEntry.save({ transaction: cache.transaction.legacy.transaction })
|
||||||
|
|
||||||
if (hasDeviceManipulation(deviceEntry)) {
|
if (hasDeviceManipulation(deviceEntry)) {
|
||||||
if (!hadManipulationBefore) {
|
if (!hadManipulationBefore) {
|
||||||
await sendManipulationWarnings({
|
await sendManipulationWarnings({
|
||||||
database: cache.database,
|
|
||||||
transaction: cache.transaction,
|
transaction: cache.transaction,
|
||||||
deviceName: deviceEntry.name,
|
deviceName: deviceEntry.name,
|
||||||
familyId: cache.familyId
|
familyId: cache.familyId
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* server component for the TimeLimit App
|
* server component for the TimeLimit App
|
||||||
* Copyright (C) 2019 - 2022 Jonas Lochmann
|
* Copyright (C) 2019 - 2026 Jonas Lochmann
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU Affero General Public License as
|
* it under the terms of the GNU Affero General Public License as
|
||||||
@@ -26,13 +26,13 @@ export async function dispatchUpdateInstalledApps ({ deviceId, action, cache }:
|
|||||||
cache: Cache
|
cache: Cache
|
||||||
}) {
|
}) {
|
||||||
async function upsert({ type, data }: { type: number, data: Buffer }) {
|
async function upsert({ type, data }: { type: number, data: Buffer }) {
|
||||||
await cache.database.encryptedAppList.upsert({
|
await cache.transaction.legacy.database.encryptedAppList.upsert({
|
||||||
familyId: cache.familyId,
|
familyId: cache.familyId,
|
||||||
deviceId,
|
deviceId,
|
||||||
type,
|
type,
|
||||||
version: generateVersionId(),
|
version: generateVersionId(),
|
||||||
data
|
data
|
||||||
}, { transaction: cache.transaction })
|
}, { transaction: cache.transaction.legacy.transaction })
|
||||||
}
|
}
|
||||||
|
|
||||||
if (action.base) {
|
if (action.base) {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* server component for the TimeLimit App
|
* server component for the TimeLimit App
|
||||||
* Copyright (C) 2019 - 2022 Jonas Lochmann
|
* Copyright (C) 2019 - 2026 Jonas Lochmann
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU Affero General Public License as
|
* it under the terms of the GNU Affero General Public License as
|
||||||
@@ -26,12 +26,12 @@ export async function dispatchUploadDevicePublicKeyAction ({ deviceId, action, c
|
|||||||
cache: Cache
|
cache: Cache
|
||||||
eventHandler: EventHandler
|
eventHandler: EventHandler
|
||||||
}) {
|
}) {
|
||||||
const deviceEntry = await cache.database.device.findOne({
|
const deviceEntry = await cache.transaction.legacy.database.device.findOne({
|
||||||
where: {
|
where: {
|
||||||
familyId: cache.familyId,
|
familyId: cache.familyId,
|
||||||
deviceId
|
deviceId
|
||||||
},
|
},
|
||||||
transaction: cache.transaction
|
transaction: cache.transaction.legacy.transaction
|
||||||
})
|
})
|
||||||
|
|
||||||
if (deviceEntry === null) {
|
if (deviceEntry === null) {
|
||||||
@@ -39,7 +39,7 @@ export async function dispatchUploadDevicePublicKeyAction ({ deviceId, action, c
|
|||||||
} else if (deviceEntry.publicKey === null) {
|
} else if (deviceEntry.publicKey === null) {
|
||||||
deviceEntry.publicKey = action.key
|
deviceEntry.publicKey = action.key
|
||||||
|
|
||||||
await deviceEntry.save({ transaction: cache.transaction })
|
await deviceEntry.save({ transaction: cache.transaction.legacy.transaction })
|
||||||
|
|
||||||
cache.invalidiateDeviceList = true
|
cache.invalidiateDeviceList = true
|
||||||
cache.incrementTriggeredSyncLevel(2)
|
cache.incrementTriggeredSyncLevel(2)
|
||||||
|
|||||||
@@ -25,13 +25,13 @@ export const dispatchChildChangePassword = async ({ action, childUserId, cache }
|
|||||||
childUserId: string
|
childUserId: string
|
||||||
cache: Cache
|
cache: Cache
|
||||||
}) => {
|
}) => {
|
||||||
const childEntry = await cache.database.user.findOne({
|
const childEntry = await cache.transaction.legacy.database.user.findOne({
|
||||||
where: {
|
where: {
|
||||||
familyId: cache.familyId,
|
familyId: cache.familyId,
|
||||||
userId: childUserId,
|
userId: childUserId,
|
||||||
type: 'child'
|
type: 'child'
|
||||||
},
|
},
|
||||||
transaction: cache.transaction
|
transaction: cache.transaction.legacy.transaction
|
||||||
})
|
})
|
||||||
|
|
||||||
if (!childEntry) {
|
if (!childEntry) {
|
||||||
@@ -44,7 +44,7 @@ export const dispatchChildChangePassword = async ({ action, childUserId, cache }
|
|||||||
childEntry.secondPasswordSalt = newPassword.secondSalt
|
childEntry.secondPasswordSalt = newPassword.secondSalt
|
||||||
childEntry.secondPasswordHash = newPassword.secondHash
|
childEntry.secondPasswordHash = newPassword.secondHash
|
||||||
|
|
||||||
await childEntry.save({ transaction: cache.transaction })
|
await childEntry.save({ transaction: cache.transaction.legacy.transaction })
|
||||||
|
|
||||||
{
|
{
|
||||||
const clear = cache.getSecondPasswordHashOfChild.cache.clear
|
const clear = cache.getSecondPasswordHashOfChild.cache.clear
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* server component for the TimeLimit App
|
* server component for the TimeLimit App
|
||||||
* Copyright (C) 2019 - 2022 Jonas Lochmann
|
* Copyright (C) 2019 - 2026 Jonas Lochmann
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU Affero General Public License as
|
* it under the terms of the GNU Affero General Public License as
|
||||||
@@ -39,13 +39,13 @@ export const dispatchChildSignIn = async ({ deviceId, childUserId, cache }: {
|
|||||||
cache
|
cache
|
||||||
})
|
})
|
||||||
|
|
||||||
const userEntryUnsafe = await cache.database.user.findOne({
|
const userEntryUnsafe = await cache.transaction.legacy.database.user.findOne({
|
||||||
where: {
|
where: {
|
||||||
familyId: cache.familyId,
|
familyId: cache.familyId,
|
||||||
type: 'child',
|
type: 'child',
|
||||||
userId: childUserId
|
userId: childUserId
|
||||||
},
|
},
|
||||||
transaction: cache.transaction,
|
transaction: cache.transaction.legacy.transaction,
|
||||||
attributes: [
|
attributes: [
|
||||||
'currentDevice'
|
'currentDevice'
|
||||||
]
|
]
|
||||||
@@ -58,7 +58,7 @@ export const dispatchChildSignIn = async ({ deviceId, childUserId, cache }: {
|
|||||||
if (userEntryUnsafe.currentDevice === deviceId) {
|
if (userEntryUnsafe.currentDevice === deviceId) {
|
||||||
// unassign to prevent way aroundprimary device rule
|
// unassign to prevent way aroundprimary device rule
|
||||||
|
|
||||||
await cache.database.user.update({
|
await cache.transaction.legacy.database.user.update({
|
||||||
currentDevice: ''
|
currentDevice: ''
|
||||||
}, {
|
}, {
|
||||||
where: {
|
where: {
|
||||||
@@ -66,7 +66,7 @@ export const dispatchChildSignIn = async ({ deviceId, childUserId, cache }: {
|
|||||||
type: 'child',
|
type: 'child',
|
||||||
userId: childUserId
|
userId: childUserId
|
||||||
},
|
},
|
||||||
transaction: cache.transaction
|
transaction: cache.transaction.legacy.transaction
|
||||||
})
|
})
|
||||||
|
|
||||||
cache.invalidiateUserList = true
|
cache.invalidiateUserList = true
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* server component for the TimeLimit App
|
* server component for the TimeLimit App
|
||||||
* Copyright (C) 2019 - 2022 Jonas Lochmann
|
* Copyright (C) 2019 - 2026 Jonas Lochmann
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU Affero General Public License as
|
* it under the terms of the GNU Affero General Public License as
|
||||||
@@ -45,14 +45,14 @@ export async function dispatchParentAction ({
|
|||||||
parser: parseParentAction,
|
parser: parseParentAction,
|
||||||
applier: async (parsedAction) => {
|
applier: async (parsedAction) => {
|
||||||
if (isChildLimitAdding) {
|
if (isChildLimitAdding) {
|
||||||
const deviceEntryUnsafe = await cache.database.device.findOne({
|
const deviceEntryUnsafe = await cache.transaction.legacy.database.device.findOne({
|
||||||
attributes: ['currentUserId'],
|
attributes: ['currentUserId'],
|
||||||
where: {
|
where: {
|
||||||
familyId: cache.familyId,
|
familyId: cache.familyId,
|
||||||
deviceId,
|
deviceId,
|
||||||
currentUserId: action.userId
|
currentUserId: action.userId
|
||||||
},
|
},
|
||||||
transaction: cache.transaction
|
transaction: cache.transaction.legacy.transaction
|
||||||
})
|
})
|
||||||
|
|
||||||
if (!deviceEntryUnsafe) {
|
if (!deviceEntryUnsafe) {
|
||||||
@@ -67,14 +67,14 @@ export async function dispatchParentAction ({
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
const deviceUserEntryUnsafe = await cache.database.user.findOne({
|
const deviceUserEntryUnsafe = await cache.transaction.legacy.database.user.findOne({
|
||||||
attributes: ['flags'],
|
attributes: ['flags'],
|
||||||
where: {
|
where: {
|
||||||
familyId: cache.familyId,
|
familyId: cache.familyId,
|
||||||
userId: deviceUserId,
|
userId: deviceUserId,
|
||||||
type: 'child'
|
type: 'child'
|
||||||
},
|
},
|
||||||
transaction: cache.transaction
|
transaction: cache.transaction.legacy.transaction
|
||||||
})
|
})
|
||||||
|
|
||||||
if (!deviceUserEntryUnsafe) {
|
if (!deviceUserEntryUnsafe) {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* server component for the TimeLimit App
|
* server component for the TimeLimit App
|
||||||
* Copyright (C) 2019 - 2022 Jonas Lochmann
|
* Copyright (C) 2019 - 2026 Jonas Lochmann
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU Affero General Public License as
|
* it under the terms of the GNU Affero General Public License as
|
||||||
@@ -29,12 +29,12 @@ export async function dispatchAddCategoryApps ({ action, cache, fromChildSelfLim
|
|||||||
cache: Cache
|
cache: Cache
|
||||||
fromChildSelfLimitAddChildUserId: string | null
|
fromChildSelfLimitAddChildUserId: string | null
|
||||||
}) {
|
}) {
|
||||||
const categoryEntryUnsafe = await cache.database.category.findOne({
|
const categoryEntryUnsafe = await cache.transaction.legacy.database.category.findOne({
|
||||||
where: {
|
where: {
|
||||||
familyId: cache.familyId,
|
familyId: cache.familyId,
|
||||||
categoryId: action.categoryId
|
categoryId: action.categoryId
|
||||||
},
|
},
|
||||||
transaction: cache.transaction,
|
transaction: cache.transaction.legacy.transaction,
|
||||||
attributes: ['childId']
|
attributes: ['childId']
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -50,13 +50,13 @@ export async function dispatchAddCategoryApps ({ action, cache, fromChildSelfLim
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const categoriesOfSameChild = (await cache.database.category.findAll({
|
const categoriesOfSameChild = (await cache.transaction.legacy.database.category.findAll({
|
||||||
where: {
|
where: {
|
||||||
familyId: cache.familyId,
|
familyId: cache.familyId,
|
||||||
childId
|
childId
|
||||||
},
|
},
|
||||||
attributes: ['categoryId', 'parentCategoryId'],
|
attributes: ['categoryId', 'parentCategoryId'],
|
||||||
transaction: cache.transaction
|
transaction: cache.transaction.legacy.transaction
|
||||||
})).map((item) => ({
|
})).map((item) => ({
|
||||||
categoryId: item.categoryId,
|
categoryId: item.categoryId,
|
||||||
parentCategoryId: item.parentCategoryId
|
parentCategoryId: item.parentCategoryId
|
||||||
@@ -64,7 +64,7 @@ export async function dispatchAddCategoryApps ({ action, cache, fromChildSelfLim
|
|||||||
|
|
||||||
const userCategoryIds = categoriesOfSameChild.map((item) => item.categoryId)
|
const userCategoryIds = categoriesOfSameChild.map((item) => item.categoryId)
|
||||||
|
|
||||||
const oldCategories = (await cache.database.categoryApp.findAll({
|
const oldCategories = (await cache.transaction.legacy.database.categoryApp.findAll({
|
||||||
attributes: [ 'categoryId' ],
|
attributes: [ 'categoryId' ],
|
||||||
group: [ 'categoryId' ],
|
group: [ 'categoryId' ],
|
||||||
where: {
|
where: {
|
||||||
@@ -76,7 +76,7 @@ export async function dispatchAddCategoryApps ({ action, cache, fromChildSelfLim
|
|||||||
[Sequelize.Op.in]: action.packageNames
|
[Sequelize.Op.in]: action.packageNames
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
transaction: cache.transaction
|
transaction: cache.transaction.legacy.transaction
|
||||||
})).map((item) => item.categoryId)
|
})).map((item) => item.categoryId)
|
||||||
|
|
||||||
if (fromChildSelfLimitAddChildUserId !== null) {
|
if (fromChildSelfLimitAddChildUserId !== null) {
|
||||||
@@ -92,13 +92,13 @@ export async function dispatchAddCategoryApps ({ action, cache, fromChildSelfLim
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
const parentCategoriesOfTargetCategory = getCategoryWithParentCategories(categoriesOfSameChild, action.categoryId)
|
const parentCategoriesOfTargetCategory = getCategoryWithParentCategories(categoriesOfSameChild, action.categoryId)
|
||||||
const userEntryUnsafe = await cache.database.user.findOne({
|
const userEntryUnsafe = await cache.transaction.legacy.database.user.findOne({
|
||||||
attributes: [ 'categoryForNotAssignedApps' ],
|
attributes: [ 'categoryForNotAssignedApps' ],
|
||||||
where: {
|
where: {
|
||||||
familyId: cache.familyId,
|
familyId: cache.familyId,
|
||||||
userId: fromChildSelfLimitAddChildUserId
|
userId: fromChildSelfLimitAddChildUserId
|
||||||
},
|
},
|
||||||
transaction: cache.transaction
|
transaction: cache.transaction.legacy.transaction
|
||||||
})
|
})
|
||||||
|
|
||||||
if (!userEntryUnsafe) {
|
if (!userEntryUnsafe) {
|
||||||
@@ -111,7 +111,7 @@ export async function dispatchAddCategoryApps ({ action, cache, fromChildSelfLim
|
|||||||
parentCategoriesOfTargetCategory.indexOf(validatedDefaultCategoryId) !== -1
|
parentCategoriesOfTargetCategory.indexOf(validatedDefaultCategoryId) !== -1
|
||||||
|
|
||||||
const assertCanAddApp = async (packageName: string, isApp: boolean) => {
|
const assertCanAddApp = async (packageName: string, isApp: boolean) => {
|
||||||
const categoryAppEntryUnsafe = await cache.database.categoryApp.findOne({
|
const categoryAppEntryUnsafe = await cache.transaction.legacy.database.categoryApp.findOne({
|
||||||
attributes: [ 'categoryId' ],
|
attributes: [ 'categoryId' ],
|
||||||
where: {
|
where: {
|
||||||
familyId: cache.familyId,
|
familyId: cache.familyId,
|
||||||
@@ -120,7 +120,7 @@ export async function dispatchAddCategoryApps ({ action, cache, fromChildSelfLim
|
|||||||
},
|
},
|
||||||
packageName: packageName
|
packageName: packageName
|
||||||
},
|
},
|
||||||
transaction: cache.transaction
|
transaction: cache.transaction.legacy.transaction
|
||||||
})
|
})
|
||||||
|
|
||||||
const categoryAppEntry = categoryAppEntryUnsafe ? { categoryId: categoryAppEntryUnsafe.categoryId } : null
|
const categoryAppEntry = categoryAppEntryUnsafe ? { categoryId: categoryAppEntryUnsafe.categoryId } : null
|
||||||
@@ -162,7 +162,7 @@ export async function dispatchAddCategoryApps ({ action, cache, fromChildSelfLim
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (oldCategories.length > 0) {
|
if (oldCategories.length > 0) {
|
||||||
await cache.database.categoryApp.destroy({
|
await cache.transaction.legacy.database.categoryApp.destroy({
|
||||||
where: {
|
where: {
|
||||||
familyId: cache.familyId,
|
familyId: cache.familyId,
|
||||||
categoryId: {
|
categoryId: {
|
||||||
@@ -172,18 +172,18 @@ export async function dispatchAddCategoryApps ({ action, cache, fromChildSelfLim
|
|||||||
[Sequelize.Op.in]: action.packageNames
|
[Sequelize.Op.in]: action.packageNames
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
transaction: cache.transaction
|
transaction: cache.transaction.legacy.transaction
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
await cache.database.categoryApp.bulkCreate(
|
await cache.transaction.legacy.database.categoryApp.bulkCreate(
|
||||||
action.packageNames.map((packageName): CategoryAppAttributes => ({
|
action.packageNames.map((packageName): CategoryAppAttributes => ({
|
||||||
familyId: cache.familyId,
|
familyId: cache.familyId,
|
||||||
categoryId: action.categoryId,
|
categoryId: action.categoryId,
|
||||||
packageName
|
packageName
|
||||||
})),
|
})),
|
||||||
{
|
{
|
||||||
transaction: cache.transaction
|
transaction: cache.transaction.legacy.transaction
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* server component for the TimeLimit App
|
* server component for the TimeLimit App
|
||||||
* Copyright (C) 2019 - 2022 Jonas Lochmann
|
* Copyright (C) 2019 - 2026 Jonas Lochmann
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU Affero General Public License as
|
* it under the terms of the GNU Affero General Public License as
|
||||||
@@ -25,12 +25,12 @@ export async function dispatchAddCategoryNetworkId ({ action, cache }: {
|
|||||||
action: AddCategoryNetworkIdAction
|
action: AddCategoryNetworkIdAction
|
||||||
cache: Cache
|
cache: Cache
|
||||||
}) {
|
}) {
|
||||||
const categoryEntryUnsafe = await cache.database.category.findOne({
|
const categoryEntryUnsafe = await cache.transaction.legacy.database.category.findOne({
|
||||||
where: {
|
where: {
|
||||||
familyId: cache.familyId,
|
familyId: cache.familyId,
|
||||||
categoryId: action.categoryId
|
categoryId: action.categoryId
|
||||||
},
|
},
|
||||||
transaction: cache.transaction,
|
transaction: cache.transaction.legacy.transaction,
|
||||||
attributes: ['childId']
|
attributes: ['childId']
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -38,12 +38,12 @@ export async function dispatchAddCategoryNetworkId ({ action, cache }: {
|
|||||||
throw new MissingCategoryException()
|
throw new MissingCategoryException()
|
||||||
}
|
}
|
||||||
|
|
||||||
const count = await cache.database.categoryNetworkId.count({
|
const count = await cache.transaction.legacy.database.categoryNetworkId.count({
|
||||||
where: {
|
where: {
|
||||||
familyId: cache.familyId,
|
familyId: cache.familyId,
|
||||||
categoryId: action.categoryId
|
categoryId: action.categoryId
|
||||||
},
|
},
|
||||||
transaction: cache.transaction
|
transaction: cache.transaction.legacy.transaction
|
||||||
})
|
})
|
||||||
|
|
||||||
if (count + 1 > maxNetworkIdsPerCategory) {
|
if (count + 1 > maxNetworkIdsPerCategory) {
|
||||||
@@ -52,13 +52,13 @@ export async function dispatchAddCategoryNetworkId ({ action, cache }: {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
const hasOldItem = (await cache.database.categoryNetworkId.count({
|
const hasOldItem = (await cache.transaction.legacy.database.categoryNetworkId.count({
|
||||||
where: {
|
where: {
|
||||||
familyId: cache.familyId,
|
familyId: cache.familyId,
|
||||||
categoryId: action.categoryId,
|
categoryId: action.categoryId,
|
||||||
networkItemId: action.itemId
|
networkItemId: action.itemId
|
||||||
},
|
},
|
||||||
transaction: cache.transaction
|
transaction: cache.transaction.legacy.transaction
|
||||||
})) !== 0
|
})) !== 0
|
||||||
|
|
||||||
if (hasOldItem) {
|
if (hasOldItem) {
|
||||||
@@ -67,12 +67,12 @@ export async function dispatchAddCategoryNetworkId ({ action, cache }: {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
await cache.database.categoryNetworkId.create({
|
await cache.transaction.legacy.database.categoryNetworkId.create({
|
||||||
familyId: cache.familyId,
|
familyId: cache.familyId,
|
||||||
categoryId: action.categoryId,
|
categoryId: action.categoryId,
|
||||||
networkItemId: action.itemId,
|
networkItemId: action.itemId,
|
||||||
hashedNetworkId: action.hashedNetworkId
|
hashedNetworkId: action.hashedNetworkId
|
||||||
}, { transaction: cache.transaction })
|
}, { transaction: cache.transaction.legacy.transaction })
|
||||||
|
|
||||||
cache.categoriesWithModifiedBaseData.add(action.categoryId)
|
cache.categoriesWithModifiedBaseData.add(action.categoryId)
|
||||||
cache.incrementTriggeredSyncLevel(2)
|
cache.incrementTriggeredSyncLevel(2)
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* server component for the TimeLimit App
|
* server component for the TimeLimit App
|
||||||
* Copyright (C) 2019 - 2022 Jonas Lochmann
|
* Copyright (C) 2019 - 2026 Jonas Lochmann
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU Affero General Public License as
|
* it under the terms of the GNU Affero General Public License as
|
||||||
@@ -25,16 +25,16 @@ export async function dispatchAddU2f ({ action, cache, parentUserId }: {
|
|||||||
cache: Cache
|
cache: Cache
|
||||||
parentUserId: string
|
parentUserId: string
|
||||||
}) {
|
}) {
|
||||||
const counter = await cache.database.u2fKey.count({
|
const counter = await cache.transaction.legacy.database.u2fKey.count({
|
||||||
where: {
|
where: {
|
||||||
familyId: cache.familyId
|
familyId: cache.familyId
|
||||||
},
|
},
|
||||||
transaction: cache.transaction
|
transaction: cache.transaction.legacy.transaction
|
||||||
})
|
})
|
||||||
|
|
||||||
if (counter >= 16) throw new LimitReachedException({ type: 'u2f keys' })
|
if (counter >= 16) throw new LimitReachedException({ type: 'u2f keys' })
|
||||||
|
|
||||||
await cache.database.u2fKey.create({
|
await cache.transaction.legacy.database.u2fKey.create({
|
||||||
familyId: cache.familyId,
|
familyId: cache.familyId,
|
||||||
keyId: getU2fKeyId({ keyHandle: action.keyHandle, publicKey: action.publicKey }),
|
keyId: getU2fKeyId({ keyHandle: action.keyHandle, publicKey: action.publicKey }),
|
||||||
userId: parentUserId,
|
userId: parentUserId,
|
||||||
@@ -42,7 +42,7 @@ export async function dispatchAddU2f ({ action, cache, parentUserId }: {
|
|||||||
keyHandle: action.keyHandle,
|
keyHandle: action.keyHandle,
|
||||||
publicKey: action.publicKey,
|
publicKey: action.publicKey,
|
||||||
nextCounter: '0'
|
nextCounter: '0'
|
||||||
}, { transaction: cache.transaction })
|
}, { transaction: cache.transaction.legacy.transaction })
|
||||||
|
|
||||||
cache.invalidateU2fList = true
|
cache.invalidateU2fList = true
|
||||||
cache.incrementTriggeredSyncLevel(1)
|
cache.incrementTriggeredSyncLevel(1)
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* server component for the TimeLimit App
|
* server component for the TimeLimit App
|
||||||
* Copyright (C) 2019 - 2022 Jonas Lochmann
|
* Copyright (C) 2019 - 2026 Jonas Lochmann
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU Affero General Public License as
|
* it under the terms of the GNU Affero General Public License as
|
||||||
@@ -28,7 +28,7 @@ export async function dispatchAddUser ({ action, cache }: {
|
|||||||
await decryptParentPassword({ cache, password: action.password }) :
|
await decryptParentPassword({ cache, password: action.password }) :
|
||||||
null
|
null
|
||||||
|
|
||||||
await cache.database.user.create({
|
await cache.transaction.legacy.database.user.create({
|
||||||
familyId: cache.familyId,
|
familyId: cache.familyId,
|
||||||
userId: action.userId,
|
userId: action.userId,
|
||||||
type: action.userType,
|
type: action.userType,
|
||||||
@@ -45,7 +45,7 @@ export async function dispatchAddUser ({ action, cache }: {
|
|||||||
mailNotificationFlags: 0,
|
mailNotificationFlags: 0,
|
||||||
blockedTimes: '',
|
blockedTimes: '',
|
||||||
flags: '0'
|
flags: '0'
|
||||||
}, { transaction: cache.transaction })
|
}, { transaction: cache.transaction.legacy.transaction })
|
||||||
|
|
||||||
cache.invalidiateUserList = true
|
cache.invalidiateUserList = true
|
||||||
cache.incrementTriggeredSyncLevel(1)
|
cache.incrementTriggeredSyncLevel(1)
|
||||||
|
|||||||
@@ -24,13 +24,13 @@ export async function dispatchChangeParentPassword ({ action, cache }: {
|
|||||||
action: ChangeParentPasswordAction
|
action: ChangeParentPasswordAction
|
||||||
cache: Cache
|
cache: Cache
|
||||||
}) {
|
}) {
|
||||||
const parentEntry = await cache.database.user.findOne({
|
const parentEntry = await cache.transaction.legacy.database.user.findOne({
|
||||||
where: {
|
where: {
|
||||||
familyId: cache.familyId,
|
familyId: cache.familyId,
|
||||||
userId: action.parentUserId,
|
userId: action.parentUserId,
|
||||||
type: 'parent'
|
type: 'parent'
|
||||||
},
|
},
|
||||||
transaction: cache.transaction
|
transaction: cache.transaction.legacy.transaction
|
||||||
})
|
})
|
||||||
|
|
||||||
if (!parentEntry) {
|
if (!parentEntry) {
|
||||||
@@ -51,7 +51,7 @@ export async function dispatchChangeParentPassword ({ action, cache }: {
|
|||||||
parentEntry.secondPasswordSalt = action.newPasswordSecondSalt
|
parentEntry.secondPasswordSalt = action.newPasswordSecondSalt
|
||||||
parentEntry.secondPasswordHash = newSecondPasswordHash
|
parentEntry.secondPasswordHash = newSecondPasswordHash
|
||||||
|
|
||||||
await parentEntry.save({ transaction: cache.transaction })
|
await parentEntry.save({ transaction: cache.transaction.legacy.transaction })
|
||||||
|
|
||||||
{
|
{
|
||||||
const clear = cache.getSecondPasswordHashOfParent.cache.clear
|
const clear = cache.getSecondPasswordHashOfParent.cache.clear
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* server component for the TimeLimit App
|
* server component for the TimeLimit App
|
||||||
* Copyright (C) 2019 - 2022 Jonas Lochmann
|
* Copyright (C) 2019 - 2026 Jonas Lochmann
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU Affero General Public License as
|
* it under the terms of the GNU Affero General Public License as
|
||||||
@@ -33,21 +33,21 @@ export async function dispatchCreateCategory ({ action, cache, fromChildSelfLimi
|
|||||||
}
|
}
|
||||||
|
|
||||||
// check that the child exists
|
// check that the child exists
|
||||||
const childEntry = await cache.database.user.findOne({
|
const childEntry = await cache.transaction.legacy.database.user.findOne({
|
||||||
where: {
|
where: {
|
||||||
familyId: cache.familyId,
|
familyId: cache.familyId,
|
||||||
userId: action.childId,
|
userId: action.childId,
|
||||||
type: 'child'
|
type: 'child'
|
||||||
},
|
},
|
||||||
transaction: cache.transaction
|
transaction: cache.transaction.legacy.transaction
|
||||||
})
|
})
|
||||||
|
|
||||||
if (!childEntry) {
|
if (!childEntry) {
|
||||||
throw new MissingUserException()
|
throw new MissingUserException()
|
||||||
}
|
}
|
||||||
|
|
||||||
const oldMaxSort: number = await cache.database.category.max('sort', {
|
const oldMaxSort: number = await cache.transaction.legacy.database.category.max('sort', {
|
||||||
transaction: cache.transaction,
|
transaction: cache.transaction.legacy.transaction,
|
||||||
where: {
|
where: {
|
||||||
familyId: cache.familyId,
|
familyId: cache.familyId,
|
||||||
childId: action.childId
|
childId: action.childId
|
||||||
@@ -58,7 +58,7 @@ export async function dispatchCreateCategory ({ action, cache, fromChildSelfLimi
|
|||||||
const sort = Number.isSafeInteger(oldMaxSort + 1) ? (oldMaxSort + 1) : 0
|
const sort = Number.isSafeInteger(oldMaxSort + 1) ? (oldMaxSort + 1) : 0
|
||||||
|
|
||||||
// no version number needs to be updated
|
// no version number needs to be updated
|
||||||
await cache.database.category.create({
|
await cache.transaction.legacy.database.category.create({
|
||||||
familyId: cache.familyId,
|
familyId: cache.familyId,
|
||||||
categoryId: action.categoryId,
|
categoryId: action.categoryId,
|
||||||
childId: action.childId,
|
childId: action.childId,
|
||||||
@@ -82,7 +82,7 @@ export async function dispatchCreateCategory ({ action, cache, fromChildSelfLimi
|
|||||||
minBatteryMobile: 0,
|
minBatteryMobile: 0,
|
||||||
flags: '0',
|
flags: '0',
|
||||||
blockNotificationDelay: '0'
|
blockNotificationDelay: '0'
|
||||||
}, { transaction: cache.transaction })
|
}, { transaction: cache.transaction.legacy.transaction })
|
||||||
|
|
||||||
// update the cache
|
// update the cache
|
||||||
cache.doesCategoryExist.cache.set(action.categoryId, true)
|
cache.doesCategoryExist.cache.set(action.categoryId, true)
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* server component for the TimeLimit App
|
* server component for the TimeLimit App
|
||||||
* Copyright (C) 2019 - 2024 Jonas Lochmann
|
* Copyright (C) 2019 - 2026 Jonas Lochmann
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU Affero General Public License as
|
* it under the terms of the GNU Affero General Public License as
|
||||||
@@ -25,12 +25,12 @@ export async function dispatchCreateTimeLimitRule ({ action, cache, fromChildSel
|
|||||||
cache: Cache
|
cache: Cache
|
||||||
fromChildSelfLimitAddChildUserId: string | null
|
fromChildSelfLimitAddChildUserId: string | null
|
||||||
}) {
|
}) {
|
||||||
const categoryEntryUnsafe = await cache.database.category.findOne({
|
const categoryEntryUnsafe = await cache.transaction.legacy.database.category.findOne({
|
||||||
where: {
|
where: {
|
||||||
familyId: cache.familyId,
|
familyId: cache.familyId,
|
||||||
categoryId: action.rule.categoryId
|
categoryId: action.rule.categoryId
|
||||||
},
|
},
|
||||||
transaction: cache.transaction,
|
transaction: cache.transaction.legacy.transaction,
|
||||||
attributes: ['childId']
|
attributes: ['childId']
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -44,7 +44,7 @@ export async function dispatchCreateTimeLimitRule ({ action, cache, fromChildSel
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
await cache.database.timelimitRule.create({
|
await cache.transaction.legacy.database.timelimitRule.create({
|
||||||
familyId: cache.familyId,
|
familyId: cache.familyId,
|
||||||
ruleId: action.rule.ruleId,
|
ruleId: action.rule.ruleId,
|
||||||
categoryId: action.rule.categoryId,
|
categoryId: action.rule.categoryId,
|
||||||
@@ -57,7 +57,7 @@ export async function dispatchCreateTimeLimitRule ({ action, cache, fromChildSel
|
|||||||
sessionPauseMilliseconds: action.rule.sessionPauseMilliseconds,
|
sessionPauseMilliseconds: action.rule.sessionPauseMilliseconds,
|
||||||
perDay: action.rule.perDay ? 1 : 0,
|
perDay: action.rule.perDay ? 1 : 0,
|
||||||
expiresAt: action.rule.expiresAt ? action.rule.expiresAt.toString() : null
|
expiresAt: action.rule.expiresAt ? action.rule.expiresAt.toString() : null
|
||||||
}, { transaction: cache.transaction })
|
}, { transaction: cache.transaction.legacy.transaction })
|
||||||
|
|
||||||
cache.categoriesWithModifiedTimeLimitRules.add(action.rule.categoryId)
|
cache.categoriesWithModifiedTimeLimitRules.add(action.rule.categoryId)
|
||||||
cache.incrementTriggeredSyncLevel(2)
|
cache.incrementTriggeredSyncLevel(2)
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* server component for the TimeLimit App
|
* server component for the TimeLimit App
|
||||||
* Copyright (C) 2019 - 2022 Jonas Lochmann
|
* Copyright (C) 2019 - 2026 Jonas Lochmann
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU Affero General Public License as
|
* it under the terms of the GNU Affero General Public License as
|
||||||
@@ -23,59 +23,59 @@ export async function dispatchDeleteCategory ({ action, cache }: {
|
|||||||
action: DeleteCategoryAction
|
action: DeleteCategoryAction
|
||||||
cache: Cache
|
cache: Cache
|
||||||
}) {
|
}) {
|
||||||
const { familyId, transaction } = cache
|
const { familyId } = cache
|
||||||
const { categoryId } = action
|
const { categoryId } = action
|
||||||
|
|
||||||
const categoryEntry = await cache.database.category.findOne({
|
const categoryEntry = await cache.transaction.legacy.database.category.findOne({
|
||||||
where: {
|
where: {
|
||||||
familyId,
|
familyId,
|
||||||
categoryId
|
categoryId
|
||||||
},
|
},
|
||||||
transaction
|
transaction: cache.transaction.legacy.transaction
|
||||||
})
|
})
|
||||||
|
|
||||||
if (!categoryEntry) { throw new MissingCategoryException() }
|
if (!categoryEntry) { throw new MissingCategoryException() }
|
||||||
|
|
||||||
await cache.database.timelimitRule.destroy({
|
await cache.transaction.legacy.database.timelimitRule.destroy({
|
||||||
where: {
|
where: {
|
||||||
familyId,
|
familyId,
|
||||||
categoryId
|
categoryId
|
||||||
},
|
},
|
||||||
transaction
|
transaction: cache.transaction.legacy.transaction
|
||||||
})
|
})
|
||||||
|
|
||||||
await cache.database.usedTime.destroy({
|
await cache.transaction.legacy.database.usedTime.destroy({
|
||||||
where: {
|
where: {
|
||||||
familyId,
|
familyId,
|
||||||
categoryId
|
categoryId
|
||||||
},
|
},
|
||||||
transaction
|
transaction: cache.transaction.legacy.transaction
|
||||||
})
|
})
|
||||||
|
|
||||||
await cache.database.categoryApp.destroy({
|
await cache.transaction.legacy.database.categoryApp.destroy({
|
||||||
where: {
|
where: {
|
||||||
familyId,
|
familyId,
|
||||||
categoryId
|
categoryId
|
||||||
},
|
},
|
||||||
transaction
|
transaction: cache.transaction.legacy.transaction
|
||||||
})
|
})
|
||||||
|
|
||||||
const [affectedUserRows] = await cache.database.user.update({
|
const [affectedUserRows] = await cache.transaction.legacy.database.user.update({
|
||||||
categoryForNotAssignedApps: ''
|
categoryForNotAssignedApps: ''
|
||||||
}, {
|
}, {
|
||||||
where: {
|
where: {
|
||||||
familyId,
|
familyId,
|
||||||
categoryForNotAssignedApps: categoryId
|
categoryForNotAssignedApps: categoryId
|
||||||
},
|
},
|
||||||
transaction
|
transaction: cache.transaction.legacy.transaction
|
||||||
})
|
})
|
||||||
|
|
||||||
await cache.database.category.destroy({
|
await cache.transaction.legacy.database.category.destroy({
|
||||||
where: {
|
where: {
|
||||||
familyId,
|
familyId,
|
||||||
categoryId
|
categoryId
|
||||||
},
|
},
|
||||||
transaction
|
transaction: cache.transaction.legacy.transaction
|
||||||
})
|
})
|
||||||
|
|
||||||
// update the cache
|
// update the cache
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* server component for the TimeLimit App
|
* server component for the TimeLimit App
|
||||||
* Copyright (C) 2019 - 2022 Jonas Lochmann
|
* Copyright (C) 2019 - 2026 Jonas Lochmann
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU Affero General Public License as
|
* it under the terms of the GNU Affero General Public License as
|
||||||
@@ -23,12 +23,12 @@ export async function dispatchDeleteChildTaskAction ({ action, cache }: {
|
|||||||
action: DeleteChildTaskAction
|
action: DeleteChildTaskAction
|
||||||
cache: Cache
|
cache: Cache
|
||||||
}) {
|
}) {
|
||||||
const taskInfoUnsafe = await cache.database.childTask.findOne({
|
const taskInfoUnsafe = await cache.transaction.legacy.database.childTask.findOne({
|
||||||
where: {
|
where: {
|
||||||
familyId: cache.familyId,
|
familyId: cache.familyId,
|
||||||
taskId: action.taskId
|
taskId: action.taskId
|
||||||
},
|
},
|
||||||
transaction: cache.transaction,
|
transaction: cache.transaction.legacy.transaction,
|
||||||
attributes: ['categoryId']
|
attributes: ['categoryId']
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -36,12 +36,12 @@ export async function dispatchDeleteChildTaskAction ({ action, cache }: {
|
|||||||
|
|
||||||
const taskInfo = { categoryId: taskInfoUnsafe.categoryId }
|
const taskInfo = { categoryId: taskInfoUnsafe.categoryId }
|
||||||
|
|
||||||
await cache.database.childTask.destroy({
|
await cache.transaction.legacy.database.childTask.destroy({
|
||||||
where: {
|
where: {
|
||||||
familyId: cache.familyId,
|
familyId: cache.familyId,
|
||||||
taskId: action.taskId
|
taskId: action.taskId
|
||||||
},
|
},
|
||||||
transaction: cache.transaction
|
transaction: cache.transaction.legacy.transaction
|
||||||
})
|
})
|
||||||
|
|
||||||
cache.categoriesWithModifiedTasks.add(taskInfo.categoryId)
|
cache.categoriesWithModifiedTasks.add(taskInfo.categoryId)
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* server component for the TimeLimit App
|
* server component for the TimeLimit App
|
||||||
* Copyright (C) 2019 - 2022 Jonas Lochmann
|
* Copyright (C) 2019 - 2026 Jonas Lochmann
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU Affero General Public License as
|
* it under the terms of the GNU Affero General Public License as
|
||||||
@@ -23,19 +23,19 @@ export async function dispatchDeleteTimeLimitRule ({ action, cache }: {
|
|||||||
action: DeleteTimeLimitRuleAction
|
action: DeleteTimeLimitRuleAction
|
||||||
cache: Cache
|
cache: Cache
|
||||||
}) {
|
}) {
|
||||||
const ruleEntry = await cache.database.timelimitRule.findOne({
|
const ruleEntry = await cache.transaction.legacy.database.timelimitRule.findOne({
|
||||||
where: {
|
where: {
|
||||||
familyId: cache.familyId,
|
familyId: cache.familyId,
|
||||||
ruleId: action.ruleId
|
ruleId: action.ruleId
|
||||||
},
|
},
|
||||||
transaction: cache.transaction
|
transaction: cache.transaction.legacy.transaction
|
||||||
})
|
})
|
||||||
|
|
||||||
if (!ruleEntry) {
|
if (!ruleEntry) {
|
||||||
throw new MissingRuleException()
|
throw new MissingRuleException()
|
||||||
}
|
}
|
||||||
|
|
||||||
await ruleEntry.destroy({ transaction: cache.transaction })
|
await ruleEntry.destroy({ transaction: cache.transaction.legacy.transaction })
|
||||||
|
|
||||||
cache.categoriesWithModifiedTimeLimitRules.add(ruleEntry.categoryId)
|
cache.categoriesWithModifiedTimeLimitRules.add(ruleEntry.categoryId)
|
||||||
cache.incrementTriggeredSyncLevel(2)
|
cache.incrementTriggeredSyncLevel(2)
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* server component for the TimeLimit App
|
* server component for the TimeLimit App
|
||||||
* Copyright (C) 2019 - 2022 Jonas Lochmann
|
* Copyright (C) 2019 - 2026 Jonas Lochmann
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU Affero General Public License as
|
* it under the terms of the GNU Affero General Public License as
|
||||||
@@ -23,12 +23,12 @@ export async function dispatchIgnoreManipulation ({ action, cache }: {
|
|||||||
action: IgnoreManipulationAction
|
action: IgnoreManipulationAction
|
||||||
cache: Cache
|
cache: Cache
|
||||||
}) {
|
}) {
|
||||||
const deviceEntry = await cache.database.device.findOne({
|
const deviceEntry = await cache.transaction.legacy.database.device.findOne({
|
||||||
where: {
|
where: {
|
||||||
familyId: cache.familyId,
|
familyId: cache.familyId,
|
||||||
deviceId: action.deviceId
|
deviceId: action.deviceId
|
||||||
},
|
},
|
||||||
transaction: cache.transaction
|
transaction: cache.transaction.legacy.transaction
|
||||||
})
|
})
|
||||||
|
|
||||||
if (deviceEntry === null) {
|
if (deviceEntry === null) {
|
||||||
@@ -85,7 +85,7 @@ export async function dispatchIgnoreManipulation ({ action, cache }: {
|
|||||||
deviceEntry.manipulationFlags = deviceEntry.manipulationFlags & (~action.ignoreManipulationFlags)
|
deviceEntry.manipulationFlags = deviceEntry.manipulationFlags & (~action.ignoreManipulationFlags)
|
||||||
}
|
}
|
||||||
|
|
||||||
await deviceEntry.save({ transaction: cache.transaction })
|
await deviceEntry.save({ transaction: cache.transaction.legacy.transaction })
|
||||||
cache.invalidiateDeviceList = true
|
cache.invalidiateDeviceList = true
|
||||||
cache.incrementTriggeredSyncLevel(1)
|
cache.incrementTriggeredSyncLevel(1)
|
||||||
cache.incrementTargetedTriggeredSyncLevel(action.deviceId, 2)
|
cache.incrementTargetedTriggeredSyncLevel(action.deviceId, 2)
|
||||||
|
|||||||
+6
-6
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* server component for the TimeLimit App
|
* server component for the TimeLimit App
|
||||||
* Copyright (C) 2019 - 2022 Jonas Lochmann
|
* Copyright (C) 2019 - 2026 Jonas Lochmann
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU Affero General Public License as
|
* it under the terms of the GNU Affero General Public License as
|
||||||
@@ -38,18 +38,18 @@ export async function dispatchIncrementCategoryExtraTime ({ action, cache }: {
|
|||||||
|
|
||||||
category.extraTimeDay = action.day
|
category.extraTimeDay = action.day
|
||||||
|
|
||||||
await category.save({ transaction: cache.transaction })
|
await category.save({ transaction: cache.transaction.legacy.transaction })
|
||||||
|
|
||||||
cache.categoriesWithModifiedBaseData.add(category.categoryId)
|
cache.categoriesWithModifiedBaseData.add(category.categoryId)
|
||||||
cache.incrementTriggeredSyncLevel(2)
|
cache.incrementTriggeredSyncLevel(2)
|
||||||
}
|
}
|
||||||
|
|
||||||
const categoryEntry = await cache.database.category.findOne({
|
const categoryEntry = await cache.transaction.legacy.database.category.findOne({
|
||||||
where: {
|
where: {
|
||||||
familyId: cache.familyId,
|
familyId: cache.familyId,
|
||||||
categoryId: action.categoryId
|
categoryId: action.categoryId
|
||||||
},
|
},
|
||||||
transaction: cache.transaction
|
transaction: cache.transaction.legacy.transaction
|
||||||
})
|
})
|
||||||
|
|
||||||
if (!categoryEntry) {
|
if (!categoryEntry) {
|
||||||
@@ -59,12 +59,12 @@ export async function dispatchIncrementCategoryExtraTime ({ action, cache }: {
|
|||||||
await handleCategory(categoryEntry)
|
await handleCategory(categoryEntry)
|
||||||
|
|
||||||
if (categoryEntry.parentCategoryId !== '') {
|
if (categoryEntry.parentCategoryId !== '') {
|
||||||
const parentCategoryEntry = await cache.database.category.findOne({
|
const parentCategoryEntry = await cache.transaction.legacy.database.category.findOne({
|
||||||
where: {
|
where: {
|
||||||
familyId: cache.familyId,
|
familyId: cache.familyId,
|
||||||
categoryId: categoryEntry.parentCategoryId
|
categoryId: categoryEntry.parentCategoryId
|
||||||
},
|
},
|
||||||
transaction: cache.transaction
|
transaction: cache.transaction.legacy.transaction
|
||||||
})
|
})
|
||||||
|
|
||||||
if (parentCategoryEntry) {
|
if (parentCategoryEntry) {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* server component for the TimeLimit App
|
* server component for the TimeLimit App
|
||||||
* Copyright (C) 2019 - 2022 Jonas Lochmann
|
* Copyright (C) 2019 - 2026 Jonas Lochmann
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU Affero General Public License as
|
* it under the terms of the GNU Affero General Public License as
|
||||||
@@ -24,7 +24,7 @@ export async function dispatchRemoveCategoryApps ({ action, cache }: {
|
|||||||
action: RemoveCategoryAppsAction
|
action: RemoveCategoryAppsAction
|
||||||
cache: Cache
|
cache: Cache
|
||||||
}) {
|
}) {
|
||||||
const affectedRows = await cache.database.categoryApp.destroy({
|
const affectedRows = await cache.transaction.legacy.database.categoryApp.destroy({
|
||||||
where: {
|
where: {
|
||||||
familyId: cache.familyId,
|
familyId: cache.familyId,
|
||||||
categoryId: action.categoryId,
|
categoryId: action.categoryId,
|
||||||
@@ -32,7 +32,7 @@ export async function dispatchRemoveCategoryApps ({ action, cache }: {
|
|||||||
[Sequelize.Op.in]: action.packageNames
|
[Sequelize.Op.in]: action.packageNames
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
transaction: cache.transaction
|
transaction: cache.transaction.legacy.transaction
|
||||||
})
|
})
|
||||||
|
|
||||||
if (affectedRows !== action.packageNames.length) {
|
if (affectedRows !== action.packageNames.length) {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* server component for the TimeLimit App
|
* server component for the TimeLimit App
|
||||||
* Copyright (C) 2019 - 2022 Jonas Lochmann
|
* Copyright (C) 2019 - 2026 Jonas Lochmann
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU Affero General Public License as
|
* it under the terms of the GNU Affero General Public License as
|
||||||
@@ -31,7 +31,7 @@ export async function dispatchRemoveU2f ({ action, cache, parentUserId, authenti
|
|||||||
throw new ApplyActionUnacceptableAuthMethodException()
|
throw new ApplyActionUnacceptableAuthMethodException()
|
||||||
}
|
}
|
||||||
|
|
||||||
await cache.database.u2fKey.destroy({
|
await cache.transaction.legacy.database.u2fKey.destroy({
|
||||||
where: {
|
where: {
|
||||||
familyId: cache.familyId,
|
familyId: cache.familyId,
|
||||||
keyId: getU2fKeyId({ keyHandle: action.keyHandle, publicKey: action.publicKey }),
|
keyId: getU2fKeyId({ keyHandle: action.keyHandle, publicKey: action.publicKey }),
|
||||||
@@ -39,7 +39,7 @@ export async function dispatchRemoveU2f ({ action, cache, parentUserId, authenti
|
|||||||
keyHandle: action.keyHandle,
|
keyHandle: action.keyHandle,
|
||||||
publicKey: action.publicKey
|
publicKey: action.publicKey
|
||||||
},
|
},
|
||||||
transaction: cache.transaction
|
transaction: cache.transaction.legacy.transaction
|
||||||
})
|
})
|
||||||
|
|
||||||
cache.invalidateU2fList = true
|
cache.invalidateU2fList = true
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* server component for the TimeLimit App
|
* server component for the TimeLimit App
|
||||||
* Copyright (C) 2019 - 2022 Jonas Lochmann
|
* Copyright (C) 2019 - 2026 Jonas Lochmann
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU Affero General Public License as
|
* it under the terms of the GNU Affero General Public License as
|
||||||
@@ -30,12 +30,12 @@ export async function dispatchRemoveUser ({ action, cache, parentUserId }: {
|
|||||||
cache: Cache
|
cache: Cache
|
||||||
parentUserId: string
|
parentUserId: string
|
||||||
}) {
|
}) {
|
||||||
const user = await cache.database.user.findOne({
|
const user = await cache.transaction.legacy.database.user.findOne({
|
||||||
where: {
|
where: {
|
||||||
familyId: cache.familyId,
|
familyId: cache.familyId,
|
||||||
userId: action.userId
|
userId: action.userId
|
||||||
},
|
},
|
||||||
transaction: cache.transaction
|
transaction: cache.transaction.legacy.transaction
|
||||||
})
|
})
|
||||||
|
|
||||||
if (!user) {
|
if (!user) {
|
||||||
@@ -60,8 +60,8 @@ export async function dispatchRemoveUser ({ action, cache, parentUserId }: {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (user.mail !== '') {
|
if (user.mail !== '') {
|
||||||
const usersWithLinkedMail = await cache.database.user.count({
|
const usersWithLinkedMail = await cache.transaction.legacy.database.user.count({
|
||||||
transaction: cache.transaction,
|
transaction: cache.transaction.legacy.transaction,
|
||||||
where: {
|
where: {
|
||||||
familyId: cache.familyId,
|
familyId: cache.familyId,
|
||||||
type: 'parent',
|
type: 'parent',
|
||||||
@@ -76,16 +76,16 @@ export async function dispatchRemoveUser ({ action, cache, parentUserId }: {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const usersWithLimitLoginCategories = (await cache.database.userLimitLoginCategory.findAll({
|
const usersWithLimitLoginCategories = (await cache.transaction.legacy.database.userLimitLoginCategory.findAll({
|
||||||
transaction: cache.transaction,
|
transaction: cache.transaction.legacy.transaction,
|
||||||
where: {
|
where: {
|
||||||
familyId: cache.familyId
|
familyId: cache.familyId
|
||||||
},
|
},
|
||||||
attributes: ['userId']
|
attributes: ['userId']
|
||||||
})).map((item) => item.userId)
|
})).map((item) => item.userId)
|
||||||
|
|
||||||
const allParentUserIds = (await cache.database.user.findAll({
|
const allParentUserIds = (await cache.transaction.legacy.database.user.findAll({
|
||||||
transaction: cache.transaction,
|
transaction: cache.transaction.legacy.transaction,
|
||||||
where: {
|
where: {
|
||||||
familyId: cache.familyId,
|
familyId: cache.familyId,
|
||||||
type: 'parent'
|
type: 'parent'
|
||||||
@@ -101,56 +101,56 @@ export async function dispatchRemoveUser ({ action, cache, parentUserId }: {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (user.type === 'child') {
|
if (user.type === 'child') {
|
||||||
const categories = await cache.database.category.findAll({
|
const categories = await cache.transaction.legacy.database.category.findAll({
|
||||||
where: {
|
where: {
|
||||||
familyId: cache.familyId,
|
familyId: cache.familyId,
|
||||||
childId: action.userId
|
childId: action.userId
|
||||||
},
|
},
|
||||||
transaction: cache.transaction
|
transaction: cache.transaction.legacy.transaction
|
||||||
})
|
})
|
||||||
|
|
||||||
await cache.database.categoryApp.destroy({
|
await cache.transaction.legacy.database.categoryApp.destroy({
|
||||||
where: {
|
where: {
|
||||||
familyId: cache.familyId,
|
familyId: cache.familyId,
|
||||||
categoryId: {
|
categoryId: {
|
||||||
[Sequelize.Op.in]: categories.map((category) => category.categoryId)
|
[Sequelize.Op.in]: categories.map((category) => category.categoryId)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
transaction: cache.transaction
|
transaction: cache.transaction.legacy.transaction
|
||||||
})
|
})
|
||||||
|
|
||||||
await cache.database.timelimitRule.destroy({
|
await cache.transaction.legacy.database.timelimitRule.destroy({
|
||||||
where: {
|
where: {
|
||||||
familyId: cache.familyId,
|
familyId: cache.familyId,
|
||||||
categoryId: {
|
categoryId: {
|
||||||
[Sequelize.Op.in]: categories.map((category) => category.categoryId)
|
[Sequelize.Op.in]: categories.map((category) => category.categoryId)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
transaction: cache.transaction
|
transaction: cache.transaction.legacy.transaction
|
||||||
})
|
})
|
||||||
|
|
||||||
await cache.database.usedTime.destroy({
|
await cache.transaction.legacy.database.usedTime.destroy({
|
||||||
where: {
|
where: {
|
||||||
familyId: cache.familyId,
|
familyId: cache.familyId,
|
||||||
categoryId: {
|
categoryId: {
|
||||||
[Sequelize.Op.in]: categories.map((category) => category.categoryId)
|
[Sequelize.Op.in]: categories.map((category) => category.categoryId)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
transaction: cache.transaction
|
transaction: cache.transaction.legacy.transaction
|
||||||
})
|
})
|
||||||
|
|
||||||
await cache.database.category.destroy({
|
await cache.transaction.legacy.database.category.destroy({
|
||||||
where: {
|
where: {
|
||||||
familyId: cache.familyId,
|
familyId: cache.familyId,
|
||||||
categoryId: {
|
categoryId: {
|
||||||
[Sequelize.Op.in]: categories.map((category) => category.categoryId)
|
[Sequelize.Op.in]: categories.map((category) => category.categoryId)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
transaction: cache.transaction
|
transaction: cache.transaction.legacy.transaction
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
const [updatedDevices1] = await cache.database.device.update({
|
const [updatedDevices1] = await cache.transaction.legacy.database.device.update({
|
||||||
currentUserId: '',
|
currentUserId: '',
|
||||||
isUserKeptSignedIn: false
|
isUserKeptSignedIn: false
|
||||||
}, {
|
}, {
|
||||||
@@ -158,24 +158,24 @@ export async function dispatchRemoveUser ({ action, cache, parentUserId }: {
|
|||||||
familyId: cache.familyId,
|
familyId: cache.familyId,
|
||||||
currentUserId: action.userId
|
currentUserId: action.userId
|
||||||
},
|
},
|
||||||
transaction: cache.transaction
|
transaction: cache.transaction.legacy.transaction
|
||||||
})
|
})
|
||||||
|
|
||||||
const [updatedDevices2] = await cache.database.device.update({
|
const [updatedDevices2] = await cache.transaction.legacy.database.device.update({
|
||||||
defaultUserId: ''
|
defaultUserId: ''
|
||||||
}, {
|
}, {
|
||||||
where: {
|
where: {
|
||||||
familyId: cache.familyId,
|
familyId: cache.familyId,
|
||||||
defaultUserId: action.userId
|
defaultUserId: action.userId
|
||||||
},
|
},
|
||||||
transaction: cache.transaction
|
transaction: cache.transaction.legacy.transaction
|
||||||
})
|
})
|
||||||
|
|
||||||
if (updatedDevices1 > 0 || updatedDevices2 > 0) {
|
if (updatedDevices1 > 0 || updatedDevices2 > 0) {
|
||||||
cache.invalidiateDeviceList = true
|
cache.invalidiateDeviceList = true
|
||||||
}
|
}
|
||||||
|
|
||||||
await user.destroy({ transaction: cache.transaction })
|
await user.destroy({ transaction: cache.transaction.legacy.transaction })
|
||||||
|
|
||||||
cache.invalidiateUserList = true
|
cache.invalidiateUserList = true
|
||||||
cache.incrementTriggeredSyncLevel(2)
|
cache.incrementTriggeredSyncLevel(2)
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* server component for the TimeLimit App
|
* server component for the TimeLimit App
|
||||||
* Copyright (C) 2019 - 2022 Jonas Lochmann
|
* Copyright (C) 2019 - 2026 Jonas Lochmann
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU Affero General Public License as
|
* it under the terms of the GNU Affero General Public License as
|
||||||
@@ -23,20 +23,20 @@ export async function dispatchRenameChild ({ action, cache }: {
|
|||||||
action: RenameChildAction
|
action: RenameChildAction
|
||||||
cache: Cache
|
cache: Cache
|
||||||
}) {
|
}) {
|
||||||
const oldItem = await cache.database.user.findOne({
|
const oldItem = await cache.transaction.legacy.database.user.findOne({
|
||||||
where: {
|
where: {
|
||||||
familyId: cache.familyId,
|
familyId: cache.familyId,
|
||||||
userId: action.childId,
|
userId: action.childId,
|
||||||
type: 'child'
|
type: 'child'
|
||||||
},
|
},
|
||||||
transaction: cache.transaction
|
transaction: cache.transaction.legacy.transaction
|
||||||
})
|
})
|
||||||
|
|
||||||
if (!oldItem) {
|
if (!oldItem) {
|
||||||
throw new MissingUserException()
|
throw new MissingUserException()
|
||||||
}
|
}
|
||||||
|
|
||||||
await cache.database.user.update({
|
await cache.transaction.legacy.database.user.update({
|
||||||
name: action.newName
|
name: action.newName
|
||||||
}, {
|
}, {
|
||||||
where: {
|
where: {
|
||||||
@@ -44,7 +44,7 @@ export async function dispatchRenameChild ({ action, cache }: {
|
|||||||
userId: action.childId,
|
userId: action.childId,
|
||||||
type: 'child'
|
type: 'child'
|
||||||
},
|
},
|
||||||
transaction: cache.transaction
|
transaction: cache.transaction.legacy.transaction
|
||||||
})
|
})
|
||||||
|
|
||||||
cache.invalidiateUserList = true
|
cache.invalidiateUserList = true
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* server component for the TimeLimit App
|
* server component for the TimeLimit App
|
||||||
* Copyright (C) 2019 - 2022 Jonas Lochmann
|
* Copyright (C) 2019 - 2026 Jonas Lochmann
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU Affero General Public License as
|
* it under the terms of the GNU Affero General Public License as
|
||||||
@@ -23,12 +23,12 @@ export async function dispatchResetCategoryNetworkIds ({ action, cache }: {
|
|||||||
action: ResetCategoryNetworkIdsAction
|
action: ResetCategoryNetworkIdsAction
|
||||||
cache: Cache
|
cache: Cache
|
||||||
}) {
|
}) {
|
||||||
const categoryEntryUnsafe = await cache.database.category.findOne({
|
const categoryEntryUnsafe = await cache.transaction.legacy.database.category.findOne({
|
||||||
where: {
|
where: {
|
||||||
familyId: cache.familyId,
|
familyId: cache.familyId,
|
||||||
categoryId: action.categoryId
|
categoryId: action.categoryId
|
||||||
},
|
},
|
||||||
transaction: cache.transaction,
|
transaction: cache.transaction.legacy.transaction,
|
||||||
attributes: ['childId']
|
attributes: ['childId']
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -36,12 +36,12 @@ export async function dispatchResetCategoryNetworkIds ({ action, cache }: {
|
|||||||
throw new MissingCategoryException()
|
throw new MissingCategoryException()
|
||||||
}
|
}
|
||||||
|
|
||||||
await cache.database.categoryNetworkId.destroy({
|
await cache.transaction.legacy.database.categoryNetworkId.destroy({
|
||||||
where: {
|
where: {
|
||||||
familyId: cache.familyId,
|
familyId: cache.familyId,
|
||||||
categoryId: action.categoryId
|
categoryId: action.categoryId
|
||||||
},
|
},
|
||||||
transaction: cache.transaction
|
transaction: cache.transaction.legacy.transaction
|
||||||
})
|
})
|
||||||
|
|
||||||
cache.categoriesWithModifiedBaseData.add(action.categoryId)
|
cache.categoriesWithModifiedBaseData.add(action.categoryId)
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* server component for the TimeLimit App
|
* server component for the TimeLimit App
|
||||||
* Copyright (C) 2019 - 2022 Jonas Lochmann
|
* Copyright (C) 2019 - 2026 Jonas Lochmann
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU Affero General Public License as
|
* it under the terms of the GNU Affero General Public License as
|
||||||
@@ -29,12 +29,12 @@ export async function dispatchReviewChildTaskAction ({ action, cache }: {
|
|||||||
throw new PremiumVersionMissingException()
|
throw new PremiumVersionMissingException()
|
||||||
}
|
}
|
||||||
|
|
||||||
const taskInfo = await cache.database.childTask.findOne({
|
const taskInfo = await cache.transaction.legacy.database.childTask.findOne({
|
||||||
where: {
|
where: {
|
||||||
familyId: cache.familyId,
|
familyId: cache.familyId,
|
||||||
taskId: action.taskId
|
taskId: action.taskId
|
||||||
},
|
},
|
||||||
transaction: cache.transaction
|
transaction: cache.transaction.legacy.transaction
|
||||||
})
|
})
|
||||||
|
|
||||||
if (taskInfo === null) throw new MissingTaskException()
|
if (taskInfo === null) throw new MissingTaskException()
|
||||||
@@ -42,13 +42,13 @@ export async function dispatchReviewChildTaskAction ({ action, cache }: {
|
|||||||
if (taskInfo.pendingRequest === 0) throw new IllegalStateException({ staticMessage: 'no task review pending' })
|
if (taskInfo.pendingRequest === 0) throw new IllegalStateException({ staticMessage: 'no task review pending' })
|
||||||
|
|
||||||
if (action.ok) {
|
if (action.ok) {
|
||||||
const categoryInfoUnsafe = await cache.database.category.findOne({
|
const categoryInfoUnsafe = await cache.transaction.legacy.database.category.findOne({
|
||||||
where: {
|
where: {
|
||||||
familyId: cache.familyId,
|
familyId: cache.familyId,
|
||||||
categoryId: taskInfo.categoryId
|
categoryId: taskInfo.categoryId
|
||||||
},
|
},
|
||||||
attributes: ['extraTimeInMillis', 'extraTimeDay'],
|
attributes: ['extraTimeInMillis', 'extraTimeDay'],
|
||||||
transaction: cache.transaction
|
transaction: cache.transaction.legacy.transaction
|
||||||
})
|
})
|
||||||
|
|
||||||
if (categoryInfoUnsafe === null) {
|
if (categoryInfoUnsafe === null) {
|
||||||
@@ -64,7 +64,7 @@ export async function dispatchReviewChildTaskAction ({ action, cache }: {
|
|||||||
action.day !== undefined && categoryInfo.extraTimeDay !== action.day
|
action.day !== undefined && categoryInfo.extraTimeDay !== action.day
|
||||||
|
|
||||||
if (resetDayBoundExtraTime) {
|
if (resetDayBoundExtraTime) {
|
||||||
await cache.database.category.update({
|
await cache.transaction.legacy.database.category.update({
|
||||||
extraTimeInMillis: taskInfo.extraTimeDuration,
|
extraTimeInMillis: taskInfo.extraTimeDuration,
|
||||||
extraTimeDay: -1
|
extraTimeDay: -1
|
||||||
}, {
|
}, {
|
||||||
@@ -72,23 +72,23 @@ export async function dispatchReviewChildTaskAction ({ action, cache }: {
|
|||||||
familyId: cache.familyId,
|
familyId: cache.familyId,
|
||||||
categoryId: taskInfo.categoryId
|
categoryId: taskInfo.categoryId
|
||||||
},
|
},
|
||||||
transaction: cache.transaction
|
transaction: cache.transaction.legacy.transaction
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
await cache.database.category.update({
|
await cache.transaction.legacy.database.category.update({
|
||||||
extraTimeInMillis: categoryInfo.extraTimeInMillis + taskInfo.extraTimeDuration
|
extraTimeInMillis: categoryInfo.extraTimeInMillis + taskInfo.extraTimeDuration
|
||||||
}, {
|
}, {
|
||||||
where: {
|
where: {
|
||||||
familyId: cache.familyId,
|
familyId: cache.familyId,
|
||||||
categoryId: taskInfo.categoryId
|
categoryId: taskInfo.categoryId
|
||||||
},
|
},
|
||||||
transaction: cache.transaction
|
transaction: cache.transaction.legacy.transaction
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
cache.categoriesWithModifiedBaseData.add(taskInfo.categoryId)
|
cache.categoriesWithModifiedBaseData.add(taskInfo.categoryId)
|
||||||
|
|
||||||
await cache.database.childTask.update({
|
await cache.transaction.legacy.database.childTask.update({
|
||||||
pendingRequest: 0,
|
pendingRequest: 0,
|
||||||
lastGrantTimestamp: action.time.toString(10)
|
lastGrantTimestamp: action.time.toString(10)
|
||||||
}, {
|
}, {
|
||||||
@@ -96,19 +96,19 @@ export async function dispatchReviewChildTaskAction ({ action, cache }: {
|
|||||||
familyId: cache.familyId,
|
familyId: cache.familyId,
|
||||||
taskId: action.taskId
|
taskId: action.taskId
|
||||||
},
|
},
|
||||||
transaction: cache.transaction
|
transaction: cache.transaction.legacy.transaction
|
||||||
})
|
})
|
||||||
|
|
||||||
cache.incrementTriggeredSyncLevel(2)
|
cache.incrementTriggeredSyncLevel(2)
|
||||||
} else {
|
} else {
|
||||||
await cache.database.childTask.update({
|
await cache.transaction.legacy.database.childTask.update({
|
||||||
pendingRequest: 0
|
pendingRequest: 0
|
||||||
}, {
|
}, {
|
||||||
where: {
|
where: {
|
||||||
familyId: cache.familyId,
|
familyId: cache.familyId,
|
||||||
taskId: action.taskId
|
taskId: action.taskId
|
||||||
},
|
},
|
||||||
transaction: cache.transaction
|
transaction: cache.transaction.legacy.transaction
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* server component for the TimeLimit App
|
* server component for the TimeLimit App
|
||||||
* Copyright (C) 2019 - 2022 Jonas Lochmann
|
* Copyright (C) 2019 - 2026 Jonas Lochmann
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU Affero General Public License as
|
* it under the terms of the GNU Affero General Public License as
|
||||||
@@ -28,19 +28,19 @@ export async function dispatchSetCategoryExtraTime ({ action, cache }: {
|
|||||||
throw new PremiumVersionMissingException()
|
throw new PremiumVersionMissingException()
|
||||||
}
|
}
|
||||||
|
|
||||||
const oldItem = await cache.database.category.findOne({
|
const oldItem = await cache.transaction.legacy.database.category.findOne({
|
||||||
where: {
|
where: {
|
||||||
familyId: cache.familyId,
|
familyId: cache.familyId,
|
||||||
categoryId: action.categoryId
|
categoryId: action.categoryId
|
||||||
},
|
},
|
||||||
transaction: cache.transaction
|
transaction: cache.transaction.legacy.transaction
|
||||||
})
|
})
|
||||||
|
|
||||||
if (!oldItem) {
|
if (!oldItem) {
|
||||||
throw new MissingCategoryException()
|
throw new MissingCategoryException()
|
||||||
}
|
}
|
||||||
|
|
||||||
await cache.database.category.update({
|
await cache.transaction.legacy.database.category.update({
|
||||||
extraTimeInMillis: action.newExtraTime,
|
extraTimeInMillis: action.newExtraTime,
|
||||||
extraTimeDay: action.day
|
extraTimeDay: action.day
|
||||||
}, {
|
}, {
|
||||||
@@ -48,7 +48,7 @@ export async function dispatchSetCategoryExtraTime ({ action, cache }: {
|
|||||||
familyId: cache.familyId,
|
familyId: cache.familyId,
|
||||||
categoryId: action.categoryId
|
categoryId: action.categoryId
|
||||||
},
|
},
|
||||||
transaction: cache.transaction
|
transaction: cache.transaction.legacy.transaction
|
||||||
})
|
})
|
||||||
|
|
||||||
cache.categoriesWithModifiedBaseData.add(action.categoryId)
|
cache.categoriesWithModifiedBaseData.add(action.categoryId)
|
||||||
|
|||||||
+7
-7
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* server component for the TimeLimit App
|
* server component for the TimeLimit App
|
||||||
* Copyright (C) 2019 - 2022 Jonas Lochmann
|
* Copyright (C) 2019 - 2026 Jonas Lochmann
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU Affero General Public License as
|
* it under the terms of the GNU Affero General Public License as
|
||||||
@@ -24,13 +24,13 @@ export async function dispatchSetCategoryForUnassignedApps ({ action, cache }: {
|
|||||||
action: SetCategoryForUnassignedAppsAction
|
action: SetCategoryForUnassignedAppsAction
|
||||||
cache: Cache
|
cache: Cache
|
||||||
}) {
|
}) {
|
||||||
const oldUserEntry = await cache.database.user.findOne({
|
const oldUserEntry = await cache.transaction.legacy.database.user.findOne({
|
||||||
where: {
|
where: {
|
||||||
familyId: cache.familyId,
|
familyId: cache.familyId,
|
||||||
userId: action.childId,
|
userId: action.childId,
|
||||||
type: 'child'
|
type: 'child'
|
||||||
},
|
},
|
||||||
transaction: cache.transaction
|
transaction: cache.transaction.legacy.transaction
|
||||||
})
|
})
|
||||||
|
|
||||||
if (!oldUserEntry) {
|
if (!oldUserEntry) {
|
||||||
@@ -40,13 +40,13 @@ export async function dispatchSetCategoryForUnassignedApps ({ action, cache }: {
|
|||||||
if (action.categoryId === '') {
|
if (action.categoryId === '') {
|
||||||
// nothing to check
|
// nothing to check
|
||||||
} else {
|
} else {
|
||||||
const categoryEntryUnsafe = await cache.database.category.findOne({
|
const categoryEntryUnsafe = await cache.transaction.legacy.database.category.findOne({
|
||||||
attributes: ['childId'],
|
attributes: ['childId'],
|
||||||
where: {
|
where: {
|
||||||
familyId: cache.familyId,
|
familyId: cache.familyId,
|
||||||
categoryId: action.categoryId
|
categoryId: action.categoryId
|
||||||
},
|
},
|
||||||
transaction: cache.transaction
|
transaction: cache.transaction.legacy.transaction
|
||||||
})
|
})
|
||||||
|
|
||||||
if (!categoryEntryUnsafe) {
|
if (!categoryEntryUnsafe) {
|
||||||
@@ -66,7 +66,7 @@ export async function dispatchSetCategoryForUnassignedApps ({ action, cache }: {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
await cache.database.user.update({
|
await cache.transaction.legacy.database.user.update({
|
||||||
categoryForNotAssignedApps: action.categoryId
|
categoryForNotAssignedApps: action.categoryId
|
||||||
}, {
|
}, {
|
||||||
where: {
|
where: {
|
||||||
@@ -74,7 +74,7 @@ export async function dispatchSetCategoryForUnassignedApps ({ action, cache }: {
|
|||||||
userId: action.childId,
|
userId: action.childId,
|
||||||
type: 'child'
|
type: 'child'
|
||||||
},
|
},
|
||||||
transaction: cache.transaction
|
transaction: cache.transaction.legacy.transaction
|
||||||
})
|
})
|
||||||
|
|
||||||
cache.invalidiateUserList = true
|
cache.invalidiateUserList = true
|
||||||
|
|||||||
@@ -24,13 +24,13 @@ export async function dispatchSetChildPassword ({ action, cache }: {
|
|||||||
action: SetChildPasswordAction
|
action: SetChildPasswordAction
|
||||||
cache: Cache
|
cache: Cache
|
||||||
}) {
|
}) {
|
||||||
const childEntry = await cache.database.user.findOne({
|
const childEntry = await cache.transaction.legacy.database.user.findOne({
|
||||||
where: {
|
where: {
|
||||||
familyId: cache.familyId,
|
familyId: cache.familyId,
|
||||||
userId: action.childUserId,
|
userId: action.childUserId,
|
||||||
type: 'child'
|
type: 'child'
|
||||||
},
|
},
|
||||||
transaction: cache.transaction
|
transaction: cache.transaction.legacy.transaction
|
||||||
})
|
})
|
||||||
|
|
||||||
if (!childEntry) {
|
if (!childEntry) {
|
||||||
@@ -43,7 +43,7 @@ export async function dispatchSetChildPassword ({ action, cache }: {
|
|||||||
childEntry.secondPasswordSalt = newPassword.secondSalt
|
childEntry.secondPasswordSalt = newPassword.secondSalt
|
||||||
childEntry.secondPasswordHash = newPassword.secondHash
|
childEntry.secondPasswordHash = newPassword.secondHash
|
||||||
|
|
||||||
await childEntry.save({ transaction: cache.transaction })
|
await childEntry.save({ transaction: cache.transaction.legacy.transaction })
|
||||||
|
|
||||||
{
|
{
|
||||||
const clear = cache.getSecondPasswordHashOfChild.cache.clear
|
const clear = cache.getSecondPasswordHashOfChild.cache.clear
|
||||||
|
|||||||
+5
-5
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* server component for the TimeLimit App
|
* server component for the TimeLimit App
|
||||||
* Copyright (C) 2019 - 2022 Jonas Lochmann
|
* Copyright (C) 2019 - 2026 Jonas Lochmann
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU Affero General Public License as
|
* it under the terms of the GNU Affero General Public License as
|
||||||
@@ -23,8 +23,8 @@ export async function dispatchSetConsiderRebootManipulation ({ action, cache }:
|
|||||||
action: SetConsiderRebootManipulationAction
|
action: SetConsiderRebootManipulationAction
|
||||||
cache: Cache
|
cache: Cache
|
||||||
}) {
|
}) {
|
||||||
const oldDevice = await cache.database.device.findOne({
|
const oldDevice = await cache.transaction.legacy.database.device.findOne({
|
||||||
transaction: cache.transaction,
|
transaction: cache.transaction.legacy.transaction,
|
||||||
where: {
|
where: {
|
||||||
familyId: cache.familyId,
|
familyId: cache.familyId,
|
||||||
deviceId: action.deviceId
|
deviceId: action.deviceId
|
||||||
@@ -35,10 +35,10 @@ export async function dispatchSetConsiderRebootManipulation ({ action, cache }:
|
|||||||
throw new MissingDeviceException()
|
throw new MissingDeviceException()
|
||||||
}
|
}
|
||||||
|
|
||||||
await cache.database.device.update({
|
await cache.transaction.legacy.database.device.update({
|
||||||
considerRebootManipulation: action.enable
|
considerRebootManipulation: action.enable
|
||||||
}, {
|
}, {
|
||||||
transaction: cache.transaction,
|
transaction: cache.transaction.legacy.transaction,
|
||||||
where: {
|
where: {
|
||||||
familyId: cache.familyId,
|
familyId: cache.familyId,
|
||||||
deviceId: action.deviceId
|
deviceId: action.deviceId
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* server component for the TimeLimit App
|
* server component for the TimeLimit App
|
||||||
* Copyright (C) 2019 - 2022 Jonas Lochmann
|
* Copyright (C) 2019 - 2026 Jonas Lochmann
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU Affero General Public License as
|
* it under the terms of the GNU Affero General Public License as
|
||||||
@@ -31,8 +31,8 @@ export async function dispatchSetDeviceDefaultUser ({ action, cache }: {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const oldDeviceItem = await cache.database.device.findOne({
|
const oldDeviceItem = await cache.transaction.legacy.database.device.findOne({
|
||||||
transaction: cache.transaction,
|
transaction: cache.transaction.legacy.transaction,
|
||||||
where: {
|
where: {
|
||||||
familyId: cache.familyId,
|
familyId: cache.familyId,
|
||||||
deviceId: action.deviceId
|
deviceId: action.deviceId
|
||||||
@@ -43,10 +43,10 @@ export async function dispatchSetDeviceDefaultUser ({ action, cache }: {
|
|||||||
throw new MissingDeviceException()
|
throw new MissingDeviceException()
|
||||||
}
|
}
|
||||||
|
|
||||||
await cache.database.device.update({
|
await cache.transaction.legacy.database.device.update({
|
||||||
defaultUserId: action.defaultUserId
|
defaultUserId: action.defaultUserId
|
||||||
}, {
|
}, {
|
||||||
transaction: cache.transaction,
|
transaction: cache.transaction.legacy.transaction,
|
||||||
where: {
|
where: {
|
||||||
familyId: cache.familyId,
|
familyId: cache.familyId,
|
||||||
deviceId: action.deviceId
|
deviceId: action.deviceId
|
||||||
|
|||||||
+5
-5
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* server component for the TimeLimit App
|
* server component for the TimeLimit App
|
||||||
* Copyright (C) 2019 - 2020 Jonas Lochmann
|
* Copyright (C) 2019 - 2026 Jonas Lochmann
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU Affero General Public License as
|
* it under the terms of the GNU Affero General Public License as
|
||||||
@@ -23,8 +23,8 @@ export async function dispatchSetDeviceDefaultUserTimeout ({ action, cache }: {
|
|||||||
action: SetDeviceDefaultUserTimeoutAction
|
action: SetDeviceDefaultUserTimeoutAction
|
||||||
cache: Cache
|
cache: Cache
|
||||||
}) {
|
}) {
|
||||||
const oldDeviceItem = await cache.database.device.findOne({
|
const oldDeviceItem = await cache.transaction.legacy.database.device.findOne({
|
||||||
transaction: cache.transaction,
|
transaction: cache.transaction.legacy.transaction,
|
||||||
where: {
|
where: {
|
||||||
familyId: cache.familyId,
|
familyId: cache.familyId,
|
||||||
deviceId: action.deviceId
|
deviceId: action.deviceId
|
||||||
@@ -35,10 +35,10 @@ export async function dispatchSetDeviceDefaultUserTimeout ({ action, cache }: {
|
|||||||
throw new MissingDeviceException()
|
throw new MissingDeviceException()
|
||||||
}
|
}
|
||||||
|
|
||||||
await cache.database.device.update({
|
await cache.transaction.legacy.database.device.update({
|
||||||
defaultUserTimeout: action.timeout
|
defaultUserTimeout: action.timeout
|
||||||
}, {
|
}, {
|
||||||
transaction: cache.transaction,
|
transaction: cache.transaction.legacy.transaction,
|
||||||
where: {
|
where: {
|
||||||
familyId: cache.familyId,
|
familyId: cache.familyId,
|
||||||
deviceId: action.deviceId
|
deviceId: action.deviceId
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* server component for the TimeLimit App
|
* server component for the TimeLimit App
|
||||||
* Copyright (C) 2019 - 2022 Jonas Lochmann
|
* Copyright (C) 2019 - 2026 Jonas Lochmann
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU Affero General Public License as
|
* it under the terms of the GNU Affero General Public License as
|
||||||
@@ -31,19 +31,19 @@ export async function dispatchSetDeviceUser ({ action, cache }: {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const oldDeviceItem = await cache.database.device.findOne({
|
const oldDeviceItem = await cache.transaction.legacy.database.device.findOne({
|
||||||
where: {
|
where: {
|
||||||
familyId: cache.familyId,
|
familyId: cache.familyId,
|
||||||
deviceId: action.deviceId
|
deviceId: action.deviceId
|
||||||
},
|
},
|
||||||
transaction: cache.transaction
|
transaction: cache.transaction.legacy.transaction
|
||||||
})
|
})
|
||||||
|
|
||||||
if (!oldDeviceItem) {
|
if (!oldDeviceItem) {
|
||||||
throw new MissingDeviceException()
|
throw new MissingDeviceException()
|
||||||
}
|
}
|
||||||
|
|
||||||
await cache.database.device.update({
|
await cache.transaction.legacy.database.device.update({
|
||||||
currentUserId: action.userId,
|
currentUserId: action.userId,
|
||||||
isUserKeptSignedIn: false
|
isUserKeptSignedIn: false
|
||||||
}, {
|
}, {
|
||||||
@@ -51,7 +51,7 @@ export async function dispatchSetDeviceUser ({ action, cache }: {
|
|||||||
familyId: cache.familyId,
|
familyId: cache.familyId,
|
||||||
deviceId: action.deviceId
|
deviceId: action.deviceId
|
||||||
},
|
},
|
||||||
transaction: cache.transaction
|
transaction: cache.transaction.legacy.transaction
|
||||||
})
|
})
|
||||||
|
|
||||||
cache.invalidiateDeviceList = true
|
cache.invalidiateDeviceList = true
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* server component for the TimeLimit App
|
* server component for the TimeLimit App
|
||||||
* Copyright (C) 2019 - 2022 Jonas Lochmann
|
* Copyright (C) 2019 - 2026 Jonas Lochmann
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU Affero General Public License as
|
* it under the terms of the GNU Affero General Public License as
|
||||||
@@ -32,12 +32,12 @@ export async function dispatchSetKeepSignedIn ({ action, cache, parentUserId }:
|
|||||||
throw new SourceUserNotFoundException()
|
throw new SourceUserNotFoundException()
|
||||||
}
|
}
|
||||||
|
|
||||||
const deviceEntry = await cache.database.device.findOne({
|
const deviceEntry = await cache.transaction.legacy.database.device.findOne({
|
||||||
where: {
|
where: {
|
||||||
familyId: cache.familyId,
|
familyId: cache.familyId,
|
||||||
deviceId: action.deviceId
|
deviceId: action.deviceId
|
||||||
},
|
},
|
||||||
transaction: cache.transaction
|
transaction: cache.transaction.legacy.transaction
|
||||||
})
|
})
|
||||||
|
|
||||||
if (!deviceEntry) {
|
if (!deviceEntry) {
|
||||||
@@ -50,7 +50,7 @@ export async function dispatchSetKeepSignedIn ({ action, cache, parentUserId }:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const [affectedRows] = await cache.database.device.update({
|
const [affectedRows] = await cache.transaction.legacy.database.device.update({
|
||||||
isUserKeptSignedIn: action.keepSignedIn
|
isUserKeptSignedIn: action.keepSignedIn
|
||||||
}, {
|
}, {
|
||||||
where: {
|
where: {
|
||||||
@@ -58,7 +58,7 @@ export async function dispatchSetKeepSignedIn ({ action, cache, parentUserId }:
|
|||||||
deviceId: action.deviceId,
|
deviceId: action.deviceId,
|
||||||
currentUserId: deviceEntry.currentUserId
|
currentUserId: deviceEntry.currentUserId
|
||||||
},
|
},
|
||||||
transaction: cache.transaction
|
transaction: cache.transaction.legacy.transaction
|
||||||
})
|
})
|
||||||
|
|
||||||
if (affectedRows !== 0) {
|
if (affectedRows !== 0) {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* server component for the TimeLimit App
|
* server component for the TimeLimit App
|
||||||
* Copyright (C) 2019 - 2022 Jonas Lochmann
|
* Copyright (C) 2019 - 2026 Jonas Lochmann
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU Affero General Public License as
|
* it under the terms of the GNU Affero General Public License as
|
||||||
@@ -27,12 +27,12 @@ export async function dispatchSetParentCategory ({ action, cache, fromChildSelfL
|
|||||||
cache: Cache
|
cache: Cache
|
||||||
fromChildSelfLimitAddChildUserId: string | null
|
fromChildSelfLimitAddChildUserId: string | null
|
||||||
}) {
|
}) {
|
||||||
const categoryEntry = await cache.database.category.findOne({
|
const categoryEntry = await cache.transaction.legacy.database.category.findOne({
|
||||||
where: {
|
where: {
|
||||||
familyId: cache.familyId,
|
familyId: cache.familyId,
|
||||||
categoryId: action.categoryId
|
categoryId: action.categoryId
|
||||||
},
|
},
|
||||||
transaction: cache.transaction
|
transaction: cache.transaction.legacy.transaction
|
||||||
})
|
})
|
||||||
|
|
||||||
if (!categoryEntry) {
|
if (!categoryEntry) {
|
||||||
@@ -46,13 +46,13 @@ export async function dispatchSetParentCategory ({ action, cache, fromChildSelfL
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (action.parentCategory !== '') {
|
if (action.parentCategory !== '') {
|
||||||
const categoriesByUserId = (await cache.database.category.findAll({
|
const categoriesByUserId = (await cache.transaction.legacy.database.category.findAll({
|
||||||
where: {
|
where: {
|
||||||
familyId: cache.familyId,
|
familyId: cache.familyId,
|
||||||
childId: categoryEntry.childId
|
childId: categoryEntry.childId
|
||||||
},
|
},
|
||||||
attributes: ['categoryId', 'parentCategoryId'],
|
attributes: ['categoryId', 'parentCategoryId'],
|
||||||
transaction: cache.transaction
|
transaction: cache.transaction.legacy.transaction
|
||||||
})).map((item) => ({
|
})).map((item) => ({
|
||||||
categoryId: item.categoryId,
|
categoryId: item.categoryId,
|
||||||
parentCategoryId: item.parentCategoryId
|
parentCategoryId: item.parentCategoryId
|
||||||
@@ -107,14 +107,14 @@ export async function dispatchSetParentCategory ({ action, cache, fromChildSelfL
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
await cache.database.category.update({
|
await cache.transaction.legacy.database.category.update({
|
||||||
parentCategoryId: action.parentCategory
|
parentCategoryId: action.parentCategory
|
||||||
}, {
|
}, {
|
||||||
where: {
|
where: {
|
||||||
familyId: cache.familyId,
|
familyId: cache.familyId,
|
||||||
categoryId: action.categoryId
|
categoryId: action.categoryId
|
||||||
},
|
},
|
||||||
transaction: cache.transaction
|
transaction: cache.transaction.legacy.transaction
|
||||||
})
|
})
|
||||||
|
|
||||||
cache.categoriesWithModifiedBaseData.add(action.categoryId)
|
cache.categoriesWithModifiedBaseData.add(action.categoryId)
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* server component for the TimeLimit App
|
* server component for the TimeLimit App
|
||||||
* Copyright (C) 2019 - 2022 Jonas Lochmann
|
* Copyright (C) 2019 - 2026 Jonas Lochmann
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU Affero General Public License as
|
* it under the terms of the GNU Affero General Public License as
|
||||||
@@ -23,8 +23,8 @@ export async function dispatchSetRelaxPrimaryDevice ({ action, cache }: {
|
|||||||
action: SetRelaxPrimaryDeviceAction
|
action: SetRelaxPrimaryDeviceAction
|
||||||
cache: Cache
|
cache: Cache
|
||||||
}) {
|
}) {
|
||||||
const oldUser = cache.database.user.findOne({
|
const oldUser = cache.transaction.legacy.database.user.findOne({
|
||||||
transaction: cache.transaction,
|
transaction: cache.transaction.legacy.transaction,
|
||||||
where: {
|
where: {
|
||||||
familyId: cache.familyId,
|
familyId: cache.familyId,
|
||||||
userId: action.userId,
|
userId: action.userId,
|
||||||
@@ -36,10 +36,10 @@ export async function dispatchSetRelaxPrimaryDevice ({ action, cache }: {
|
|||||||
throw new MissingUserException()
|
throw new MissingUserException()
|
||||||
}
|
}
|
||||||
|
|
||||||
await cache.database.user.update({
|
await cache.transaction.legacy.database.user.update({
|
||||||
relaxPrimaryDeviceRule: action.relax
|
relaxPrimaryDeviceRule: action.relax
|
||||||
}, {
|
}, {
|
||||||
transaction: cache.transaction,
|
transaction: cache.transaction.legacy.transaction,
|
||||||
where: {
|
where: {
|
||||||
familyId: cache.familyId,
|
familyId: cache.familyId,
|
||||||
userId: action.userId,
|
userId: action.userId,
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* server component for the TimeLimit App
|
* server component for the TimeLimit App
|
||||||
* Copyright (C) 2019 - 2022 Jonas Lochmann
|
* Copyright (C) 2019 - 2026 Jonas Lochmann
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU Affero General Public License as
|
* it under the terms of the GNU Affero General Public License as
|
||||||
@@ -30,10 +30,10 @@ export async function dispatchSetSendDeviceConnected ({ action, cache, sourceDev
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
await cache.database.device.update({
|
await cache.transaction.legacy.database.device.update({
|
||||||
showDeviceConnected: action.enable
|
showDeviceConnected: action.enable
|
||||||
}, {
|
}, {
|
||||||
transaction: cache.transaction,
|
transaction: cache.transaction.legacy.transaction,
|
||||||
where: {
|
where: {
|
||||||
familyId: cache.familyId,
|
familyId: cache.familyId,
|
||||||
deviceId: action.deviceId
|
deviceId: action.deviceId
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* server component for the TimeLimit App
|
* server component for the TimeLimit App
|
||||||
* Copyright (C) 2019 - 2022 Jonas Lochmann
|
* Copyright (C) 2019 - 2026 Jonas Lochmann
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU Affero General Public License as
|
* it under the terms of the GNU Affero General Public License as
|
||||||
@@ -30,20 +30,20 @@ export async function dispatchUserSetDisableLimitsUntil ({ action, cache }: {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const oldUser = await cache.database.user.findOne({
|
const oldUser = await cache.transaction.legacy.database.user.findOne({
|
||||||
where: {
|
where: {
|
||||||
familyId: cache.familyId,
|
familyId: cache.familyId,
|
||||||
userId: action.childId,
|
userId: action.childId,
|
||||||
type: 'child'
|
type: 'child'
|
||||||
},
|
},
|
||||||
transaction: cache.transaction
|
transaction: cache.transaction.legacy.transaction
|
||||||
})
|
})
|
||||||
|
|
||||||
if (!oldUser) {
|
if (!oldUser) {
|
||||||
throw new MissingUserException()
|
throw new MissingUserException()
|
||||||
}
|
}
|
||||||
|
|
||||||
await cache.database.user.update({
|
await cache.transaction.legacy.database.user.update({
|
||||||
disableTimelimitsUntil: action.timestamp.toString(10)
|
disableTimelimitsUntil: action.timestamp.toString(10)
|
||||||
}, {
|
}, {
|
||||||
where: {
|
where: {
|
||||||
@@ -51,7 +51,7 @@ export async function dispatchUserSetDisableLimitsUntil ({ action, cache }: {
|
|||||||
userId: action.childId,
|
userId: action.childId,
|
||||||
type: 'child'
|
type: 'child'
|
||||||
},
|
},
|
||||||
transaction: cache.transaction
|
transaction: cache.transaction.legacy.transaction
|
||||||
})
|
})
|
||||||
|
|
||||||
cache.invalidiateUserList = true
|
cache.invalidiateUserList = true
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* server component for the TimeLimit App
|
* server component for the TimeLimit App
|
||||||
* Copyright (C) 2019 - 2022 Jonas Lochmann
|
* Copyright (C) 2019 - 2026 Jonas Lochmann
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU Affero General Public License as
|
* it under the terms of the GNU Affero General Public License as
|
||||||
@@ -23,22 +23,22 @@ export async function dispatchSetUserTimezone ({ action, cache }: {
|
|||||||
action: SetUserTimezoneAction
|
action: SetUserTimezoneAction
|
||||||
cache: Cache
|
cache: Cache
|
||||||
}) {
|
}) {
|
||||||
const oldUser = await cache.database.user.findOne({
|
const oldUser = await cache.transaction.legacy.database.user.findOne({
|
||||||
where: {
|
where: {
|
||||||
familyId: cache.familyId,
|
familyId: cache.familyId,
|
||||||
userId: action.userId
|
userId: action.userId
|
||||||
},
|
},
|
||||||
transaction: cache.transaction
|
transaction: cache.transaction.legacy.transaction
|
||||||
})
|
})
|
||||||
|
|
||||||
if (!oldUser) {
|
if (!oldUser) {
|
||||||
throw new MissingUserException()
|
throw new MissingUserException()
|
||||||
}
|
}
|
||||||
|
|
||||||
await cache.database.user.update({
|
await cache.transaction.legacy.database.user.update({
|
||||||
timeZone: action.timezone
|
timeZone: action.timezone
|
||||||
}, {
|
}, {
|
||||||
transaction: cache.transaction,
|
transaction: cache.transaction.legacy.transaction,
|
||||||
where: {
|
where: {
|
||||||
familyId: cache.familyId,
|
familyId: cache.familyId,
|
||||||
userId: action.userId
|
userId: action.userId
|
||||||
|
|||||||
+4
-4
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* server component for the TimeLimit App
|
* server component for the TimeLimit App
|
||||||
* Copyright (C) 2019 - 2022 Jonas Lochmann
|
* Copyright (C) 2019 - 2026 Jonas Lochmann
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU Affero General Public License as
|
* it under the terms of the GNU Affero General Public License as
|
||||||
@@ -23,12 +23,12 @@ export async function dispatchUpdateCategoryBatteryLimit ({ action, cache }: {
|
|||||||
action: UpdateCategoryBatteryLimitAction
|
action: UpdateCategoryBatteryLimitAction
|
||||||
cache: Cache
|
cache: Cache
|
||||||
}) {
|
}) {
|
||||||
const categoryEntry = await cache.database.category.findOne({
|
const categoryEntry = await cache.transaction.legacy.database.category.findOne({
|
||||||
where: {
|
where: {
|
||||||
familyId: cache.familyId,
|
familyId: cache.familyId,
|
||||||
categoryId: action.categoryId
|
categoryId: action.categoryId
|
||||||
},
|
},
|
||||||
transaction: cache.transaction
|
transaction: cache.transaction.legacy.transaction
|
||||||
})
|
})
|
||||||
|
|
||||||
if (!categoryEntry) {
|
if (!categoryEntry) {
|
||||||
@@ -43,7 +43,7 @@ export async function dispatchUpdateCategoryBatteryLimit ({ action, cache }: {
|
|||||||
categoryEntry.minBatteryMobile = action.mobileLimit
|
categoryEntry.minBatteryMobile = action.mobileLimit
|
||||||
}
|
}
|
||||||
|
|
||||||
await categoryEntry.save({ transaction: cache.transaction })
|
await categoryEntry.save({ transaction: cache.transaction.legacy.transaction })
|
||||||
|
|
||||||
cache.categoriesWithModifiedBaseData.add(action.categoryId)
|
cache.categoriesWithModifiedBaseData.add(action.categoryId)
|
||||||
cache.incrementTriggeredSyncLevel(2)
|
cache.incrementTriggeredSyncLevel(2)
|
||||||
|
|||||||
+5
-5
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* server component for the TimeLimit App
|
* server component for the TimeLimit App
|
||||||
* Copyright (C) 2019 - 2022 Jonas Lochmann
|
* Copyright (C) 2019 - 2026 Jonas Lochmann
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU Affero General Public License as
|
* it under the terms of the GNU Affero General Public License as
|
||||||
@@ -25,12 +25,12 @@ export async function dispatchUpdateCategoryBlockAllNotifications ({ action, cac
|
|||||||
cache: Cache
|
cache: Cache
|
||||||
fromChildSelfLimitAddChildUserId: string | null
|
fromChildSelfLimitAddChildUserId: string | null
|
||||||
}) {
|
}) {
|
||||||
const categoryEntryUnsafe = await cache.database.category.findOne({
|
const categoryEntryUnsafe = await cache.transaction.legacy.database.category.findOne({
|
||||||
where: {
|
where: {
|
||||||
familyId: cache.familyId,
|
familyId: cache.familyId,
|
||||||
categoryId: action.categoryId
|
categoryId: action.categoryId
|
||||||
},
|
},
|
||||||
transaction: cache.transaction,
|
transaction: cache.transaction.legacy.transaction,
|
||||||
attributes: ['childId', 'blockAllNotifications']
|
attributes: ['childId', 'blockAllNotifications']
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -57,7 +57,7 @@ export async function dispatchUpdateCategoryBlockAllNotifications ({ action, cac
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const [affectedRows] = await cache.database.category.update(action.blockDelay === undefined ? {
|
const [affectedRows] = await cache.transaction.legacy.database.category.update(action.blockDelay === undefined ? {
|
||||||
blockAllNotifications: action.blocked
|
blockAllNotifications: action.blocked
|
||||||
} : {
|
} : {
|
||||||
blockAllNotifications: action.blocked,
|
blockAllNotifications: action.blocked,
|
||||||
@@ -67,7 +67,7 @@ export async function dispatchUpdateCategoryBlockAllNotifications ({ action, cac
|
|||||||
familyId: cache.familyId,
|
familyId: cache.familyId,
|
||||||
categoryId: action.categoryId
|
categoryId: action.categoryId
|
||||||
},
|
},
|
||||||
transaction: cache.transaction
|
transaction: cache.transaction.legacy.transaction
|
||||||
})
|
})
|
||||||
|
|
||||||
if (affectedRows !== 0) {
|
if (affectedRows !== 0) {
|
||||||
|
|||||||
+5
-5
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* server component for the TimeLimit App
|
* server component for the TimeLimit App
|
||||||
* Copyright (C) 2019 - 2022 Jonas Lochmann
|
* Copyright (C) 2019 - 2026 Jonas Lochmann
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU Affero General Public License as
|
* it under the terms of the GNU Affero General Public License as
|
||||||
@@ -26,12 +26,12 @@ export async function dispatchUpdateCategoryBlockedTimes ({ action, cache, fromC
|
|||||||
cache: Cache
|
cache: Cache
|
||||||
fromChildSelfLimitAddChildUserId: string | null
|
fromChildSelfLimitAddChildUserId: string | null
|
||||||
}) {
|
}) {
|
||||||
const categoryEntryUnsafe = await cache.database.category.findOne({
|
const categoryEntryUnsafe = await cache.transaction.legacy.database.category.findOne({
|
||||||
where: {
|
where: {
|
||||||
familyId: cache.familyId,
|
familyId: cache.familyId,
|
||||||
categoryId: action.categoryId
|
categoryId: action.categoryId
|
||||||
},
|
},
|
||||||
transaction: cache.transaction,
|
transaction: cache.transaction.legacy.transaction,
|
||||||
attributes: ['childId', 'blockedMinutesInWeek']
|
attributes: ['childId', 'blockedMinutesInWeek']
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -59,14 +59,14 @@ export async function dispatchUpdateCategoryBlockedTimes ({ action, cache, fromC
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
await cache.database.category.update({
|
await cache.transaction.legacy.database.category.update({
|
||||||
blockedMinutesInWeek: action.blockedTimes
|
blockedMinutesInWeek: action.blockedTimes
|
||||||
}, {
|
}, {
|
||||||
where: {
|
where: {
|
||||||
familyId: cache.familyId,
|
familyId: cache.familyId,
|
||||||
categoryId: action.categoryId
|
categoryId: action.categoryId
|
||||||
},
|
},
|
||||||
transaction: cache.transaction
|
transaction: cache.transaction.legacy.transaction
|
||||||
})
|
})
|
||||||
|
|
||||||
cache.categoriesWithModifiedBaseData.add(action.categoryId)
|
cache.categoriesWithModifiedBaseData.add(action.categoryId)
|
||||||
|
|||||||
+5
-5
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* server component for the TimeLimit App
|
* server component for the TimeLimit App
|
||||||
* Copyright (C) 2019 - 2022 Jonas Lochmann
|
* Copyright (C) 2019 - 2026 Jonas Lochmann
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU Affero General Public License as
|
* it under the terms of the GNU Affero General Public License as
|
||||||
@@ -36,12 +36,12 @@ export async function dispatchUpdateCategoryDisableLimits ({ action, cache, from
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const categoryEntryUnsafe = await cache.database.category.findOne({
|
const categoryEntryUnsafe = await cache.transaction.legacy.database.category.findOne({
|
||||||
where: {
|
where: {
|
||||||
familyId: cache.familyId,
|
familyId: cache.familyId,
|
||||||
categoryId: action.categoryId
|
categoryId: action.categoryId
|
||||||
},
|
},
|
||||||
transaction: cache.transaction,
|
transaction: cache.transaction.legacy.transaction,
|
||||||
attributes: ['childId']
|
attributes: ['childId']
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -59,14 +59,14 @@ export async function dispatchUpdateCategoryDisableLimits ({ action, cache, from
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const [affectedRows] = await cache.database.category.update({
|
const [affectedRows] = await cache.transaction.legacy.database.category.update({
|
||||||
disableLimitsUntil: action.endTime.toString(10)
|
disableLimitsUntil: action.endTime.toString(10)
|
||||||
}, {
|
}, {
|
||||||
where: {
|
where: {
|
||||||
familyId: cache.familyId,
|
familyId: cache.familyId,
|
||||||
categoryId: action.categoryId
|
categoryId: action.categoryId
|
||||||
},
|
},
|
||||||
transaction: cache.transaction
|
transaction: cache.transaction.legacy.transaction
|
||||||
})
|
})
|
||||||
|
|
||||||
if (affectedRows !== 0) {
|
if (affectedRows !== 0) {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* server component for the TimeLimit App
|
* server component for the TimeLimit App
|
||||||
* Copyright (C) 2019 - 2022 Jonas Lochmann
|
* Copyright (C) 2019 - 2026 Jonas Lochmann
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU Affero General Public License as
|
* it under the terms of the GNU Affero General Public License as
|
||||||
@@ -24,12 +24,12 @@ export async function dispatchUpdateCategoryFlagsAction ({ action, cache }: {
|
|||||||
action: UpdateCategoryFlagsAction
|
action: UpdateCategoryFlagsAction
|
||||||
cache: Cache
|
cache: Cache
|
||||||
}) {
|
}) {
|
||||||
const categoryEntry = await cache.database.category.findOne({
|
const categoryEntry = await cache.transaction.legacy.database.category.findOne({
|
||||||
where: {
|
where: {
|
||||||
familyId: cache.familyId,
|
familyId: cache.familyId,
|
||||||
categoryId: action.categoryId
|
categoryId: action.categoryId
|
||||||
},
|
},
|
||||||
transaction: cache.transaction
|
transaction: cache.transaction.legacy.transaction
|
||||||
})
|
})
|
||||||
|
|
||||||
if (!categoryEntry) {
|
if (!categoryEntry) {
|
||||||
@@ -46,7 +46,7 @@ export async function dispatchUpdateCategoryFlagsAction ({ action, cache }: {
|
|||||||
|
|
||||||
categoryEntry.flags = newFlags.toString(10)
|
categoryEntry.flags = newFlags.toString(10)
|
||||||
|
|
||||||
await categoryEntry.save({ transaction: cache.transaction })
|
await categoryEntry.save({ transaction: cache.transaction.legacy.transaction })
|
||||||
|
|
||||||
cache.categoriesWithModifiedBaseData.add(action.categoryId)
|
cache.categoriesWithModifiedBaseData.add(action.categoryId)
|
||||||
cache.incrementTriggeredSyncLevel(2)
|
cache.incrementTriggeredSyncLevel(2)
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* server component for the TimeLimit App
|
* server component for the TimeLimit App
|
||||||
* Copyright (C) 2019 - 2022 Jonas Lochmann
|
* Copyright (C) 2019 - 2026 Jonas Lochmann
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU Affero General Public License as
|
* it under the terms of the GNU Affero General Public License as
|
||||||
@@ -30,10 +30,10 @@ export async function dispatchUpdateCategorySorting ({ action, cache }: {
|
|||||||
for (let i = 0; i < action.categoryIds.length; i++) {
|
for (let i = 0; i < action.categoryIds.length; i++) {
|
||||||
const categoryId = action.categoryIds[i]
|
const categoryId = action.categoryIds[i]
|
||||||
|
|
||||||
await cache.database.category.update({
|
await cache.transaction.legacy.database.category.update({
|
||||||
sort: i
|
sort: i
|
||||||
}, {
|
}, {
|
||||||
transaction: cache.transaction,
|
transaction: cache.transaction.legacy.transaction,
|
||||||
where: {
|
where: {
|
||||||
familyId: cache.familyId,
|
familyId: cache.familyId,
|
||||||
categoryId
|
categoryId
|
||||||
|
|||||||
+5
-5
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* server component for the TimeLimit App
|
* server component for the TimeLimit App
|
||||||
* Copyright (C) 2019 - 2022 Jonas Lochmann
|
* Copyright (C) 2019 - 2026 Jonas Lochmann
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU Affero General Public License as
|
* it under the terms of the GNU Affero General Public License as
|
||||||
@@ -32,12 +32,12 @@ export async function dispatchUpdateCategoryTemporarilyBlocked ({ action, cache,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const categoryEntryUnsafe = await cache.database.category.findOne({
|
const categoryEntryUnsafe = await cache.transaction.legacy.database.category.findOne({
|
||||||
where: {
|
where: {
|
||||||
familyId: cache.familyId,
|
familyId: cache.familyId,
|
||||||
categoryId: action.categoryId
|
categoryId: action.categoryId
|
||||||
},
|
},
|
||||||
transaction: cache.transaction,
|
transaction: cache.transaction.legacy.transaction,
|
||||||
attributes: ['childId', 'temporarilyBlocked', 'temporarilyBlockedEndTime']
|
attributes: ['childId', 'temporarilyBlocked', 'temporarilyBlockedEndTime']
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -67,7 +67,7 @@ export async function dispatchUpdateCategoryTemporarilyBlocked ({ action, cache,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const [affectedRows] = await cache.database.category.update({
|
const [affectedRows] = await cache.transaction.legacy.database.category.update({
|
||||||
temporarilyBlocked: action.blocked,
|
temporarilyBlocked: action.blocked,
|
||||||
temporarilyBlockedEndTime: action.blocked ? (action.endTime ?? 0).toString(10) : '0'
|
temporarilyBlockedEndTime: action.blocked ? (action.endTime ?? 0).toString(10) : '0'
|
||||||
}, {
|
}, {
|
||||||
@@ -75,7 +75,7 @@ export async function dispatchUpdateCategoryTemporarilyBlocked ({ action, cache,
|
|||||||
familyId: cache.familyId,
|
familyId: cache.familyId,
|
||||||
categoryId: action.categoryId
|
categoryId: action.categoryId
|
||||||
},
|
},
|
||||||
transaction: cache.transaction
|
transaction: cache.transaction.legacy.transaction
|
||||||
})
|
})
|
||||||
|
|
||||||
if (affectedRows !== 0) {
|
if (affectedRows !== 0) {
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user