FileLockingHelper.kt 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. /*
  2. * Nextcloud Android client application
  3. *
  4. * @author Álvaro Brey Vilas
  5. * Copyright (C) 2022 Álvaro Brey Vilas
  6. * Copyright (C) 2022 Nextcloud GmbH
  7. *
  8. * This program is free software: you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation, either version 3 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  20. */
  21. package com.nextcloud.android.files
  22. import com.owncloud.android.datamodel.OCFile
  23. import com.owncloud.android.lib.resources.files.model.FileLockType
  24. object FileLockingHelper {
  25. /**
  26. * Checks whether the given `userId` can unlock the [OCFile].
  27. */
  28. @JvmStatic
  29. fun canUserUnlockFile(userId: String, file: OCFile): Boolean {
  30. if (!file.isLocked || file.lockOwnerId == null || file.lockType != FileLockType.MANUAL) {
  31. return false
  32. }
  33. return file.lockOwnerId == userId
  34. }
  35. }