diff --git a/iOSClient/Share/Advanced/NCShareDateCell.swift b/iOSClient/Share/Advanced/NCShareDateCell.swift index 7d4e8c18c2..4af43ab227 100644 --- a/iOSClient/Share/Advanced/NCShareDateCell.swift +++ b/iOSClient/Share/Advanced/NCShareDateCell.swift @@ -18,7 +18,7 @@ class NCShareDateCell: UITableViewCell { super.init(style: .value1, reuseIdentifier: "shareExpDate") picker.datePickerMode = .date - picker.minimumDate = Date() + picker.minimumDate = Calendar.current.date(byAdding: .day, value: 1, to: Date()) picker.preferredDatePickerStyle = .wheels picker.action(for: .valueChanged) { datePicker in guard let datePicker = datePicker as? UIDatePicker else { return } diff --git a/iOSClient/Share/NCShareNetworking.swift b/iOSClient/Share/NCShareNetworking.swift index 37ff1c0034..1fe339f505 100644 --- a/iOSClient/Share/NCShareNetworking.swift +++ b/iOSClient/Share/NCShareNetworking.swift @@ -114,23 +114,20 @@ class NCShareNetworking: NSObject { } } - func createShare(_ template: Shareable, downloadLimit: DownloadLimitViewModel) { - // NOTE: Permissions don't work for creating with file drop! - // https://github.com/nextcloud/server/issues/17504 - + func createShare(_ shareable: Shareable, downloadLimit: DownloadLimitViewModel) { NCActivityIndicator.shared.start(backgroundView: view) let filenamePath = utilityFileSystem.getFileNamePath(metadata.fileName, serverUrl: metadata.serverUrl, session: session) let capabilities = NCNetworking.shared.capabilities[self.metadata.account] ?? NKCapabilities.Capabilities() NextcloudKit.shared.createShare(path: filenamePath, - shareType: template.shareType, - shareWith: template.shareWith, + shareType: shareable.shareType, + shareWith: shareable.shareWith, publicUpload: false, - note: template.note, + note: shareable.note, hideDownload: false, - password: template.password, - permissions: template.permissions, - attributes: template.attributes, + password: shareable.password, + permissions: shareable.permissions, + attributes: shareable.attributes, account: metadata.account) { task in Task { let identifier = await NCNetworking.shared.networkingTasks.createIdentifier(account: self.metadata.account, @@ -142,16 +139,18 @@ class NCShareNetworking: NSObject { NCActivityIndicator.shared.stop() if error == .success, let share = share { - template.idShare = share.idShare + shareable.idShare = share.idShare let home = self.utilityFileSystem.getHomeServer(session: self.session) self.database.addShare(account: self.metadata.account, home: home, shares: [share]) - if template.hasChanges(comparedTo: share) { - self.updateShare(template, downloadLimit: downloadLimit) + if shareable.hasChanges(comparedTo: share) { + self.updateShare(shareable, downloadLimit: downloadLimit) // Download limit update should happen implicitly on share update. } else { if case let .limited(limit, _) = downloadLimit, - capabilities.fileSharingDownloadLimit { + capabilities.fileSharingDownloadLimit, + shareable.shareType == NCShareCommon.shareTypeLink, + shareable.itemType == NCShareCommon.itemTypeFile { self.setShareDownloadLimit(limit, token: share.token) } } @@ -196,12 +195,12 @@ class NCShareNetworking: NSObject { } } - func updateShare(_ option: Shareable, downloadLimit: DownloadLimitViewModel) { + func updateShare(_ shareable: Shareable, downloadLimit: DownloadLimitViewModel) { NCActivityIndicator.shared.start(backgroundView: view) - NextcloudKit.shared.updateShare(idShare: option.idShare, password: option.password, expireDate: option.formattedDateString, permissions: option.permissions, note: option.note, label: option.label, hideDownload: option.hideDownload, attributes: option.attributes, account: metadata.account) { task in + NextcloudKit.shared.updateShare(idShare: shareable.idShare, password: shareable.password, expireDate: shareable.formattedDateString, permissions: shareable.permissions, note: shareable.note, label: shareable.label, hideDownload: shareable.hideDownload, attributes: shareable.attributes, account: metadata.account) { task in Task { let identifier = await NCNetworking.shared.networkingTasks.createIdentifier(account: self.metadata.account, - path: "_\(option.idShare)", + path: "_\(shareable.idShare)", name: "updateShare") await NCNetworking.shared.networkingTasks.track(identifier: identifier, task: task) } @@ -215,7 +214,9 @@ class NCShareNetworking: NSObject { self.database.addShare(account: self.metadata.account, home: home, shares: [share]) self.delegate?.readShareCompleted() - if capabilities.fileSharingDownloadLimit { + if capabilities.fileSharingDownloadLimit, + shareable.shareType == NCShareCommon.shareTypeLink, + shareable.itemType == NCShareCommon.itemTypeFile { if case let .limited(limit, _) = downloadLimit { self.setShareDownloadLimit(limit, token: share.token) } else { @@ -230,7 +231,7 @@ class NCShareNetworking: NSObject { } } else { NCContentPresenter().showError(error: error) - self.delegate?.updateShareWithError(idShare: option.idShare) + self.delegate?.updateShareWithError(idShare: shareable.idShare) } } } @@ -264,7 +265,7 @@ class NCShareNetworking: NSObject { func removeShareDownloadLimit(token: String) { let capabilities = NCNetworking.shared.capabilities[self.metadata.account] ?? NKCapabilities.Capabilities() - if !capabilities.fileSharingDownloadLimit { + if !capabilities.fileSharingDownloadLimit || token.isEmpty { return } @@ -289,7 +290,7 @@ class NCShareNetworking: NSObject { func setShareDownloadLimit(_ limit: Int, token: String) { let capabilities = NCNetworking.shared.capabilities[self.metadata.account] ?? NKCapabilities.Capabilities() - if !capabilities.fileSharingDownloadLimit { + if !capabilities.fileSharingDownloadLimit || token.isEmpty { return }