mirror of
https://codeberg.org/timelimit/timelimit-server.git
synced 2026-08-31 19:03:45 +02:00
Update dependencies
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
// tslint:disable
|
||||
import { ClientPushChangesRequest, ClientPullChangesRequest, MailAuthTokenRequestBody, CreateFamilyByMailTokenRequest, SignIntoFamilyRequest, RecoverParentPasswordRequest, CanRecoverPasswordRequest, RegisterChildDeviceRequest, SerializedParentAction, SerializedAppLogicAction, SerializedChildAction, CreateRegisterDeviceTokenRequest, CanDoPurchaseRequest, FinishPurchaseByGooglePlayRequest, LinkParentMailAddressRequest, UpdatePrimaryDeviceRequest, RemoveDeviceRequest, RequestWithAuthToken, SendMailLoginCodeRequest, SignInByMailCodeRequest } from './schema'
|
||||
const Ajv = require('ajv')
|
||||
import Ajv from 'ajv'
|
||||
const ajv = new Ajv()
|
||||
|
||||
const definitions = {
|
||||
|
||||
@@ -26,7 +26,7 @@ export interface AddDeviceTokenAttributes {
|
||||
createdAt: string
|
||||
}
|
||||
|
||||
export type AddDeviceTokenModel = Sequelize.Model & AddDeviceTokenAttributes
|
||||
export type AddDeviceTokenModel = Sequelize.Model<AddDeviceTokenAttributes> & AddDeviceTokenAttributes
|
||||
export type AddDeviceTokenModelStatic = typeof Sequelize.Model & {
|
||||
new (values?: object, options?: Sequelize.BuildOptions): AddDeviceTokenModel;
|
||||
}
|
||||
|
||||
+1
-1
@@ -29,7 +29,7 @@ export interface AppAttributes {
|
||||
recommendation: AppRecommendation
|
||||
}
|
||||
|
||||
export type AppModel = Sequelize.Model & AppAttributes
|
||||
export type AppModel = Sequelize.Model<AppAttributes> & AppAttributes
|
||||
export type AppModelStatic = typeof Sequelize.Model & {
|
||||
new (values?: object, options?: Sequelize.BuildOptions): AppModel;
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ export interface AppActivityAttributes {
|
||||
title: string
|
||||
}
|
||||
|
||||
export type AppActivityModel = Sequelize.Model & AppActivityAttributes
|
||||
export type AppActivityModel = Sequelize.Model<AppActivityAttributes> & AppActivityAttributes
|
||||
export type AppActivityModelStatic = typeof Sequelize.Model & {
|
||||
new (values?: object, options?: Sequelize.BuildOptions): AppActivityModel;
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ export interface AuthTokenAttributes {
|
||||
createdAt: string
|
||||
}
|
||||
|
||||
export type AuthTokenModel = Sequelize.Model & AuthTokenAttributes
|
||||
export type AuthTokenModel = Sequelize.Model<AuthTokenAttributes> & AuthTokenAttributes
|
||||
export type AuthTokenModelStatic = typeof Sequelize.Model & {
|
||||
new (values?: object, options?: Sequelize.BuildOptions): AuthTokenModel;
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ export interface CategoryAttributesVersion5 {
|
||||
}
|
||||
|
||||
export interface CategoryAttributesVersion6 {
|
||||
temporarilyBlockedEndTime: number
|
||||
temporarilyBlockedEndTime: string
|
||||
}
|
||||
|
||||
export interface CategoryAttributesVersion7 {
|
||||
@@ -78,7 +78,7 @@ export type CategoryAttributes = CategoryAttributesVersion1 & CategoryAttributes
|
||||
CategoryAttributesVersion6 & CategoryAttributesVersion7 & CategoryAttributesVersion8 &
|
||||
CategoryAttributesVersion9 & CategoryAttributesVersion10
|
||||
|
||||
export type CategoryModel = Sequelize.Model & CategoryAttributes
|
||||
export type CategoryModel = Sequelize.Model<CategoryAttributes> & CategoryAttributes
|
||||
export type CategoryModelStatic = typeof Sequelize.Model & {
|
||||
new (values?: object, options?: Sequelize.BuildOptions): CategoryModel;
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ export interface CategoryAppAttributes {
|
||||
packageName: string
|
||||
}
|
||||
|
||||
export type CategoryAppModel = Sequelize.Model & CategoryAppAttributes
|
||||
export type CategoryAppModel = Sequelize.Model<CategoryAppAttributes> & CategoryAppAttributes
|
||||
export type CategoryAppModelStatic = typeof Sequelize.Model & {
|
||||
new (values?: object, options?: Sequelize.BuildOptions): CategoryAppModel;
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ export interface CategoryNetworkIdAttributes {
|
||||
hashedNetworkId: string
|
||||
}
|
||||
|
||||
export type CategoryNetworkIdModel = Sequelize.Model & CategoryNetworkIdAttributes
|
||||
export type CategoryNetworkIdModel = Sequelize.Model<CategoryNetworkIdAttributes> & CategoryNetworkIdAttributes
|
||||
export type CategoryNetworkIdModelStatic = typeof Sequelize.Model & {
|
||||
new (values?: object, options?: Sequelize.BuildOptions): CategoryNetworkIdModel;
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ export interface ChildTaskAttributes {
|
||||
export const maxExtraTime = 1000 * 60 * 60 * 24
|
||||
export const maxTitleLength = 50
|
||||
|
||||
export type ChildTaskModel = Sequelize.Model & ChildTaskAttributes
|
||||
export type ChildTaskModel = Sequelize.Model<ChildTaskAttributes> & ChildTaskAttributes
|
||||
export type ChildTaskModelStatic = typeof Sequelize.Model & {
|
||||
new (values?: object, options?: Sequelize.BuildOptions): ChildTaskModel;
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ export interface ConfigAttributes {
|
||||
value: string | null
|
||||
}
|
||||
|
||||
export type ConfigModel = Sequelize.Model & ConfigAttributes
|
||||
export type ConfigModel = Sequelize.Model<ConfigAttributes> & ConfigAttributes
|
||||
export type ConfigModelStatic = typeof Sequelize.Model & {
|
||||
new (values?: object, options?: Sequelize.BuildOptions): ConfigModel;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* server component for the TimeLimit App
|
||||
* Copyright (C) 2019 Jonas Lochmann
|
||||
* Copyright (C) 2019 - 2020 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
|
||||
@@ -107,7 +107,7 @@ export type DeviceAttributes = DeviceAttributesVersion1 & DeviceAttributesVersio
|
||||
DeviceAttributesVersion6 & DeviceAttributesVersion7 & DeviceAttributesVersion8 &
|
||||
DeviceAttributesVersion9 & DeviceAttributesVersion10 & DeviceAttributesVersion11
|
||||
|
||||
export type DeviceModel = Sequelize.Model & DeviceAttributes
|
||||
export type DeviceModel = Sequelize.Model<DeviceAttributes> & DeviceAttributes
|
||||
export type DeviceModelStatic = typeof Sequelize.Model & {
|
||||
new (values?: object, options?: Sequelize.BuildOptions): DeviceModel;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* server component for the TimeLimit App
|
||||
* Copyright (C) 2019 Jonas Lochmann
|
||||
* Copyright (C) 2019 - 2020 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
|
||||
@@ -29,7 +29,7 @@ export interface FamilyAttributes {
|
||||
hasFullVersion: boolean
|
||||
}
|
||||
|
||||
export type FamilyModel = Sequelize.Model & FamilyAttributes
|
||||
export type FamilyModel = Sequelize.Model<FamilyAttributes> & FamilyAttributes
|
||||
export type FamilyModelStatic = typeof Sequelize.Model & {
|
||||
new (values?: object, options?: Sequelize.BuildOptions): FamilyModel;
|
||||
}
|
||||
|
||||
@@ -15,7 +15,6 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { Promise as BluePromise } from 'bluebird'
|
||||
import * as Sequelize from 'sequelize'
|
||||
import { generateIdWithinFamily } from '../util/token'
|
||||
import { AddDeviceTokenModelStatic, createAddDeviceTokenModel } from './adddevicetoken'
|
||||
@@ -107,9 +106,6 @@ class TestRollbackException extends NestedTransactionTestException {}
|
||||
class NestedTransactionsNotWorkingException extends NestedTransactionTestException { constructor () { super('NestedTransactionsNotWorkingException') } }
|
||||
class IllegalStateException extends NestedTransactionTestException {}
|
||||
|
||||
export const wrapPromise = <T>(promise: Promise<T>) => BluePromise.resolve(promise)
|
||||
export const warpPromiseReturner = <T>(fun: () => Promise<T>) => () => wrapPromise(fun())
|
||||
|
||||
export async function assertNestedTransactionsAreWorking (database: Database) {
|
||||
const testValue = generateIdWithinFamily()
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* server component for the TimeLimit App
|
||||
* Copyright (C) 2019 Jonas Lochmann
|
||||
* Copyright (C) 2019 - 2020 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
|
||||
@@ -27,7 +27,7 @@ export interface MailLoginTokenAttributes {
|
||||
remainingAttempts: number
|
||||
}
|
||||
|
||||
export type MailLoginTokenModel = Sequelize.Model & MailLoginTokenAttributes
|
||||
export type MailLoginTokenModel = Sequelize.Model<MailLoginTokenAttributes> & MailLoginTokenAttributes
|
||||
export type MailLoginTokenModelStatic = typeof Sequelize.Model & {
|
||||
new (values?: object, options?: Sequelize.BuildOptions): MailLoginTokenModel;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* server component for the TimeLimit App
|
||||
* Copyright (C) 2019 Jonas Lochmann
|
||||
* Copyright (C) 2019 - 2020 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
|
||||
@@ -23,7 +23,7 @@ export interface OldDeviceAttributes {
|
||||
deviceAuthToken: string
|
||||
}
|
||||
|
||||
export type OldDeviceModel = Sequelize.Model & OldDeviceAttributes
|
||||
export type OldDeviceModel = Sequelize.Model<OldDeviceAttributes> & OldDeviceAttributes
|
||||
export type OldDeviceModelStatic = typeof Sequelize.Model & {
|
||||
new (values?: object, options?: Sequelize.BuildOptions): OldDeviceModel;
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ export interface PurchaseAttributes {
|
||||
newFullVersionEndTime: string
|
||||
}
|
||||
|
||||
export type PurchaseModel = Sequelize.Model & PurchaseAttributes
|
||||
export type PurchaseModel = Sequelize.Model<PurchaseAttributes> & PurchaseAttributes
|
||||
export type PurchaseModelStatic = typeof Sequelize.Model & {
|
||||
new (values?: object, options?: Sequelize.BuildOptions): PurchaseModel;
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ interface SessionDurationAttributesVersion1 {
|
||||
|
||||
export type SessionDurationAttributes = SessionDurationAttributesVersion1
|
||||
|
||||
export type SessionDurationModel = Sequelize.Model & SessionDurationAttributes
|
||||
export type SessionDurationModel = Sequelize.Model<SessionDurationAttributes> & SessionDurationAttributes
|
||||
export type SessionDurationModelStatic = typeof Sequelize.Model & {
|
||||
new (values?: object, options?: Sequelize.BuildOptions): SessionDurationModel;
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ interface TimelimitRuleAttributesVersion3 {
|
||||
type TimelimitRuleAttributes = TimelimitRuleAttributesVersion1 &
|
||||
TimelimitRuleAttributesVersion2 & TimelimitRuleAttributesVersion3
|
||||
|
||||
export type TimelimitRuleModel = Sequelize.Model & TimelimitRuleAttributes
|
||||
export type TimelimitRuleModel = Sequelize.Model<TimelimitRuleAttributes> & TimelimitRuleAttributes
|
||||
export type TimelimitRuleModelStatic = typeof Sequelize.Model & {
|
||||
new (values?: object, options?: Sequelize.BuildOptions): TimelimitRuleModel;
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ export interface UsedTimeAttributesVersion3 {
|
||||
export type UsedTimeAttributes = UsedTimeAttributesVersion1 &
|
||||
UsedTimeAttributesVersion2 & UsedTimeAttributesVersion3
|
||||
|
||||
export type UsedTimeModel = Sequelize.Model & UsedTimeAttributes
|
||||
export type UsedTimeModel = Sequelize.Model<UsedTimeAttributes> & UsedTimeAttributes
|
||||
export type UsedTimeModelStatic = typeof Sequelize.Model & {
|
||||
new (values?: object, options?: Sequelize.BuildOptions): UsedTimeModel;
|
||||
}
|
||||
|
||||
@@ -70,7 +70,7 @@ export interface UserAttributesVersion6 {
|
||||
export type UserAttributes = UserAttributesVersion1 & UserAttributesVersion2 &
|
||||
UserAttributesVersion3 & UserAttributesVersion4 & UserAttributesVersion5 & UserAttributesVersion6
|
||||
|
||||
export type UserModel = Sequelize.Model & UserAttributes
|
||||
export type UserModel = Sequelize.Model<UserAttributes> & UserAttributes
|
||||
export type UserModelStatic = typeof Sequelize.Model & {
|
||||
new (values?: object, options?: Sequelize.BuildOptions): UserModel;
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ export interface UserLimitLoginCategoryAttributesVersion2 {
|
||||
|
||||
export type UserLimitLoginCategoryAttributes = UserLimitLoginCategoryAttributesVersion1 & UserLimitLoginCategoryAttributesVersion2
|
||||
|
||||
export type UserLimitLoginCategoryModel = Sequelize.Model & UserLimitLoginCategoryAttributes
|
||||
export type UserLimitLoginCategoryModel = Sequelize.Model<UserLimitLoginCategoryAttributes> & UserLimitLoginCategoryAttributes
|
||||
export type UserLimitLoginCategoryModelStatic = typeof Sequelize.Model & {
|
||||
new (values?: object, options?: Sequelize.BuildOptions): UserLimitLoginCategoryModel;
|
||||
}
|
||||
|
||||
@@ -110,7 +110,7 @@ export async function deleteFamilies ({ database, familiyIds }: {
|
||||
})
|
||||
|
||||
// device
|
||||
const oldDeviceAuthTokens = await database.device.findAll({
|
||||
const oldDeviceAuthTokens = (await database.device.findAll({
|
||||
where: {
|
||||
familyId: {
|
||||
[Sequelize.Op.in]: familiyIds
|
||||
@@ -118,7 +118,7 @@ export async function deleteFamilies ({ database, familiyIds }: {
|
||||
},
|
||||
attributes: ['deviceAuthToken'],
|
||||
transaction
|
||||
}).map((item) => item.deviceAuthToken)
|
||||
})).map((item) => item.deviceAuthToken)
|
||||
|
||||
await database.device.destroy({
|
||||
where: {
|
||||
@@ -131,14 +131,14 @@ export async function deleteFamilies ({ database, familiyIds }: {
|
||||
|
||||
// olddevice
|
||||
if (oldDeviceAuthTokens.length > 0) {
|
||||
const knownOldDeviceAuthTokens = await database.oldDevice.findAll({
|
||||
const knownOldDeviceAuthTokens = (await database.oldDevice.findAll({
|
||||
where: {
|
||||
deviceAuthToken: {
|
||||
[Sequelize.Op.in]: oldDeviceAuthTokens
|
||||
}
|
||||
},
|
||||
transaction
|
||||
}).map((item) => item.deviceAuthToken)
|
||||
})).map((item) => item.deviceAuthToken)
|
||||
|
||||
const oldDeviceAuthTokensToAdd = difference(oldDeviceAuthTokens, knownOldDeviceAuthTokens)
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ export async function deleteOldFamilies (database: Database) {
|
||||
|
||||
export async function findOldFamilyIds (database: Database) {
|
||||
return database.transaction(async (transaction) => {
|
||||
const familyIdsWithExpiredLicenses = await database.family.findAll({
|
||||
const familyIdsWithExpiredLicenses = (await database.family.findAll({
|
||||
where: {
|
||||
fullVersionUntil: {
|
||||
[Sequelize.Op.lt]: (Date.now() - 1000 * 60 * 60 * 24 * 90 /* 90 days */).toString(10)
|
||||
@@ -43,13 +43,13 @@ export async function findOldFamilyIds (database: Database) {
|
||||
},
|
||||
attributes: ['familyId'],
|
||||
transaction
|
||||
}).map((item) => item.familyId)
|
||||
})).map((item) => item.familyId)
|
||||
|
||||
if (familyIdsWithExpiredLicenses.length === 0) {
|
||||
return []
|
||||
}
|
||||
|
||||
const recentlyUsedFamilyIds = await database.device.findAll({
|
||||
const recentlyUsedFamilyIds = (await database.device.findAll({
|
||||
where: {
|
||||
familyId: {
|
||||
[Sequelize.Op.in]: familyIdsWithExpiredLicenses
|
||||
@@ -60,7 +60,7 @@ export async function findOldFamilyIds (database: Database) {
|
||||
},
|
||||
attributes: ['familyId'],
|
||||
transaction
|
||||
}).map((item) => item.familyId)
|
||||
})).map((item) => item.familyId)
|
||||
|
||||
return difference(familyIdsWithExpiredLicenses, recentlyUsedFamilyIds)
|
||||
})
|
||||
|
||||
@@ -41,7 +41,7 @@ export async function reportDeviceRemoved ({ database, deviceAuthToken, websocke
|
||||
|
||||
deviceEntry.didDeviceReportUninstall = true
|
||||
deviceEntry.deviceAuthToken = generateAuthToken() // invalidiate the token
|
||||
deviceEntry.save({ transaction })
|
||||
await deviceEntry.save({ transaction })
|
||||
|
||||
// invalidiate device list
|
||||
await database.family.update({
|
||||
|
||||
@@ -195,7 +195,7 @@ export async function dispatchAddUsedTimeVersion2 ({ deviceId, action, cache, ev
|
||||
startMinuteOfDay: limit.start,
|
||||
endMinuteOfDay: limit.end,
|
||||
// end of primary key
|
||||
lastUsage: action.trustedTimestamp,
|
||||
lastUsage: action.trustedTimestamp.toString(10),
|
||||
lastSessionDuration: item.timeToAdd,
|
||||
roundedLastUpdate: roundedTimestampForSessionDuration
|
||||
}, { transaction: cache.transaction })
|
||||
|
||||
@@ -90,7 +90,7 @@ export async function dispatchMarkTaskPendingAction ({ action, cache, deviceId }
|
||||
|
||||
const childInfo = { name: childInfoUnsafe.name }
|
||||
|
||||
await cache.database.childTask.update({ pendingRequest: true }, {
|
||||
await cache.database.childTask.update({ pendingRequest: 1 }, {
|
||||
where: {
|
||||
familyId: cache.familyId,
|
||||
taskId: action.taskId
|
||||
|
||||
@@ -50,21 +50,21 @@ export async function dispatchAddCategoryApps ({ action, cache, fromChildSelfLim
|
||||
}
|
||||
}
|
||||
|
||||
const categoriesOfSameChild = await cache.database.category.findAll({
|
||||
const categoriesOfSameChild = (await cache.database.category.findAll({
|
||||
where: {
|
||||
familyId: cache.familyId,
|
||||
childId
|
||||
},
|
||||
attributes: ['categoryId', 'parentCategoryId'],
|
||||
transaction: cache.transaction
|
||||
}).map((item) => ({
|
||||
})).map((item) => ({
|
||||
categoryId: item.categoryId,
|
||||
parentCategoryId: item.parentCategoryId
|
||||
}))
|
||||
|
||||
const userCategoryIds = categoriesOfSameChild.map((item) => item.categoryId)
|
||||
|
||||
const oldCategories = await cache.database.categoryApp.findAll({
|
||||
const oldCategories = (await cache.database.categoryApp.findAll({
|
||||
attributes: [ 'categoryId' ],
|
||||
group: [ 'categoryId' ],
|
||||
where: {
|
||||
@@ -77,7 +77,7 @@ export async function dispatchAddCategoryApps ({ action, cache, fromChildSelfLim
|
||||
}
|
||||
},
|
||||
transaction: cache.transaction
|
||||
}).map((item) => item.categoryId)
|
||||
})).map((item) => item.categoryId)
|
||||
|
||||
if (fromChildSelfLimitAddChildUserId !== null) {
|
||||
try {
|
||||
|
||||
@@ -65,7 +65,7 @@ export async function dispatchCreateCategory ({ action, cache, fromChildSelfLimi
|
||||
title: action.title,
|
||||
blockedMinutesInWeek: '',
|
||||
temporarilyBlocked: false,
|
||||
temporarilyBlockedEndTime: 0,
|
||||
temporarilyBlockedEndTime: '0',
|
||||
extraTimeInMillis: 0,
|
||||
extraTimeDay: -1,
|
||||
timeLimitRulesVersion: generateVersionId(),
|
||||
@@ -76,8 +76,10 @@ export async function dispatchCreateCategory ({ action, cache, fromChildSelfLimi
|
||||
blockAllNotifications: false,
|
||||
timeWarningFlags: 0,
|
||||
sort,
|
||||
disableLimitsUntil: 0,
|
||||
taskListVersion: generateVersionId()
|
||||
disableLimitsUntil: '0',
|
||||
taskListVersion: generateVersionId(),
|
||||
minBatteryCharging: 0,
|
||||
minBatteryMobile: 0
|
||||
}, { transaction: cache.transaction })
|
||||
|
||||
// update the cache
|
||||
|
||||
+1
-1
@@ -60,7 +60,7 @@ export async function dispatchUpdateCategoryDisableLimits ({ action, cache, from
|
||||
}
|
||||
|
||||
const [affectedRows] = await cache.database.category.update({
|
||||
disableLimitsUntil: action.endTime
|
||||
disableLimitsUntil: action.endTime.toString(10)
|
||||
}, {
|
||||
where: {
|
||||
familyId: cache.familyId,
|
||||
|
||||
+2
-2
@@ -48,7 +48,7 @@ export async function dispatchUpdateCategoryTemporarilyBlocked ({ action, cache,
|
||||
const categoryEntry = {
|
||||
childId: categoryEntryUnsafe.childId,
|
||||
temporarilyBlocked: categoryEntryUnsafe.temporarilyBlocked,
|
||||
temporarilyBlockedEndTime: categoryEntryUnsafe.temporarilyBlockedEndTime
|
||||
temporarilyBlockedEndTime: parseInt(categoryEntryUnsafe.temporarilyBlockedEndTime, 10)
|
||||
}
|
||||
|
||||
if (fromChildSelfLimitAddChildUserId !== null) {
|
||||
@@ -69,7 +69,7 @@ export async function dispatchUpdateCategoryTemporarilyBlocked ({ action, cache,
|
||||
|
||||
const [affectedRows] = await cache.database.category.update({
|
||||
temporarilyBlocked: action.blocked,
|
||||
temporarilyBlockedEndTime: action.blocked ? (action.endTime ?? 0) : 0
|
||||
temporarilyBlockedEndTime: action.blocked ? (action.endTime ?? 0).toString(10) : '0'
|
||||
}, {
|
||||
where: {
|
||||
familyId: cache.familyId,
|
||||
|
||||
@@ -64,48 +64,52 @@ export async function getAppList ({ database, transaction, familyEntry, appsStat
|
||||
|
||||
if (idsOfDevicesWhereInstalledAppsMustBeSynced.length > 0) {
|
||||
const [appsToSync, activitiesToSync] = await Promise.all([
|
||||
database.app.findAll({
|
||||
where: {
|
||||
familyId: familyEntry.familyId,
|
||||
deviceId: {
|
||||
[Sequelize.Op.in]: idsOfDevicesWhereInstalledAppsMustBeSynced
|
||||
}
|
||||
},
|
||||
attributes: [
|
||||
'deviceId',
|
||||
'packageName',
|
||||
'title',
|
||||
'isLaunchable',
|
||||
'recommendation'
|
||||
],
|
||||
transaction
|
||||
}).map((item) => ({
|
||||
deviceId: item.deviceId,
|
||||
packageName: item.packageName,
|
||||
title: item.title,
|
||||
isLaunchable: item.isLaunchable,
|
||||
recommendation: item.recommendation
|
||||
})),
|
||||
database.appActivity.findAll({
|
||||
where: {
|
||||
familyId: familyEntry.familyId,
|
||||
deviceId: {
|
||||
[Sequelize.Op.in]: idsOfDevicesWhereInstalledAppsMustBeSynced
|
||||
}
|
||||
},
|
||||
attributes: [
|
||||
'deviceId',
|
||||
'packageName',
|
||||
'title',
|
||||
'activityName'
|
||||
],
|
||||
transaction
|
||||
}).map((item) => ({
|
||||
deviceId: item.deviceId,
|
||||
packageName: item.packageName,
|
||||
activityName: item.activityName,
|
||||
title: item.title
|
||||
}))
|
||||
(async () => {
|
||||
return (await database.app.findAll({
|
||||
where: {
|
||||
familyId: familyEntry.familyId,
|
||||
deviceId: {
|
||||
[Sequelize.Op.in]: idsOfDevicesWhereInstalledAppsMustBeSynced
|
||||
}
|
||||
},
|
||||
attributes: [
|
||||
'deviceId',
|
||||
'packageName',
|
||||
'title',
|
||||
'isLaunchable',
|
||||
'recommendation'
|
||||
],
|
||||
transaction
|
||||
})).map((item) => ({
|
||||
deviceId: item.deviceId,
|
||||
packageName: item.packageName,
|
||||
title: item.title,
|
||||
isLaunchable: item.isLaunchable,
|
||||
recommendation: item.recommendation
|
||||
}))
|
||||
})(),
|
||||
(async () => {
|
||||
return (await database.appActivity.findAll({
|
||||
where: {
|
||||
familyId: familyEntry.familyId,
|
||||
deviceId: {
|
||||
[Sequelize.Op.in]: idsOfDevicesWhereInstalledAppsMustBeSynced
|
||||
}
|
||||
},
|
||||
attributes: [
|
||||
'deviceId',
|
||||
'packageName',
|
||||
'title',
|
||||
'activityName'
|
||||
],
|
||||
transaction
|
||||
})).map((item) => ({
|
||||
deviceId: item.deviceId,
|
||||
packageName: item.packageName,
|
||||
activityName: item.activityName,
|
||||
title: item.title
|
||||
}))
|
||||
})()
|
||||
])
|
||||
|
||||
return idsOfDevicesWhereInstalledAppsMustBeSynced.map((deviceId): ServerInstalledAppsData => ({
|
||||
|
||||
@@ -106,7 +106,7 @@ export async function getCategoryBaseDatas ({
|
||||
timeWarnings: item.timeWarningFlags,
|
||||
mblMobile: item.minBatteryMobile,
|
||||
mblCharging: item.minBatteryCharging,
|
||||
tempBlockTime: item.temporarilyBlockedEndTime,
|
||||
tempBlockTime: parseInt(item.temporarilyBlockedEndTime, 10),
|
||||
sort: item.sort,
|
||||
networks: networkIdsForSyncing
|
||||
.filter((network) => network.categoryId === item.categoryId)
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { Database, Transaction, warpPromiseReturner } from '../../database'
|
||||
import { Database, Transaction } from '../../database'
|
||||
import { mailNotificationFlags } from '../../database/user'
|
||||
import { sendManipulationWarningMail } from '../../util/mail'
|
||||
import { canSendWarningMail } from '../../util/ratelimit-warningmail'
|
||||
@@ -39,7 +39,7 @@ export const sendManipulationWarnings = async ({ database, familyId, deviceName,
|
||||
.filter((item) => (item.mailNotificationFlags & mailNotificationFlags.warnings) === mailNotificationFlags.warnings)
|
||||
.map((item) => item.mail)
|
||||
|
||||
transaction.afterCommit(warpPromiseReturner(async () => {
|
||||
transaction.afterCommit(async () => {
|
||||
await Promise.all(
|
||||
targetMailAddresses.map(async (receiver) => {
|
||||
if (await canSendWarningMail(receiver)) {
|
||||
@@ -47,5 +47,5 @@ export const sendManipulationWarnings = async ({ database, familyId, deviceName,
|
||||
}
|
||||
})
|
||||
)
|
||||
}))
|
||||
})
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { Database, Transaction, warpPromiseReturner } from '../../database'
|
||||
import { Database, Transaction } from '../../database'
|
||||
import { mailNotificationFlags } from '../../database/user'
|
||||
import { sendTaskDoneMail } from '../../util/mail'
|
||||
import { canSendTaskDoneMail } from '../../util/ratelimit-taskdonemail'
|
||||
@@ -40,7 +40,7 @@ export const sendTaskDoneMails = async ({ database, familyId, childName, taskTit
|
||||
.filter((item) => (item.mailNotificationFlags & mailNotificationFlags.tasks) === mailNotificationFlags.tasks)
|
||||
.map((item) => item.mail)
|
||||
|
||||
transaction.afterCommit(warpPromiseReturner(async () => {
|
||||
transaction.afterCommit(async () => {
|
||||
await Promise.all(
|
||||
targetMailAddresses.map(async (receiver) => {
|
||||
if (await canSendTaskDoneMail(receiver)) {
|
||||
@@ -48,5 +48,5 @@ export const sendTaskDoneMails = async ({ database, familyId, childName, taskTit
|
||||
}
|
||||
})
|
||||
)
|
||||
}))
|
||||
})
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { Database, Transaction, warpPromiseReturner } from '../../database'
|
||||
import { Database, Transaction } from '../../database'
|
||||
import { mailNotificationFlags } from '../../database/user'
|
||||
import { sendUninstallWarningMail } from '../../util/mail'
|
||||
import { canSendWarningMail } from '../../util/ratelimit-warningmail'
|
||||
@@ -39,7 +39,7 @@ export const sendUninstallWarnings = async ({ database, familyId, deviceName, tr
|
||||
.filter((item) => (item.mailNotificationFlags & mailNotificationFlags.warnings) === mailNotificationFlags.warnings)
|
||||
.map((item) => item.mail)
|
||||
|
||||
transaction.afterCommit(warpPromiseReturner(async () => {
|
||||
transaction.afterCommit(async () => {
|
||||
await Promise.all(
|
||||
targetMailAddresses.map(async (receiver) => {
|
||||
if (await canSendWarningMail(receiver)) {
|
||||
@@ -47,5 +47,5 @@ export const sendUninstallWarnings = async ({ database, familyId, deviceName, tr
|
||||
}
|
||||
})
|
||||
)
|
||||
}))
|
||||
})
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import * as EventEmitter from 'events'
|
||||
import { EventEmitter } from 'events'
|
||||
import * as io from 'socket.io'
|
||||
import { ConnectedDevicesManager, VisibleConnectedDevicesManager } from '../connected-devices'
|
||||
import { Database } from '../database'
|
||||
@@ -37,7 +37,7 @@ export const createWebsocketHandler = ({ connectedDevicesManager, database }: {
|
||||
const eventTriggerImportantSyncForAll = 'triggerimportantsyncforall'
|
||||
|
||||
let socketCounter = 0
|
||||
const server = io()
|
||||
const server = new io()
|
||||
|
||||
server.on('connection', (socket) => {
|
||||
socketCounter++
|
||||
|
||||
@@ -44,7 +44,7 @@ async function deleteDeprecatedPurchases ({ database, websocket }: {
|
||||
websocket: WebsocketApi
|
||||
}) {
|
||||
await database.transaction(async (transaction) => {
|
||||
const affectedFamilyIds = await database.family.findAll({
|
||||
const affectedFamilyIds = (await database.family.findAll({
|
||||
where: {
|
||||
hasFullVersion: true,
|
||||
fullVersionUntil: {
|
||||
@@ -55,14 +55,16 @@ async function deleteDeprecatedPurchases ({ database, websocket }: {
|
||||
transaction,
|
||||
lock: Sequelize.Transaction.LOCK.UPDATE,
|
||||
limit: 100
|
||||
}).map((item) => item.familyId)
|
||||
})).map((item) => item.familyId)
|
||||
|
||||
await database.family.update({
|
||||
hasFullVersion: false
|
||||
}, {
|
||||
where: {
|
||||
familyid: {
|
||||
[Sequelize.Op.in]: affectedFamilyIds
|
||||
familyId: {
|
||||
[Sequelize.Op.in]: {
|
||||
affectedFamilyIds
|
||||
}
|
||||
}
|
||||
},
|
||||
transaction
|
||||
|
||||
@@ -45,7 +45,7 @@ async function deleteOldUsedTimes ({ database }: {
|
||||
|
||||
await database.transaction(async (transaction) => {
|
||||
// get matching categories
|
||||
const categoriesToCleanUpOne = await database.usedTime.findAll({
|
||||
const categoriesToCleanUpOne = (await database.usedTime.findAll({
|
||||
transaction,
|
||||
where: {
|
||||
lastUpdate: {
|
||||
@@ -58,12 +58,12 @@ async function deleteOldUsedTimes ({ database }: {
|
||||
],
|
||||
limit: 1000,
|
||||
order: [['lastUpdate', 'ASC']]
|
||||
}).map((item) => ({
|
||||
})).map((item) => ({
|
||||
familyId: item.familyId,
|
||||
categoryId: item.categoryId
|
||||
}))
|
||||
|
||||
const categoriesToCleanUpTwo = await database.sessionDuration.findAll({
|
||||
const categoriesToCleanUpTwo = (await database.sessionDuration.findAll({
|
||||
transaction,
|
||||
where: {
|
||||
roundedLastUpdate: {
|
||||
@@ -76,7 +76,7 @@ async function deleteOldUsedTimes ({ database }: {
|
||||
],
|
||||
limit: 1000,
|
||||
order: [['roundedLastUpdate', 'ASC']]
|
||||
}).map((item) => ({
|
||||
})).map((item) => ({
|
||||
familyId: item.familyId,
|
||||
categoryId: item.categoryId
|
||||
}))
|
||||
|
||||
Reference in New Issue
Block a user