FileLockingHelper.kt 726 B

123456789101112131415161718192021222324
  1. /*
  2. * Nextcloud - Android Client
  3. *
  4. * SPDX-FileCopyrightText: 2022 Álvaro Brey <alvaro@alvarobrey.com>
  5. * SPDX-FileCopyrightText: 2022 Nextcloud GmbH
  6. * SPDX-License-Identifier: AGPL-3.0-or-later
  7. */
  8. package com.nextcloud.android.files
  9. import com.owncloud.android.datamodel.OCFile
  10. import com.owncloud.android.lib.resources.files.model.FileLockType
  11. object FileLockingHelper {
  12. /**
  13. * Checks whether the given `userId` can unlock the [OCFile].
  14. */
  15. @JvmStatic
  16. fun canUserUnlockFile(userId: String, file: OCFile): Boolean {
  17. if (!file.isLocked || file.lockOwnerId == null || file.lockType != FileLockType.MANUAL) {
  18. return false
  19. }
  20. return file.lockOwnerId == userId
  21. }
  22. }