Compare commits

...
Author SHA1 Message Date
Jonas Lochmann 6935c0811c Update dependencies 2025-12-29 01:00:00 +01:00
jonas-l 66001b547f Merge pull request 'chore: update base image to current node lts' (#43) from aveltens/timelimit-server:master into master
Reviewed-on: https://codeberg.org/timelimit/timelimit-server/pulls/43
2025-12-29 08:29:03 +01:00
aveltens c574fccda7 chore: update base image to current node lts 2025-12-28 20:23:12 +01:00
Jonas Lochmann 2cfa0babe1 Update dependencies 2025-12-01 01:00:00 +01:00
Jonas Lochmann 2f2d932d10 Update dependencies 2025-12-01 01:00:00 +01:00
Jonas Lochmann 1215c0c8a2 Add support for time limit rules that expire 2025-11-10 01:00:00 +01:00
Jonas Lochmann 93337e5e08 Add new send-mail-login-code-v2 error responses 2025-11-10 01:00:00 +01:00
Jonas Lochmann e871188661 Update dependencies 2025-11-10 01:00:00 +01:00
Jonas Lochmann ac9f655c44 Update dependencies 2025-10-20 02:00:00 +02:00
Jonas Lochmann 717d8f243a Update dependencies 2025-10-06 02:00:00 +02:00
Jonas Lochmann 6189601459 Update dependencies 2025-06-14 19:08:56 +02:00
Jonas Lochmann 569e5ce62d Update dependencies 2024-12-02 01:00:00 +01:00
Jonas Lochmann 6220cc6bb9 Update dependencies 2024-11-18 01:00:00 +01:00
Jonas Lochmann 33d9fd732f Update dependencies 2024-10-07 02:00:00 +02:00
Jonas Lochmann 764f240707 Update dependencies 2024-09-09 02:00:00 +02:00
Jonas Lochmann b392ca295a Update dependencies 2024-09-09 02:00:00 +02:00
Jonas Lochmann f5fc8e6cd6 Update dependencies 2024-08-19 02:00:00 +02:00
Jonas Lochmann 9c2048af64 Fix lint warnings 2024-07-29 02:00:00 +02:00
Jonas Lochmann b69271f7df Update umzug 2024-07-29 02:00:00 +02:00
Jonas Lochmann 97d2730b20 Update dependencies 2024-06-17 02:00:00 +02:00
Jonas Lochmann 0346197c23 Update dependencies 2024-06-10 02:00:00 +02:00
Jonas Lochmann a7ed01af74 Update dependencies 2024-06-03 02:00:00 +02:00
Jonas Lochmann f77d91ff56 Update dependencies 2024-04-29 02:00:00 +02:00
Jonas Lochmann 2d035da0da Update dependencies 2024-04-08 02:00:00 +02:00
Jonas Lochmann 2d73cba90e Update dependencies 2024-04-08 02:00:00 +02:00
Jonas Lochmann 1918c74277 Update dependencies 2024-03-25 01:00:00 +01:00
Jonas Lochmann e55d1fd1a9 Update dependencies 2024-03-18 01:00:00 +01:00
Jonas Lochmann f10b79a023 Add skipLibCheck to tsconfig.json 2024-03-18 01:00:00 +01:00
Jonas Lochmann 2c401288a3 Adjust json schema generation parameters 2024-03-18 01:00:00 +01:00
Jonas Lochmann 89f3325a18 Update dependencies 2024-03-04 01:00:00 +01:00
Jonas Lochmann 7aaad00881 Update dependencies 2024-02-05 01:00:00 +01:00
Jonas Lochmann c7e4cfc9f9 Add workaround for session duration change logic bug 2024-01-01 01:00:00 +01:00
162 changed files with 7569 additions and 9940 deletions
+1 -1
View File
@@ -1,4 +1,4 @@
FROM node:16-alpine FROM node:24-alpine
# Create app directories # Create app directories
RUN mkdir -p /usr/src/app RUN mkdir -p /usr/src/app
+4
View File
@@ -41,6 +41,10 @@ If a whitelist was configured and the mail address is not within it: ``{"mailAdd
If a blacklist was configured and the mail server is within it: ``{"mailServerBlacklisted": true}`` If a blacklist was configured and the mail server is within it: ``{"mailServerBlacklisted": true}``
If a temporarily blacklist was configured and the mail server is within it (used in case of known mail delivery issues): ``{"mailServerBlacklistedTemporarily": true}``
If the client is suspicious: ``{"blockedForIntegrityReasons": true}``
On success: a object with a ``mailLoginToken`` of the type string On success: a object with a ``mailLoginToken`` of the type string
#### example response #### example response
-58
View File
@@ -270,14 +270,6 @@
* [Untitled object in ClientPullChangesRequest](./clientpullchangesrequest-definitions-clientdatastatus-properties-devicesdetail.md) `https://timelimit.io/ClientPullChangesRequest#/definitions/ClientDataStatus/properties/devicesDetail` * [Untitled object in ClientPullChangesRequest](./clientpullchangesrequest-definitions-clientdatastatus-properties-devicesdetail.md) `https://timelimit.io/ClientPullChangesRequest#/definitions/ClientDataStatus/properties/devicesDetail`
* [Untitled object in ClientPullChangesRequest](./clientpullchangesrequest-definitions-clientdatastatus-properties-apps.md) `https://timelimit.io/ClientPullChangesRequest#/definitions/ClientDataStatus/properties/apps`
* [Untitled object in ClientPullChangesRequest](./clientpullchangesrequest-definitions-clientdatastatus-properties-categories.md) `https://timelimit.io/ClientPullChangesRequest#/definitions/ClientDataStatus/properties/categories`
* [Untitled object in ClientPullChangesRequest](./clientpullchangesrequest-definitions-clientdatastatus-properties-devicesdetail.md) `https://timelimit.io/ClientPullChangesRequest#/definitions/ClientDataStatus/properties/devicesDetail`
* [Untitled object in SerializedAppLogicAction](./serializedapplogicaction-definitions-serializedaddusedtimeactionversion2-properties-i-items.md) `https://timelimit.io/SerializedAppLogicAction#/definitions/SerializedAddUsedTimeActionVersion2/properties/i/items`
* [Untitled object in SerializedAppLogicAction](./serializedapplogicaction-definitions-serializedaddusedtimeactionversion2-properties-i-items.md) `https://timelimit.io/SerializedAppLogicAction#/definitions/SerializedAddUsedTimeActionVersion2/properties/i/items` * [Untitled object in SerializedAppLogicAction](./serializedapplogicaction-definitions-serializedaddusedtimeactionversion2-properties-i-items.md) `https://timelimit.io/SerializedAppLogicAction#/definitions/SerializedAddUsedTimeActionVersion2/properties/i/items`
### Arrays ### Arrays
@@ -306,32 +298,6 @@
* [Untitled array in SerializedAppLogicAction](./serializedapplogicaction-definitions-serializedupdateappactivitiesaction-properties-updatedoradded.md) `https://timelimit.io/SerializedAppLogicAction#/definitions/SerializedUpdateAppActivitiesAction/properties/updatedOrAdded` * [Untitled array in SerializedAppLogicAction](./serializedapplogicaction-definitions-serializedupdateappactivitiesaction-properties-updatedoradded.md) `https://timelimit.io/SerializedAppLogicAction#/definitions/SerializedUpdateAppActivitiesAction/properties/updatedOrAdded`
* [Untitled array in SerializedAppLogicAction](./serializedapplogicaction-definitions-serializedaddinstalledappsaction-properties-apps.md) `https://timelimit.io/SerializedAppLogicAction#/definitions/SerializedAddInstalledAppsAction/properties/apps`
* [Untitled array in SerializedAppLogicAction](./serializedapplogicaction-definitions-serializedaddusedtimeactionversion2-properties-i.md) `https://timelimit.io/SerializedAppLogicAction#/definitions/SerializedAddUsedTimeActionVersion2/properties/i`
* [Untitled array in SerializedAppLogicAction](./serializedapplogicaction-definitions-serializedaddusedtimeactionversion2-properties-i-items-properties-as.md) `https://timelimit.io/SerializedAppLogicAction#/definitions/SerializedAddUsedTimeActionVersion2/properties/i/items/properties/as`
* [Untitled array in SerializedAppLogicAction](./serializedapplogicaction-definitions-serializedaddusedtimeactionversion2-properties-i-items-properties-as-items.md) `https://timelimit.io/SerializedAppLogicAction#/definitions/SerializedAddUsedTimeActionVersion2/properties/i/items/properties/as/items`
* [Untitled array in SerializedAppLogicAction](./serializedapplogicaction-definitions-serializedaddusedtimeactionversion2-properties-i-items-properties-sdl.md) `https://timelimit.io/SerializedAppLogicAction#/definitions/SerializedAddUsedTimeActionVersion2/properties/i/items/properties/sdl`
* [Untitled array in SerializedAppLogicAction](./serializedapplogicaction-definitions-serializedaddusedtimeactionversion2-properties-i-items-properties-sdl-items.md) `https://timelimit.io/SerializedAppLogicAction#/definitions/SerializedAddUsedTimeActionVersion2/properties/i/items/properties/sdl/items`
* [Untitled array in SerializedAppLogicAction](./serializedapplogicaction-definitions-serializedremoveinstalledappsaction-properties-packagenames.md) `https://timelimit.io/SerializedAppLogicAction#/definitions/SerializedRemoveInstalledAppsAction/properties/packageNames`
* [Untitled array in SerializedAppLogicAction](./serializedapplogicaction-definitions-serializedupdateappactivitiesaction-properties-removed.md) `https://timelimit.io/SerializedAppLogicAction#/definitions/SerializedUpdateAppActivitiesAction/properties/removed`
* [Untitled array in SerializedAppLogicAction](./serializedapplogicaction-definitions-serializedupdateappactivitiesaction-properties-removed-items.md) `https://timelimit.io/SerializedAppLogicAction#/definitions/SerializedUpdateAppActivitiesAction/properties/removed/items`
* [Untitled array in SerializedAppLogicAction](./serializedapplogicaction-definitions-serializedupdateappactivitiesaction-properties-updatedoradded.md) `https://timelimit.io/SerializedAppLogicAction#/definitions/SerializedUpdateAppActivitiesAction/properties/updatedOrAdded`
* [Untitled array in SerializedParentAction](./serializedparentaction-definitions-serializedaddcategoryappsaction-properties-packagenames.md) `https://timelimit.io/SerializedParentAction#/definitions/SerializedAddCategoryAppsAction/properties/packageNames`
* [Untitled array in SerializedParentAction](./serializedparentaction-definitions-serializedremovecategoryappsaction-properties-packagenames.md) `https://timelimit.io/SerializedParentAction#/definitions/SerializedRemoveCategoryAppsAction/properties/packageNames`
* [Untitled array in SerializedParentAction](./serializedparentaction-definitions-serializedupdatecategorysortingaction-properties-categoryids.md) `https://timelimit.io/SerializedParentAction#/definitions/SerializedUpdateCategorySortingAction/properties/categoryIds`
* [Untitled array in SerializedParentAction](./serializedparentaction-definitions-serializedaddcategoryappsaction-properties-packagenames.md) `https://timelimit.io/SerializedParentAction#/definitions/SerializedAddCategoryAppsAction/properties/packageNames` * [Untitled array in SerializedParentAction](./serializedparentaction-definitions-serializedaddcategoryappsaction-properties-packagenames.md) `https://timelimit.io/SerializedParentAction#/definitions/SerializedAddCategoryAppsAction/properties/packageNames`
* [Untitled array in SerializedParentAction](./serializedparentaction-definitions-serializedremovecategoryappsaction-properties-packagenames.md) `https://timelimit.io/SerializedParentAction#/definitions/SerializedRemoveCategoryAppsAction/properties/packageNames` * [Untitled array in SerializedParentAction](./serializedparentaction-definitions-serializedremovecategoryappsaction-properties-packagenames.md) `https://timelimit.io/SerializedParentAction#/definitions/SerializedRemoveCategoryAppsAction/properties/packageNames`
@@ -382,30 +348,6 @@
* [Untitled array in ServerDataStatus](./serverdatastatus-definitions-u2fdata-properties-d.md) `https://timelimit.io/ServerDataStatus#/definitions/U2fData/properties/d` * [Untitled array in ServerDataStatus](./serverdatastatus-definitions-u2fdata-properties-d.md) `https://timelimit.io/ServerDataStatus#/definitions/U2fData/properties/d`
* [Untitled array in ServerDataStatus](./serverdatastatus-definitions-serverdevicelist-properties-data.md) `https://timelimit.io/ServerDataStatus#/definitions/ServerDeviceList/properties/data`
* [Untitled array in ServerDataStatus](./serverdatastatus-definitions-serverinstalledappsdata-properties-apps.md) `https://timelimit.io/ServerDataStatus#/definitions/ServerInstalledAppsData/properties/apps`
* [Untitled array in ServerDataStatus](./serverdatastatus-definitions-serverinstalledappsdata-properties-activities.md) `https://timelimit.io/ServerDataStatus#/definitions/ServerInstalledAppsData/properties/activities`
* [Untitled array in ServerDataStatus](./serverdatastatus-definitions-serverupdatedcategorybasedata-properties-networks.md) `https://timelimit.io/ServerDataStatus#/definitions/ServerUpdatedCategoryBaseData/properties/networks`
* [Untitled array in ServerDataStatus](./serverdatastatus-definitions-serverupdatedcategorybasedata-properties-atw.md) `https://timelimit.io/ServerDataStatus#/definitions/ServerUpdatedCategoryBaseData/properties/atw`
* [Untitled array in ServerDataStatus](./serverdatastatus-definitions-serverupdatedcategoryassignedapps-properties-apps.md) `https://timelimit.io/ServerDataStatus#/definitions/ServerUpdatedCategoryAssignedApps/properties/apps`
* [Untitled array in ServerDataStatus](./serverdatastatus-definitions-serverupdatedcategoryusedtimes-properties-times.md) `https://timelimit.io/ServerDataStatus#/definitions/ServerUpdatedCategoryUsedTimes/properties/times`
* [Untitled array in ServerDataStatus](./serverdatastatus-definitions-serverupdatedcategoryusedtimes-properties-sessiondurations.md) `https://timelimit.io/ServerDataStatus#/definitions/ServerUpdatedCategoryUsedTimes/properties/sessionDurations`
* [Untitled array in ServerDataStatus](./serverdatastatus-definitions-serverupdatedtimelimitrules-properties-rules.md) `https://timelimit.io/ServerDataStatus#/definitions/ServerUpdatedTimeLimitRules/properties/rules`
* [Untitled array in ServerDataStatus](./serverdatastatus-definitions-serverupdatedcategorytasks-properties-tasks.md) `https://timelimit.io/ServerDataStatus#/definitions/ServerUpdatedCategoryTasks/properties/tasks`
* [Untitled array in ServerDataStatus](./serverdatastatus-definitions-serveruserlist-properties-data.md) `https://timelimit.io/ServerDataStatus#/definitions/ServerUserList/properties/data`
* [Untitled array in ServerDataStatus](./serverdatastatus-definitions-u2fdata-properties-d.md) `https://timelimit.io/ServerDataStatus#/definitions/U2fData/properties/d`
## Version Note ## Version Note
The schemas linked above follow the JSON Schema Spec version: `http://json-schema.org/draft-07/schema#` The schemas linked above follow the JSON Schema Spec version: `http://json-schema.org/draft-07/schema#`
@@ -410,6 +410,9 @@
}, },
"perDay": { "perDay": {
"type": "boolean" "type": "boolean"
},
"e": {
"type": "number"
} }
}, },
"additionalProperties": false, "additionalProperties": false,
@@ -1458,6 +1461,9 @@
}, },
"perDay": { "perDay": {
"type": "boolean" "type": "boolean"
},
"e": {
"type": "number"
} }
}, },
"additionalProperties": false, "additionalProperties": false,
@@ -1,7 +1,7 @@
# EncryptableParentPassword Schema # EncryptableParentPassword Schema
```txt ```txt
https://timelimit.io/SerializedParentAction#/definitions/SerializedSetChildPasswordAction/properties/newPassword https://timelimit.io/SerializedParentAction#/definitions/EncryptableParentPassword
``` ```
@@ -10,11 +10,11 @@ https://timelimit.io/SerializedParentAction#/definitions/SerializedSetChildPassw
| :------------------ | :--------- | :------------- | :----------- | :---------------- | :-------------------- | :------------------ | :------------------------------------------------------------------------------------------------ | | :------------------ | :--------- | :------------- | :----------- | :---------------- | :-------------------- | :------------------ | :------------------------------------------------------------------------------------------------ |
| Can be instantiated | No | Unknown status | No | Forbidden | Forbidden | none | [SerializedParentAction.schema.json\*](SerializedParentAction.schema.json "open original schema") | | Can be instantiated | No | Unknown status | No | Forbidden | Forbidden | none | [SerializedParentAction.schema.json\*](SerializedParentAction.schema.json "open original schema") |
## newPassword Type ## EncryptableParentPassword Type
`object` ([EncryptableParentPassword](serializedparentaction-definitions-encryptableparentpassword.md)) `object` ([EncryptableParentPassword](serializedparentaction-definitions-encryptableparentpassword.md))
# newPassword Properties # EncryptableParentPassword Properties
| Property | Type | Required | Nullable | Defined by | | Property | Type | Required | Nullable | Defined by |
| :------------------------ | :-------- | :------- | :------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | :------------------------ | :-------- | :------- | :------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
@@ -0,0 +1,15 @@
# Untitled number in SerializedParentAction Schema
```txt
https://timelimit.io/SerializedParentAction#/definitions/SerializedTimeLimitRule/properties/e
```
| Abstract | Extensible | Status | Identifiable | Custom Properties | Additional Properties | Access Restrictions | Defined In |
| :------------------ | :--------- | :------------- | :---------------------- | :---------------- | :-------------------- | :------------------ | :------------------------------------------------------------------------------------------------ |
| Can be instantiated | No | Unknown status | Unknown identifiability | Forbidden | Allowed | none | [SerializedParentAction.schema.json\*](SerializedParentAction.schema.json "open original schema") |
## e Type
`number`
@@ -28,6 +28,7 @@ https://timelimit.io/SerializedParentAction#/definitions/SerializedTimeLimitRule
| [dur](#dur) | `number` | Optional | cannot be null | [SerializedParentAction](serializedparentaction-definitions-serializedtimelimitrule-properties-dur.md "https://timelimit.io/SerializedParentAction#/definitions/SerializedTimeLimitRule/properties/dur") | | [dur](#dur) | `number` | Optional | cannot be null | [SerializedParentAction](serializedparentaction-definitions-serializedtimelimitrule-properties-dur.md "https://timelimit.io/SerializedParentAction#/definitions/SerializedTimeLimitRule/properties/dur") |
| [pause](#pause) | `number` | Optional | cannot be null | [SerializedParentAction](serializedparentaction-definitions-serializedtimelimitrule-properties-pause.md "https://timelimit.io/SerializedParentAction#/definitions/SerializedTimeLimitRule/properties/pause") | | [pause](#pause) | `number` | Optional | cannot be null | [SerializedParentAction](serializedparentaction-definitions-serializedtimelimitrule-properties-pause.md "https://timelimit.io/SerializedParentAction#/definitions/SerializedTimeLimitRule/properties/pause") |
| [perDay](#perday) | `boolean` | Optional | cannot be null | [SerializedParentAction](serializedparentaction-definitions-serializedtimelimitrule-properties-perday.md "https://timelimit.io/SerializedParentAction#/definitions/SerializedTimeLimitRule/properties/perDay") | | [perDay](#perday) | `boolean` | Optional | cannot be null | [SerializedParentAction](serializedparentaction-definitions-serializedtimelimitrule-properties-perday.md "https://timelimit.io/SerializedParentAction#/definitions/SerializedTimeLimitRule/properties/perDay") |
| [e](#e) | `number` | Optional | cannot be null | [SerializedParentAction](serializedparentaction-definitions-serializedtimelimitrule-properties-e.md "https://timelimit.io/SerializedParentAction#/definitions/SerializedTimeLimitRule/properties/e") |
## ruleId ## ruleId
@@ -208,3 +209,21 @@ https://timelimit.io/SerializedParentAction#/definitions/SerializedTimeLimitRule
### perDay Type ### perDay Type
`boolean` `boolean`
## e
`e`
* is optional
* Type: `number`
* cannot be null
* defined in: [SerializedParentAction](serializedparentaction-definitions-serializedtimelimitrule-properties-e.md "https://timelimit.io/SerializedParentAction#/definitions/SerializedTimeLimitRule/properties/e")
### e Type
`number`
@@ -0,0 +1,15 @@
# Untitled number in SerializedParentAction Schema
```txt
https://timelimit.io/SerializedParentAction#/definitions/SerializedUpdateTimelimitRuleAction/properties/e
```
| Abstract | Extensible | Status | Identifiable | Custom Properties | Additional Properties | Access Restrictions | Defined In |
| :------------------ | :--------- | :------------- | :---------------------- | :---------------- | :-------------------- | :------------------ | :------------------------------------------------------------------------------------------------ |
| Can be instantiated | No | Unknown status | Unknown identifiability | Forbidden | Allowed | none | [SerializedParentAction.schema.json\*](SerializedParentAction.schema.json "open original schema") |
## e Type
`number`
@@ -0,0 +1,15 @@
# Untitled number in SerializedParentAction Schema
```txt
https://timelimit.io/SerializedParentAction#/definitions/SerializedUpdateTimelimitRuleAction/properties/expiresAt
```
| Abstract | Extensible | Status | Identifiable | Custom Properties | Additional Properties | Access Restrictions | Defined In |
| :------------------ | :--------- | :------------- | :---------------------- | :---------------- | :-------------------- | :------------------ | :------------------------------------------------------------------------------------------------ |
| Can be instantiated | No | Unknown status | Unknown identifiability | Forbidden | Allowed | none | [SerializedParentAction.schema.json\*](SerializedParentAction.schema.json "open original schema") |
## expiresAt Type
`number`
@@ -28,6 +28,7 @@ https://timelimit.io/SerializedParentAction#/definitions/SerializedUpdateTimelim
| [dur](#dur) | `number` | Optional | cannot be null | [SerializedParentAction](serializedparentaction-definitions-serializedupdatetimelimitruleaction-properties-dur.md "https://timelimit.io/SerializedParentAction#/definitions/SerializedUpdateTimelimitRuleAction/properties/dur") | | [dur](#dur) | `number` | Optional | cannot be null | [SerializedParentAction](serializedparentaction-definitions-serializedupdatetimelimitruleaction-properties-dur.md "https://timelimit.io/SerializedParentAction#/definitions/SerializedUpdateTimelimitRuleAction/properties/dur") |
| [pause](#pause) | `number` | Optional | cannot be null | [SerializedParentAction](serializedparentaction-definitions-serializedupdatetimelimitruleaction-properties-pause.md "https://timelimit.io/SerializedParentAction#/definitions/SerializedUpdateTimelimitRuleAction/properties/pause") | | [pause](#pause) | `number` | Optional | cannot be null | [SerializedParentAction](serializedparentaction-definitions-serializedupdatetimelimitruleaction-properties-pause.md "https://timelimit.io/SerializedParentAction#/definitions/SerializedUpdateTimelimitRuleAction/properties/pause") |
| [perDay](#perday) | `boolean` | Optional | cannot be null | [SerializedParentAction](serializedparentaction-definitions-serializedupdatetimelimitruleaction-properties-perday.md "https://timelimit.io/SerializedParentAction#/definitions/SerializedUpdateTimelimitRuleAction/properties/perDay") | | [perDay](#perday) | `boolean` | Optional | cannot be null | [SerializedParentAction](serializedparentaction-definitions-serializedupdatetimelimitruleaction-properties-perday.md "https://timelimit.io/SerializedParentAction#/definitions/SerializedUpdateTimelimitRuleAction/properties/perDay") |
| [e](#e) | `number` | Optional | cannot be null | [SerializedParentAction](serializedparentaction-definitions-serializedupdatetimelimitruleaction-properties-e.md "https://timelimit.io/SerializedParentAction#/definitions/SerializedUpdateTimelimitRuleAction/properties/e") |
## type ## type
@@ -216,3 +217,21 @@ https://timelimit.io/SerializedParentAction#/definitions/SerializedUpdateTimelim
### perDay Type ### perDay Type
`boolean` `boolean`
## e
`e`
* is optional
* Type: `number`
* cannot be null
* defined in: [SerializedParentAction](serializedparentaction-definitions-serializedupdatetimelimitruleaction-properties-e.md "https://timelimit.io/SerializedParentAction#/definitions/SerializedUpdateTimelimitRuleAction/properties/e")
### e Type
`number`
+38
View File
@@ -899,6 +899,7 @@ Reference this group by using
| [dur](#dur) | `number` | Optional | cannot be null | [SerializedParentAction](serializedparentaction-definitions-serializedtimelimitrule-properties-dur.md "https://timelimit.io/SerializedParentAction#/definitions/SerializedTimeLimitRule/properties/dur") | | [dur](#dur) | `number` | Optional | cannot be null | [SerializedParentAction](serializedparentaction-definitions-serializedtimelimitrule-properties-dur.md "https://timelimit.io/SerializedParentAction#/definitions/SerializedTimeLimitRule/properties/dur") |
| [pause](#pause) | `number` | Optional | cannot be null | [SerializedParentAction](serializedparentaction-definitions-serializedtimelimitrule-properties-pause.md "https://timelimit.io/SerializedParentAction#/definitions/SerializedTimeLimitRule/properties/pause") | | [pause](#pause) | `number` | Optional | cannot be null | [SerializedParentAction](serializedparentaction-definitions-serializedtimelimitrule-properties-pause.md "https://timelimit.io/SerializedParentAction#/definitions/SerializedTimeLimitRule/properties/pause") |
| [perDay](#perday) | `boolean` | Optional | cannot be null | [SerializedParentAction](serializedparentaction-definitions-serializedtimelimitrule-properties-perday.md "https://timelimit.io/SerializedParentAction#/definitions/SerializedTimeLimitRule/properties/perDay") | | [perDay](#perday) | `boolean` | Optional | cannot be null | [SerializedParentAction](serializedparentaction-definitions-serializedtimelimitrule-properties-perday.md "https://timelimit.io/SerializedParentAction#/definitions/SerializedTimeLimitRule/properties/perDay") |
| [e](#e) | `number` | Optional | cannot be null | [SerializedParentAction](serializedparentaction-definitions-serializedtimelimitrule-properties-e.md "https://timelimit.io/SerializedParentAction#/definitions/SerializedTimeLimitRule/properties/e") |
### ruleId ### ruleId
@@ -1080,6 +1081,24 @@ Reference this group by using
`boolean` `boolean`
### e
`e`
* is optional
* Type: `number`
* cannot be null
* defined in: [SerializedParentAction](serializedparentaction-definitions-serializedtimelimitrule-properties-e.md "https://timelimit.io/SerializedParentAction#/definitions/SerializedTimeLimitRule/properties/e")
#### e Type
`number`
## Definitions group SerializedDeleteCategoryAction ## Definitions group SerializedDeleteCategoryAction
Reference this group by using Reference this group by using
@@ -4397,6 +4416,7 @@ Reference this group by using
| [dur](#dur-1) | `number` | Optional | cannot be null | [SerializedParentAction](serializedparentaction-definitions-serializedupdatetimelimitruleaction-properties-dur.md "https://timelimit.io/SerializedParentAction#/definitions/SerializedUpdateTimelimitRuleAction/properties/dur") | | [dur](#dur-1) | `number` | Optional | cannot be null | [SerializedParentAction](serializedparentaction-definitions-serializedupdatetimelimitruleaction-properties-dur.md "https://timelimit.io/SerializedParentAction#/definitions/SerializedUpdateTimelimitRuleAction/properties/dur") |
| [pause](#pause-1) | `number` | Optional | cannot be null | [SerializedParentAction](serializedparentaction-definitions-serializedupdatetimelimitruleaction-properties-pause.md "https://timelimit.io/SerializedParentAction#/definitions/SerializedUpdateTimelimitRuleAction/properties/pause") | | [pause](#pause-1) | `number` | Optional | cannot be null | [SerializedParentAction](serializedparentaction-definitions-serializedupdatetimelimitruleaction-properties-pause.md "https://timelimit.io/SerializedParentAction#/definitions/SerializedUpdateTimelimitRuleAction/properties/pause") |
| [perDay](#perday-1) | `boolean` | Optional | cannot be null | [SerializedParentAction](serializedparentaction-definitions-serializedupdatetimelimitruleaction-properties-perday.md "https://timelimit.io/SerializedParentAction#/definitions/SerializedUpdateTimelimitRuleAction/properties/perDay") | | [perDay](#perday-1) | `boolean` | Optional | cannot be null | [SerializedParentAction](serializedparentaction-definitions-serializedupdatetimelimitruleaction-properties-perday.md "https://timelimit.io/SerializedParentAction#/definitions/SerializedUpdateTimelimitRuleAction/properties/perDay") |
| [e](#e-1) | `number` | Optional | cannot be null | [SerializedParentAction](serializedparentaction-definitions-serializedupdatetimelimitruleaction-properties-e.md "https://timelimit.io/SerializedParentAction#/definitions/SerializedUpdateTimelimitRuleAction/properties/e") |
### type ### type
@@ -4586,6 +4606,24 @@ Reference this group by using
`boolean` `boolean`
### e
`e`
* is optional
* Type: `number`
* cannot be null
* defined in: [SerializedParentAction](serializedparentaction-definitions-serializedupdatetimelimitruleaction-properties-e.md "https://timelimit.io/SerializedParentAction#/definitions/SerializedUpdateTimelimitRuleAction/properties/e")
#### e Type
`number`
## Definitions group SerializedUpdateUserFlagsAction ## Definitions group SerializedUpdateUserFlagsAction
Reference this group by using Reference this group by using
+3018 -5622
View File
File diff suppressed because it is too large Load Diff
+6 -8
View File
@@ -29,7 +29,7 @@
}, },
"homepage": "https://gitlab.com/timelimit.io/timelimit-server-2018#README", "homepage": "https://gitlab.com/timelimit.io/timelimit-server-2018#README",
"devDependencies": { "devDependencies": {
"@adobe/jsonschema2md": "^7.0.0", "@adobe/jsonschema2md": "^8.0.8",
"@types/basic-auth": "^1.1.3", "@types/basic-auth": "^1.1.3",
"@types/body-parser": "^1.19.0", "@types/body-parser": "^1.19.0",
"@types/ejs": "^3.1.0", "@types/ejs": "^3.1.0",
@@ -38,12 +38,11 @@
"@types/lodash": "^4.14.166", "@types/lodash": "^4.14.166",
"@types/node": "^16.11.59", "@types/node": "^16.11.59",
"@types/nodemailer": "^6.4.4", "@types/nodemailer": "^6.4.4",
"@types/umzug": "^2.3.0", "@typescript-eslint/eslint-plugin": "^7.18.0",
"@typescript-eslint/eslint-plugin": "^5.10.0", "@typescript-eslint/parser": "^7.18.0",
"@typescript-eslint/parser": "^5.10.0",
"eslint": "^8.7.0", "eslint": "^8.7.0",
"rimraf": "^3.0.2", "rimraf": "^3.0.2",
"typescript": "^4.4.4", "typescript": "^5.5.4",
"typescript-json-schema": "^0.52.0" "typescript-json-schema": "^0.52.0"
}, },
"dependencies": { "dependencies": {
@@ -57,14 +56,13 @@
"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": "^6.7.2", "nodemailer": "^7.0.9",
"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",
"sequelize": "^6.25.5", "sequelize": "^6.25.5",
"socket.io": "^4.0.1", "socket.io": "^4.0.1",
"sqlite3": "^4.0.0", "umzug": "^3.8.1"
"umzug": "^2.3.0"
}, },
"optionalDependencies": { "optionalDependencies": {
"sqlite3": "^5.0.0" "sqlite3": "^5.0.0"
+4 -2
View File
@@ -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 - 2024 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
@@ -58,7 +58,9 @@ const allTypes = [
const settings = { const settings = {
required: true, required: true,
noExtraProps: true noExtraProps: true,
// otherwise it finds errors in dependencies that we don't care about
ignoreErrors: true
}; };
const compilerOptions = { const compilerOptions = {
+17 -4
View File
@@ -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 - 2024 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,11 +32,12 @@ export class UpdateTimelimitRuleAction extends ParentAction {
readonly sessionDurationMilliseconds: number readonly sessionDurationMilliseconds: number
readonly sessionPauseMilliseconds: number readonly sessionPauseMilliseconds: number
readonly perDay: boolean readonly perDay: boolean
readonly expiresAt?: number
constructor ({ constructor ({
ruleId, maximumTimeInMillis, dayMask, applyToExtraTimeUsage, ruleId, maximumTimeInMillis, dayMask, applyToExtraTimeUsage,
start, end, sessionDurationMilliseconds, sessionPauseMilliseconds, start, end, sessionDurationMilliseconds, sessionPauseMilliseconds,
perDay perDay, expiresAt
}: { }: {
ruleId: string ruleId: string
maximumTimeInMillis: number maximumTimeInMillis: number
@@ -47,6 +48,7 @@ export class UpdateTimelimitRuleAction extends ParentAction {
sessionDurationMilliseconds: number sessionDurationMilliseconds: number
sessionPauseMilliseconds: number sessionPauseMilliseconds: number
perDay: boolean perDay: boolean
expiresAt?: number
}) { }) {
super() super()
@@ -59,6 +61,7 @@ export class UpdateTimelimitRuleAction extends ParentAction {
this.sessionDurationMilliseconds = sessionDurationMilliseconds this.sessionDurationMilliseconds = sessionDurationMilliseconds
this.sessionPauseMilliseconds = sessionPauseMilliseconds this.sessionPauseMilliseconds = sessionPauseMilliseconds
this.perDay = perDay this.perDay = perDay
this.expiresAt = expiresAt
assertIdWithinFamily({ actionType, field: 'ruleId', value: ruleId }) assertIdWithinFamily({ actionType, field: 'ruleId', value: ruleId })
@@ -92,9 +95,17 @@ export class UpdateTimelimitRuleAction extends ParentAction {
staticMessage: 'session duration lesser than zero' staticMessage: 'session duration lesser than zero'
}) })
} }
if (expiresAt !== undefined) {
assertSafeInteger({ actionType, field: 'expiresAt', value: expiresAt })
if (expiresAt <= 0) {
throwOutOfRange({ actionType, field: 'expiresAt', value: expiresAt })
}
}
} }
static parse = ({ ruleId, time, days, extraTime, start, end, dur, pause, perDay }: SerializedUpdateTimelimitRuleAction) => ( static parse = ({ ruleId, time, days, extraTime, start, end, dur, pause, perDay, e }: SerializedUpdateTimelimitRuleAction) => (
new UpdateTimelimitRuleAction({ new UpdateTimelimitRuleAction({
ruleId, ruleId,
maximumTimeInMillis: time, maximumTimeInMillis: time,
@@ -104,7 +115,8 @@ export class UpdateTimelimitRuleAction extends ParentAction {
end: end ?? MinuteOfDay.MAX, end: end ?? MinuteOfDay.MAX,
sessionDurationMilliseconds: dur ?? 0, sessionDurationMilliseconds: dur ?? 0,
sessionPauseMilliseconds: pause ?? 0, sessionPauseMilliseconds: pause ?? 0,
perDay: perDay ?? false perDay: perDay ?? false,
expiresAt: e
}) })
) )
} }
@@ -120,4 +132,5 @@ export interface SerializedUpdateTimelimitRuleAction {
dur?: number dur?: number
pause?: number pause?: number
perDay?: boolean perDay?: boolean
e?: number
} }
+6
View File
@@ -409,6 +409,9 @@ const definitions = {
}, },
"perDay": { "perDay": {
"type": "boolean" "type": "boolean"
},
"e": {
"type": "number"
} }
}, },
"additionalProperties": false, "additionalProperties": false,
@@ -1417,6 +1420,9 @@ const definitions = {
}, },
"perDay": { "perDay": {
"type": "boolean" "type": "boolean"
},
"e": {
"type": "number"
} }
}, },
"additionalProperties": false, "additionalProperties": false,
+2 -2
View File
@@ -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 - 2024 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,7 +26,7 @@ export const config = {
expireTimeRounding: 1000 * 60 * 15 expireTimeRounding: 1000 * 60 * 15
} }
export function calculateExpireTime(now: bigint): BigInt { export function calculateExpireTime(now: bigint): bigint {
const expireBaseTime = now + BigInt(config.expireDelay) const expireBaseTime = now + BigInt(config.expireDelay)
const expireTime = expireBaseTime - expireBaseTime % BigInt(config.expireTimeRounding) + BigInt(config.expireTimeRounding) const expireTime = expireBaseTime - expireBaseTime % BigInt(config.expireTimeRounding) + BigInt(config.expireTimeRounding)
@@ -0,0 +1,39 @@
/*
* server component for the TimeLimit App
* Copyright (C) 2019 - 2024 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 ruleAttributes } from '../../timelimitrule'
export async function up (queryInterface: QueryInterface, sequelize: Sequelize) {
await sequelize.transaction({
type: Transaction.TYPES.EXCLUSIVE
}, async (transaction) => {
await queryInterface.addColumn('TimelimitRules', 'expiresAt', {
...ruleAttributes.expiresAt
}, {
transaction
})
})
}
export async function down (queryInterface: QueryInterface, sequelize: Sequelize) {
await sequelize.transaction({
type: Transaction.TYPES.EXCLUSIVE
}, async (transaction) => {
await queryInterface.removeColumn('TimelimitRules', 'expiresAt', { transaction })
})
}
+17 -9
View File
@@ -1,6 +1,6 @@
/* /*
* server component for the TimeLimit App * server component for the TimeLimit App
* Copyright (C) 2019 Jonas Lochmann * Copyright (C) 2019 - 2024 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,18 +17,26 @@
import { resolve } from 'path' import { resolve } from 'path'
import { Sequelize } from 'sequelize' import { Sequelize } from 'sequelize'
import * as Umzug from 'umzug' import { Umzug, SequelizeStorage } from 'umzug'
export const createUmzug = (sequelize: Sequelize) => ( export const createUmzug = (sequelize: Sequelize) => (
new Umzug({ new Umzug({
storage: 'sequelize', storage: new SequelizeStorage({ sequelize }),
storageOptions: {
sequelize
},
migrations: { migrations: {
params: [sequelize.getQueryInterface(), sequelize], glob: resolve(__dirname, '../../../build/database/migration/migrations/*.js'),
path: resolve(__dirname, '../../../build/database/migration/migrations'), resolve: ({ name, path }) => {
pattern: /^\d+[\w-]+\.js$/ if (!path) throw new Error()
// eslint-disable-next-line @typescript-eslint/no-var-requires
const migration = require(path)
return {
name,
up: async () => migration.up(sequelize.getQueryInterface(), sequelize),
down: async () => migration.down(sequelize.getQueryInterface(), sequelize),
} }
},
},
logger: console
}) })
) )
+20 -3
View File
@@ -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 - 2024 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
@@ -41,8 +41,13 @@ interface TimelimitRuleAttributesVersion3 {
perDay: number perDay: number
} }
interface TimelimitRuleAttributesVersion4 {
expiresAt: string | null
}
type TimelimitRuleAttributes = TimelimitRuleAttributesVersion1 & type TimelimitRuleAttributes = TimelimitRuleAttributesVersion1 &
TimelimitRuleAttributesVersion2 & TimelimitRuleAttributesVersion3 TimelimitRuleAttributesVersion2 & TimelimitRuleAttributesVersion3 &
TimelimitRuleAttributesVersion4
export type TimelimitRuleModel = Sequelize.Model<TimelimitRuleAttributes> & TimelimitRuleAttributes export type TimelimitRuleModel = Sequelize.Model<TimelimitRuleAttributes> & TimelimitRuleAttributes
export type TimelimitRuleModelStatic = typeof Sequelize.Model & { export type TimelimitRuleModelStatic = typeof Sequelize.Model & {
@@ -137,10 +142,22 @@ export const attributesVersion3: SequelizeAttributes<TimelimitRuleAttributesVers
} }
} }
export const attributesVersion4: SequelizeAttributes<TimelimitRuleAttributesVersion4> = {
expiresAt: {
type: Sequelize.BIGINT,
validate: {
min: 1
},
allowNull: true,
defaultValue: null
}
}
export const attributes: SequelizeAttributes<TimelimitRuleAttributes> = { export const attributes: SequelizeAttributes<TimelimitRuleAttributes> = {
...attributesVersion1, ...attributesVersion1,
...attributesVersion2, ...attributesVersion2,
...attributesVersion3 ...attributesVersion3,
...attributesVersion4
} }
export const createTimelimitRuleModel = (sequelize: Sequelize.Sequelize): TimelimitRuleModelStatic => sequelize.define('TimelimitRule', attributes) as TimelimitRuleModelStatic export const createTimelimitRuleModel = (sequelize: Sequelize.Sequelize): TimelimitRuleModelStatic => sequelize.define('TimelimitRule', attributes) as TimelimitRuleModelStatic
@@ -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 - 2023 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,7 @@
* 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 { AddUsedTimeActionVersion2 } from '../../../../action' import { AddUsedTimeActionVersion2 } from '../../../../action'
import { EventHandler } from '../../../../monitoring/eventhandler' import { EventHandler } from '../../../../monitoring/eventhandler'
import { MinuteOfDay } from '../../../../util/minuteofday' import { MinuteOfDay } from '../../../../util/minuteofday'
@@ -22,6 +23,8 @@ import { Cache } from '../cache'
import { IllegalStateException, SourceDeviceNotFoundException } from '../exception/illegal-state' import { IllegalStateException, SourceDeviceNotFoundException } from '../exception/illegal-state'
import { getRoundedTimestamp as getRoundedTimestampForUsedTime } from './addusedtime' import { getRoundedTimestamp as getRoundedTimestampForUsedTime } from './addusedtime'
const tolerance = 5 * 1000 // 5 seconds
export const getRoundedTimestampForSessionDuration = () => { export const getRoundedTimestampForSessionDuration = () => {
const now = Date.now() const now = Date.now()
@@ -129,11 +132,32 @@ export async function dispatchAddUsedTimeVersion2 ({ deviceId, action, cache, ev
} }
} }
} else { } else {
const oldTime: number | null = await cache.database.usedTime.aggregate(
'usedTime',
'MAX',
{
where: {
familyId: cache.familyId,
categoryId: item.categoryId,
dayOfEpoch: action.dayOfEpoch,
startMinuteOfDay: {
[Sequelize.Op.gte]: start
},
endMinuteOfDay: {
[Sequelize.Op.lte]: end
}
},
transaction: cache.transaction
}
) || 0
if (oldTime !== null && typeof oldTime !== 'number') throw new Error()
await cache.database.usedTime.create({ await cache.database.usedTime.create({
familyId: cache.familyId, familyId: cache.familyId,
categoryId: item.categoryId, categoryId: item.categoryId,
dayOfEpoch: action.dayOfEpoch, dayOfEpoch: action.dayOfEpoch,
usedTime: Math.max(0, Math.min(item.timeToAdd, lengthInMs)), usedTime: Math.max(0, Math.min(oldTime + item.timeToAdd, lengthInMs)),
lastUpdate: roundedTimestampForUsedTime, lastUpdate: roundedTimestampForUsedTime,
startMinuteOfDay: start, startMinuteOfDay: start,
endMinuteOfDay: end endMinuteOfDay: end
@@ -168,6 +192,39 @@ export async function dispatchAddUsedTimeVersion2 ({ deviceId, action, cache, ev
transaction: cache.transaction transaction: cache.transaction
}) })
const oldDuration: () => Promise<number> = async () => {
const fittingDurationItems = await cache.database.sessionDuration.findAll({
where: {
familyId: cache.familyId,
categoryId: item.categoryId,
startMinuteOfDay: {
[Sequelize.Op.gte]: limit.start
},
endMinuteOfDay: {
[Sequelize.Op.lte]: limit.end
},
maxSessionDuration: {
[Sequelize.Op.gte]: limit.duration
},
sessionPauseDuration: {
[Sequelize.Op.lte]: limit.pause
}
},
transaction: cache.transaction
})
const fittingDurationItemsLastUsageFiltered =
hasTrustedTimestamp ?
fittingDurationItems.filter((it) => {
action.trustedTimestamp - item.timeToAdd <=
parseInt(it.lastUsage, 10) + it.sessionPauseDuration - tolerance
}) : fittingDurationItems
return fittingDurationItemsLastUsageFiltered
.map((it) => it.lastSessionDuration)
.reduce((a, b) => Math.max(a, b), 0)
}
if (oldItem) { if (oldItem) {
let extendSession: boolean let extendSession: boolean
@@ -188,14 +245,13 @@ export async function dispatchAddUsedTimeVersion2 ({ deviceId, action, cache, ev
* Due to this, a session is reset if it would be over in a few seconds, too. * Due to this, a session is reset if it would be over in a few seconds, too.
*/ */
const tolerance = 5 * 1000 // 5 seconds
const timeWhenStartingCurrentUsage = action.trustedTimestamp - item.timeToAdd const timeWhenStartingCurrentUsage = action.trustedTimestamp - item.timeToAdd
const nextSessionStart = parseInt(oldItem.lastUsage, 10) + oldItem.sessionPauseDuration - tolerance const nextSessionStart = parseInt(oldItem.lastUsage, 10) + oldItem.sessionPauseDuration - tolerance
extendSession = timeWhenStartingCurrentUsage <= nextSessionStart extendSession = timeWhenStartingCurrentUsage <= nextSessionStart
} }
oldItem.lastSessionDuration = extendSession ? oldItem.lastSessionDuration + item.timeToAdd : item.timeToAdd oldItem.lastSessionDuration = extendSession ? oldItem.lastSessionDuration + item.timeToAdd : await oldDuration() + item.timeToAdd
oldItem.roundedLastUpdate = roundedTimestampForSessionDuration oldItem.roundedLastUpdate = roundedTimestampForSessionDuration
if (hasTrustedTimestamp) { if (hasTrustedTimestamp) {
@@ -215,7 +271,7 @@ export async function dispatchAddUsedTimeVersion2 ({ deviceId, action, cache, ev
endMinuteOfDay: limit.end, endMinuteOfDay: limit.end,
// end of primary key // end of primary key
lastUsage: action.trustedTimestamp.toString(10), lastUsage: action.trustedTimestamp.toString(10),
lastSessionDuration: item.timeToAdd, lastSessionDuration: await oldDuration() + item.timeToAdd,
roundedLastUpdate: roundedTimestampForSessionDuration roundedLastUpdate: roundedTimestampForSessionDuration
}, { transaction: cache.transaction }) }, { transaction: cache.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 - 2024 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
@@ -55,7 +55,8 @@ export async function dispatchCreateTimeLimitRule ({ action, cache, fromChildSel
endMinuteOfDay: action.rule.end, endMinuteOfDay: action.rule.end,
sessionDurationMilliseconds: action.rule.sessionDurationMilliseconds, sessionDurationMilliseconds: action.rule.sessionDurationMilliseconds,
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
}, { transaction: cache.transaction }) }, { transaction: cache.transaction })
cache.categoriesWithModifiedTimeLimitRules.add(action.rule.categoryId) cache.categoriesWithModifiedTimeLimitRules.add(action.rule.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 - 2024 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
@@ -81,7 +81,8 @@ export async function dispatchUpdateTimelimitRule ({
action.sessionDurationMilliseconds <= ruleEntry.sessionDurationMilliseconds && action.sessionDurationMilliseconds <= ruleEntry.sessionDurationMilliseconds &&
action.sessionPauseMilliseconds >= ruleEntry.sessionPauseMilliseconds action.sessionPauseMilliseconds >= ruleEntry.sessionPauseMilliseconds
)) && )) &&
(!action.perDay || ruleEntry.perDay || countOldAffectedDays <= 1) (!action.perDay || ruleEntry.perDay || countOldAffectedDays <= 1) &&
(action.expiresAt === undefined || (ruleEntry.expiresAt !== null && action.expiresAt >= parseInt(ruleEntry.expiresAt, 10)))
if (!isAtLeastAsStrictAsPreviously) { if (!isAtLeastAsStrictAsPreviously) {
throw new CanNotRelaxRestrictionsSelfLimitException() throw new CanNotRelaxRestrictionsSelfLimitException()
@@ -96,6 +97,7 @@ export async function dispatchUpdateTimelimitRule ({
ruleEntry.sessionDurationMilliseconds = action.sessionDurationMilliseconds ruleEntry.sessionDurationMilliseconds = action.sessionDurationMilliseconds
ruleEntry.sessionPauseMilliseconds = action.sessionPauseMilliseconds ruleEntry.sessionPauseMilliseconds = action.sessionPauseMilliseconds
ruleEntry.perDay = action.perDay ? 1 : 0 ruleEntry.perDay = action.perDay ? 1 : 0
ruleEntry.expiresAt = action.expiresAt ? action.expiresAt.toString() : null
await ruleEntry.save({ transaction: cache.transaction }) await ruleEntry.save({ transaction: cache.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 - 2024 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,7 +45,8 @@ export async function getRules ({ database, transaction, categoryIdsToSyncRules,
'endMinuteOfDay', 'endMinuteOfDay',
'sessionDurationMilliseconds', 'sessionDurationMilliseconds',
'sessionPauseMilliseconds', 'sessionPauseMilliseconds',
'perDay' 'perDay',
'expiresAt'
], ],
transaction transaction
})).map((item) => ({ })).map((item) => ({
@@ -58,7 +59,8 @@ export async function getRules ({ database, transaction, categoryIdsToSyncRules,
endMinuteOfDay: item.endMinuteOfDay, endMinuteOfDay: item.endMinuteOfDay,
sessionDurationMilliseconds: item.sessionDurationMilliseconds, sessionDurationMilliseconds: item.sessionDurationMilliseconds,
sessionPauseMilliseconds: item.sessionPauseMilliseconds, sessionPauseMilliseconds: item.sessionPauseMilliseconds,
perDay: item.perDay perDay: item.perDay,
expiresAt: item.expiresAt ? parseInt(item.expiresAt, 10) : undefined
})) }))
const getCategoryRulesVersion = (categoryId: string) => ( const getCategoryRulesVersion = (categoryId: string) => (
@@ -76,7 +78,8 @@ export async function getRules ({ database, transaction, categoryIdsToSyncRules,
end: item.endMinuteOfDay, end: item.endMinuteOfDay,
session: item.sessionDurationMilliseconds, session: item.sessionDurationMilliseconds,
pause: item.sessionPauseMilliseconds, pause: item.sessionPauseMilliseconds,
perDay: item.perDay !== 0 ? true : false perDay: item.perDay !== 0 ? true : false,
e: item.expiresAt
})), })),
version: getCategoryRulesVersion(categoryId) version: getCategoryRulesVersion(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 - 2024 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
@@ -58,7 +58,7 @@ export const generateServerDataStatus = async ({
familyEntry.hasFullVersion ? parseInt(familyEntry.fullVersionUntil, 10) : 0 familyEntry.hasFullVersion ? parseInt(familyEntry.fullVersionUntil, 10) : 0
), ),
message: await getStatusMessage({ database, transaction }) || undefined, message: await getStatusMessage({ database, transaction }) || undefined,
apiLevel: 7 apiLevel: 8
} }
if (familyEntry.deviceListVersion !== clientStatus.devices) { if (familyEntry.deviceListVersion !== clientStatus.devices) {
+19 -5
View File
@@ -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 - 2024 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,11 +29,12 @@ export class TimelimitRule {
readonly sessionDurationMilliseconds: number readonly sessionDurationMilliseconds: number
readonly sessionPauseMilliseconds: number readonly sessionPauseMilliseconds: number
readonly perDay: boolean readonly perDay: boolean
readonly expiresAt?: number
constructor ({ constructor ({
ruleId, categoryId, maxTimeInMillis, dayMask, applyToExtraTimeUsage, ruleId, categoryId, maxTimeInMillis, dayMask, applyToExtraTimeUsage,
start, end, sessionDurationMilliseconds, sessionPauseMilliseconds, start, end, sessionDurationMilliseconds, sessionPauseMilliseconds,
perDay perDay, expiresAt
}: { }: {
ruleId: string ruleId: string
categoryId: string categoryId: string
@@ -45,6 +46,7 @@ export class TimelimitRule {
sessionDurationMilliseconds: number sessionDurationMilliseconds: number
sessionPauseMilliseconds: number sessionPauseMilliseconds: number
perDay: boolean perDay: boolean
expiresAt?: number
}) { }) {
this.ruleId = ruleId this.ruleId = ruleId
this.categoryId = categoryId this.categoryId = categoryId
@@ -56,6 +58,7 @@ export class TimelimitRule {
this.sessionDurationMilliseconds = sessionDurationMilliseconds this.sessionDurationMilliseconds = sessionDurationMilliseconds
this.sessionPauseMilliseconds = sessionPauseMilliseconds this.sessionPauseMilliseconds = sessionPauseMilliseconds
this.perDay = perDay this.perDay = perDay
this.expiresAt = expiresAt
assertIdWithinFamily(ruleId) assertIdWithinFamily(ruleId)
assertIdWithinFamily(categoryId) assertIdWithinFamily(categoryId)
@@ -88,6 +91,14 @@ export class TimelimitRule {
if (sessionDurationMilliseconds < 0 || sessionPauseMilliseconds < 0) { if (sessionDurationMilliseconds < 0 || sessionPauseMilliseconds < 0) {
throw new ParseTimeLimitRuleException() throw new ParseTimeLimitRuleException()
} }
if (expiresAt !== undefined) {
if (!Number.isSafeInteger(expiresAt)) throw new ParseTimeLimitRuleException()
if (expiresAt <= 0) {
throw new ParseTimeLimitRuleException()
}
}
} }
serialize = (): SerializedTimeLimitRule => ({ serialize = (): SerializedTimeLimitRule => ({
@@ -99,10 +110,11 @@ export class TimelimitRule {
start: this.start, start: this.start,
end: this.end, end: this.end,
pause: this.sessionPauseMilliseconds, pause: this.sessionPauseMilliseconds,
dur: this.sessionDurationMilliseconds dur: this.sessionDurationMilliseconds,
e: this.expiresAt
}) })
static parse = ({ ruleId, categoryId, time, days, extraTime, start, end, dur, pause, perDay }: SerializedTimeLimitRule) => ( static parse = ({ ruleId, categoryId, time, days, extraTime, start, end, dur, pause, perDay, e }: SerializedTimeLimitRule) => (
new TimelimitRule({ new TimelimitRule({
ruleId, ruleId,
categoryId, categoryId,
@@ -113,7 +125,8 @@ export class TimelimitRule {
end: end ?? MinuteOfDay.MAX, end: end ?? MinuteOfDay.MAX,
sessionDurationMilliseconds: dur ?? 0, sessionDurationMilliseconds: dur ?? 0,
sessionPauseMilliseconds: pause ?? 0, sessionPauseMilliseconds: pause ?? 0,
perDay: perDay ?? false perDay: perDay ?? false,
expiresAt: e
}) })
) )
} }
@@ -129,6 +142,7 @@ export interface SerializedTimeLimitRule {
dur?: number dur?: number
pause?: number pause?: number
perDay?: boolean perDay?: boolean
e?: number // expiresAt
} }
export class ParseTimeLimitRuleException extends Error {} export class ParseTimeLimitRuleException extends Error {}
+2 -1
View File
@@ -11,7 +11,8 @@
"noUnusedParameters": false, "noUnusedParameters": false,
"noImplicitReturns": true, "noImplicitReturns": true,
"noFallthroughCasesInSwitch": true, "noFallthroughCasesInSwitch": true,
"sourceMap": true "sourceMap": true,
"skipLibCheck": true
}, },
"include": [ "include": [
"./src/**/*" "./src/**/*"