mirror of https://github.com/nextcloud/android
25 lines
726 B
Kotlin
25 lines
726 B
Kotlin
/*
|
|
* Nextcloud - Android Client
|
|
*
|
|
* SPDX-FileCopyrightText: 2022 Álvaro Brey <alvaro@alvarobrey.com>
|
|
* SPDX-FileCopyrightText: 2022 Nextcloud GmbH
|
|
* SPDX-License-Identifier: AGPL-3.0-or-later
|
|
*/
|
|
package com.nextcloud.android.files
|
|
|
|
import com.owncloud.android.datamodel.OCFile
|
|
import com.owncloud.android.lib.resources.files.model.FileLockType
|
|
|
|
object FileLockingHelper {
|
|
/**
|
|
* Checks whether the given `userId` can unlock the [OCFile].
|
|
*/
|
|
@JvmStatic
|
|
fun canUserUnlockFile(userId: String, file: OCFile): Boolean {
|
|
if (!file.isLocked || file.lockOwnerId == null || file.lockType != FileLockType.MANUAL) {
|
|
return false
|
|
}
|
|
return file.lockOwnerId == userId
|
|
}
|
|
}
|