mirror of
https://codeberg.org/timelimit/timelimit-server.git
synced 2025-10-03 09:49:32 +02:00
Add columns for overlay permission
This commit is contained in:
parent
a2b07e7b95
commit
ae0f1c67aa
3 changed files with 71 additions and 4 deletions
|
@ -69,9 +69,14 @@ export interface DeviceAttributesVersion6 {
|
|||
considerRebootManipulation: boolean
|
||||
}
|
||||
|
||||
export interface DeviceAttributesVersion7 {
|
||||
currentOverlayPermission: RuntimePermissionStatus
|
||||
highestOverlayPermission: RuntimePermissionStatus
|
||||
}
|
||||
|
||||
export type DeviceAttributes = DeviceAttributesVersion1 & DeviceAttributesVersion2 &
|
||||
DeviceAttributesVersion3 & DeviceAttributesVersion4 & DeviceAttributesVersion5 &
|
||||
DeviceAttributesVersion6
|
||||
DeviceAttributesVersion6 & DeviceAttributesVersion7
|
||||
|
||||
export type DeviceInstance = Sequelize.Instance<DeviceAttributes> & DeviceAttributes
|
||||
export type DeviceModel = Sequelize.Model<DeviceInstance, DeviceAttributes>
|
||||
|
@ -175,13 +180,25 @@ export const attributesVersion6: SequelizeAttributes<DeviceAttributesVersion6> =
|
|||
}
|
||||
}
|
||||
|
||||
export const attributesVersion7: SequelizeAttributes<DeviceAttributesVersion7> = {
|
||||
currentOverlayPermission: {
|
||||
...createEnumColumn(runtimePermissionStatusValues),
|
||||
defaultValue: 'not granted'
|
||||
},
|
||||
highestOverlayPermission: {
|
||||
...createEnumColumn(runtimePermissionStatusValues),
|
||||
defaultValue: 'not granted'
|
||||
}
|
||||
}
|
||||
|
||||
export const attributes: SequelizeAttributes<DeviceAttributes> = {
|
||||
...attributesVersion1,
|
||||
...attributesVersion2,
|
||||
...attributesVersion3,
|
||||
...attributesVersion4,
|
||||
...attributesVersion5,
|
||||
...attributesVersion6
|
||||
...attributesVersion6,
|
||||
...attributesVersion7
|
||||
}
|
||||
|
||||
export const createDeviceModel = (sequelize: Sequelize.Sequelize): DeviceModel => sequelize.define<DeviceInstance, DeviceAttributes>('Device', attributes)
|
||||
|
@ -190,13 +207,15 @@ export const hasDeviceManipulation = (device: DeviceAttributes) => {
|
|||
const manipulationOfUsageStats = device.currentUsageStatsPermission !== device.highestUsageStatsPermission
|
||||
const manipulationOfNotificationAccess = device.currentNotificationAccessPermission !== device.highestNotificationAccessPermission
|
||||
const manipulationOfAppVersion = device.currentAppVersion !== device.highestAppVersion
|
||||
const manipulationOfOverlayPermission = device.currentOverlayPermission !== device.highestOverlayPermission
|
||||
|
||||
const hasActiveManipulationWarning = manipulationOfProtectionLevel ||
|
||||
manipulationOfUsageStats ||
|
||||
manipulationOfNotificationAccess ||
|
||||
manipulationOfAppVersion ||
|
||||
device.triedDisablingDeviceAdmin ||
|
||||
device.didReboot
|
||||
device.didReboot ||
|
||||
manipulationOfOverlayPermission
|
||||
|
||||
const hasAnyManipulation = hasActiveManipulationWarning || device.hadManipulation
|
||||
|
||||
|
|
|
@ -0,0 +1,46 @@
|
|||
/*
|
||||
* 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 { QueryInterface, Sequelize } from 'sequelize'
|
||||
import { attributesVersion7 } from '../../device'
|
||||
|
||||
export async function up (queryInterface: QueryInterface, sequelize: Sequelize) {
|
||||
await sequelize.transaction({
|
||||
type: 'EXCLUSIVE'
|
||||
}, async (transaction) => {
|
||||
await queryInterface.addColumn('Devices', 'currentOverlayPermission', {
|
||||
...attributesVersion7.currentOverlayPermission
|
||||
}, {
|
||||
transaction
|
||||
})
|
||||
|
||||
await queryInterface.addColumn('Devices', 'highestOverlayPermission', {
|
||||
...attributesVersion7.highestOverlayPermission
|
||||
}, {
|
||||
transaction
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
export async function down (queryInterface: QueryInterface, sequelize: Sequelize) {
|
||||
await sequelize.transaction({
|
||||
type: 'EXCLUSIVE'
|
||||
}, async (transaction) => {
|
||||
await queryInterface.removeColumn('Devices', 'currentOverlayPermission', { transaction })
|
||||
await queryInterface.removeColumn('Devices', 'highestOverlayPermission', { transaction })
|
||||
})
|
||||
}
|
|
@ -55,5 +55,7 @@ export const prepareDeviceEntry = ({ familyId, userId, deviceAuthToken, deviceId
|
|||
showDeviceConnected: false,
|
||||
defaultUserId: '',
|
||||
defaultUserTimeout: 0,
|
||||
considerRebootManipulation: false
|
||||
considerRebootManipulation: false,
|
||||
currentOverlayPermission: 'not granted',
|
||||
highestOverlayPermission: 'not granted'
|
||||
})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue