Add user limit login category feature

This commit is contained in:
Jonas Lochmann 2020-06-29 02:00:00 +02:00
parent 3f7e34a175
commit 7c8c00b539
No known key found for this signature in database
GPG key ID: 8B8C9AEE10FA5B36
40 changed files with 2502 additions and 187 deletions

View file

@ -52,8 +52,24 @@ object ApplyServerDataStatus {
run {
// update/ create entries (first because there must be always one parent user)
newUserList.data.forEach {
newData ->
newUserList.data.forEach { newEntry ->
val newData = User(
id = newEntry.id,
name = newEntry.name,
password = newEntry.password,
secondPasswordSalt = newEntry.secondPasswordSalt,
type = newEntry.type,
timeZone = newEntry.timeZone,
disableLimitsUntil = newEntry.disableLimitsUntil,
mail = newEntry.mail,
currentDevice = newEntry.currentDevice,
categoryForNotAssignedApps = newEntry.categoryForNotAssignedApps,
relaxPrimaryDevice = newEntry.relaxPrimaryDevice,
mailNotificationFlags = newEntry.mailNotificationFlags,
blockedTimes = newEntry.blockedTimes,
flags = newEntry.flags
)
val oldEntry = oldUserList.find { it.id == newData.id }
if (oldEntry == null) {
@ -460,6 +476,24 @@ object ApplyServerDataStatus {
)
}
}
status.newUserList?.data?.forEach { user ->
if (user.limitLoginCategory == null) {
database.userLimitLoginCategoryDao().removeItemSync(user.id)
} else {
val oldItem = database.userLimitLoginCategoryDao().getByParentUserIdSync(user.id)
if (oldItem == null || oldItem.categoryId != user.limitLoginCategory) {
database.userLimitLoginCategoryDao().removeItemSync(user.id)
database.userLimitLoginCategoryDao().insertOrIgnoreItemSync(
UserLimitLoginCategory(
userId = user.id,
categoryId = user.limitLoginCategory
)
)
}
}
}
}
}
}