Add new actions for activity level blocking

This commit is contained in:
Jonas L
2019-04-15 00:00:00 +00:00
parent 7fb3f9fb5b
commit 0af0ff961e
11 changed files with 408 additions and 0 deletions
@@ -47,6 +47,7 @@ import {
UpdateCategoryTemporarilyBlockedAction,
UpdateCategoryTitleAction,
UpdateDeviceNameAction,
UpdateEnableActivityLevelBlockingAction,
UpdateNetworkTimeVerificationAction,
UpdateParentNotificationFlagsAction,
UpdateTimelimitRuleAction
@@ -82,6 +83,7 @@ import { dispatchUpdateCategoryBlockedTimes } from './updatecategoryblockedtimes
import { dispatchUpdateCategoryTemporarilyBlocked } from './updatecategorytemporarilyblocked'
import { dispatchUpdateCategoryTitle } from './updatecategorytitle'
import { dispatchUpdateDeviceName } from './updatedevicename'
import { dispatchUpdateEnableActivityLevelBlocking } from './updateenableactivitylevelblocking'
import { dispatchUpdateNetworkTimeVerification } from './updatenetworktimeverification'
import { dispatchUpdateParentNotificationFlags } from './updateparentnotificationflags'
import { dispatchUpdateTimelimitRule } from './updatetimelimitrule'
@@ -144,6 +146,8 @@ export const dispatchParentAction = async ({ action, cache, parentUserId, source
await dispatchDeleteTimeLimitRule({ action, cache })
} else if (action instanceof UpdateDeviceNameAction) {
await dispatchUpdateDeviceName({ action, cache })
} else if (action instanceof UpdateEnableActivityLevelBlockingAction) {
await dispatchUpdateEnableActivityLevelBlocking({ action, cache })
} else if (action instanceof UpdateNetworkTimeVerificationAction) {
await dispatchUpdateNetworkTimeVerification({ action, cache })
} else if (action instanceof UpdateParentNotificationFlagsAction) {
@@ -0,0 +1,41 @@
/*
* server component for the TimeLimit App
* Copyright (C) 2019 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 { UpdateEnableActivityLevelBlockingAction } from '../../../../action'
import { Cache } from '../cache'
export async function dispatchUpdateEnableActivityLevelBlocking ({ action, cache }: {
action: UpdateEnableActivityLevelBlockingAction
cache: Cache
}) {
const [affectedRows] = await cache.database.device.update({
activityLevelBlocking: action.enable
}, {
transaction: cache.transaction,
where: {
familyId: cache.familyId,
deviceId: action.deviceId
}
})
if (affectedRows === 0) {
throw new Error('did not find device to update activity level blocking')
}
cache.invalidiateDeviceList = true
cache.areChangesImportant = true
}