Update dependencies

This commit is contained in:
Jonas Lochmann
2020-12-28 01:00:00 +01:00
parent 2bb3777484
commit eca9473e11
133 changed files with 2298 additions and 2495 deletions
+4 -4
View File
@@ -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)
+4 -4
View File
@@ -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)
})
+1 -1
View File
@@ -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
@@ -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,
@@ -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)
+3 -3
View File
@@ -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,
}
})
)
}))
})
}
+3 -3
View File
@@ -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
}
})
)
}))
})
}
+3 -3
View File
@@ -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
}
})
)
}))
})
}