diff --git a/Anytype/Sources/PresentationLayer/Modules/InviteLink/InviteLinkView.swift b/Anytype/Sources/PresentationLayer/Modules/InviteLink/InviteLinkView.swift index 073aac4c3c..86556cf88c 100644 --- a/Anytype/Sources/PresentationLayer/Modules/InviteLink/InviteLinkView.swift +++ b/Anytype/Sources/PresentationLayer/Modules/InviteLink/InviteLinkView.swift @@ -81,7 +81,7 @@ struct InviteLinkView: View { .newDivider() } Spacer.fixedHeight(10) - AnytypeText(model.isStream ? Loc.SpaceShare.Invite.Stream.description : Loc.SpaceShare.Invite.description, style: .relation3Regular) + AnytypeText(model.description, style: .relation3Regular) .foregroundColor(.Text.secondary) Spacer.fixedHeight(20) StandardButton(model.isStream ? Loc.SpaceShare.Share.link : Loc.SpaceShare.Invite.share, style: .primaryLarge) { diff --git a/Anytype/Sources/PresentationLayer/Modules/InviteLink/InviteLinkViewModel.swift b/Anytype/Sources/PresentationLayer/Modules/InviteLink/InviteLinkViewModel.swift index b7675cef2a..0c4184494d 100644 --- a/Anytype/Sources/PresentationLayer/Modules/InviteLink/InviteLinkViewModel.swift +++ b/Anytype/Sources/PresentationLayer/Modules/InviteLink/InviteLinkViewModel.swift @@ -16,6 +16,7 @@ final class InviteLinkViewModel: ObservableObject { @Published var canCopyInviteLink = false @Published var deleteLinkSpaceId: StringIdentifiable? = nil @Published var toastBarData: ToastBarData? + @Published var description = "" @Injected(\.participantSpacesStorage) private var participantSpacesStorage: any ParticipantSpacesStorageProtocol @@ -49,7 +50,14 @@ final class InviteLinkViewModel: ObservableObject { AnytypeAnalytics.instance().logScreenSettingsSpaceShare(route: data.route) do { let invite = isStream ? try await workspaceService.getGuestInvite(spaceId: spaceId) : try await workspaceService.getCurrentInvite(spaceId: spaceId) - + if isStream { + description = Loc.SpaceShare.Invite.Stream.description + } else { + description = Loc.SpaceShare.Invite.Description.part1 + if let withoutApprove = invite.inviteType?.withoutApprove, !withoutApprove { + description += ". " + Loc.SpaceShare.Invite.Description.part2 + } + } shareLink = universalLinkParser.createUrl(link: .invite(cid: invite.cid, key: invite.fileKey)) } catch {} } diff --git a/Anytype/Sources/PresentationLayer/Modules/SpaceJoin/SpaceJoinView.swift b/Anytype/Sources/PresentationLayer/Modules/SpaceJoin/SpaceJoinView.swift index cd6c1e9292..3a7574a6c5 100644 --- a/Anytype/Sources/PresentationLayer/Modules/SpaceJoin/SpaceJoinView.swift +++ b/Anytype/Sources/PresentationLayer/Modules/SpaceJoin/SpaceJoinView.swift @@ -15,7 +15,7 @@ struct SpaceJoinView: View { ScreenStateView(state: model.state, error: model.errorMessage) { content } loading: { - invite(placeholder: true) + invite(placeholder: true, withoutApprove: model.dataState.inviteWithoutApprove) } } .multilineTextAlignment(.center) @@ -40,8 +40,8 @@ struct SpaceJoinView: View { switch model.dataState { case .requestSent: requestSent - case .invite: - invite(placeholder: false) + case let .invite(withoutApprove): + invite(placeholder: false, withoutApprove: withoutApprove) case .alreadyJoined: alreadyJoined case .inviteNotFound: @@ -62,11 +62,11 @@ struct SpaceJoinView: View { } } - private func invite(placeholder: Bool) -> some View { + private func invite(placeholder: Bool, withoutApprove: Bool) -> some View { VStack(spacing: 0) { Image(asset: .Dialog.invite) Spacer.fixedHeight(15) - AnytypeText(Loc.SpaceShare.Join.title, style: .heading) + AnytypeText(model.title, style: .heading) .foregroundColor(.Text.primary) Spacer.fixedHeight(8) AnytypeText(model.message, style: .bodyRegular, enableMarkdown: true) @@ -75,15 +75,23 @@ struct SpaceJoinView: View { $0.redacted(reason: .placeholder) } Spacer.fixedHeight(19) - AsyncStandardButton(Loc.SpaceShare.Join.button, style: .primaryLarge) { + AsyncStandardButton(model.button, style: .primaryLarge) { try await model.onJoin() } .if(placeholder) { $0.redacted(reason: .placeholder) } - Spacer.fixedHeight(17) - AnytypeText(Loc.SpaceShare.Join.info, style: .caption1Regular) - .foregroundColor(.Text.secondary) + if withoutApprove { + Spacer.fixedHeight(8) + StandardButton(Loc.cancel, style: .secondaryLarge, action: { + model.onCancel() + }) + } else { + Spacer.fixedHeight(17) + AnytypeText(Loc.SpaceShare.Join.info, style: .caption1Regular) + .foregroundColor(.Text.secondary) + } + } .padding(.horizontal, 16) .padding(.top, 24) diff --git a/Anytype/Sources/PresentationLayer/Modules/SpaceJoin/SpaceJoinViewModel.swift b/Anytype/Sources/PresentationLayer/Modules/SpaceJoin/SpaceJoinViewModel.swift index ce8e433cd8..d916b21781 100644 --- a/Anytype/Sources/PresentationLayer/Modules/SpaceJoin/SpaceJoinViewModel.swift +++ b/Anytype/Sources/PresentationLayer/Modules/SpaceJoin/SpaceJoinViewModel.swift @@ -10,10 +10,19 @@ struct SpaceJoinModuleData: Identifiable { enum SpaceJoinDataState { case requestSent - case invite + case invite(withoutApprove: Bool) case alreadyJoined case inviteNotFound case spaceDeleted + + var inviteWithoutApprove: Bool { + switch self { + case let .invite(withoutApprove): + return withoutApprove + default: + return false + } + } } @MainActor @@ -34,9 +43,11 @@ final class SpaceJoinViewModel: ObservableObject { private var callManageSpaces = false @Published var errorMessage: String = "" + @Published var title: String = Loc.SpaceShare.Join.title @Published var message: String = Loc.SpaceShare.Join.message("", "") // For Placeholder + @Published var button: String = Loc.SpaceShare.Join.button @Published var state: ScreenState = .loading - @Published var dataState: SpaceJoinDataState = .invite + @Published var dataState: SpaceJoinDataState = .invite(withoutApprove: false) @Published var toast: ToastBarData? @Published var showSuccessAlert = false @Published var dismiss = false @@ -57,7 +68,15 @@ final class SpaceJoinViewModel: ObservableObject { key: data.key, networkId: accountManager.account.info.networkId ) - showSuccessAlert.toggle() + if inviteView.inviteType.withoutApprove { + dismiss.toggle() + } else { + showSuccessAlert.toggle() + } + } + + func onCancel() { + dismiss.toggle() } func onDismissSuccessAlert() { @@ -104,13 +123,13 @@ final class SpaceJoinViewModel: ObservableObject { private func updateView() async { do { let inviteView = try await workspaceService.inviteView(cid: data.cid, key: data.key) - message = Loc.SpaceShare.Join.message( - inviteView.spaceName.withPlaceholder.trimmingCharacters(in: .whitespaces), - inviteView.creatorName.withPlaceholder.trimmingCharacters(in: .whitespaces) - ) + + handleInviteType(inviteView: inviteView) + self.inviteView = inviteView state = .data + let inviteWithoutApprove = inviteView.inviteType.withoutApprove if let spaceView = workspaceStorage.allWorkspaces.first(where: { $0.targetSpaceId == inviteView.spaceId }) { switch spaceView.accountStatus { case .spaceJoining: @@ -118,10 +137,10 @@ final class SpaceJoinViewModel: ObservableObject { case .spaceActive, .unknown: dataState = .alreadyJoined default: - dataState = .invite + dataState = .invite(withoutApprove: inviteWithoutApprove) } } else { - dataState = .invite + dataState = .invite(withoutApprove: inviteWithoutApprove) } } catch let error as SpaceInviteViewError where error.code == .inviteNotFound { dataState = .inviteNotFound @@ -134,4 +153,23 @@ final class SpaceJoinViewModel: ObservableObject { state = .error } } + + private func handleInviteType(inviteView: SpaceInviteView) { + if inviteView.inviteType.withoutApprove { + let spaceName = inviteView.spaceName.withPlaceholder.trimmingCharacters(in: .whitespaces) + title = Loc.SpaceShare.Join.NoApprove.title(spaceName) + message = Loc.SpaceShare.Join.NoApprove.message( + spaceName, + inviteView.creatorName.withPlaceholder.trimmingCharacters(in: .whitespaces) + ) + button = Loc.SpaceShare.Join.NoApprove.button + } else { + title = Loc.SpaceShare.Join.title + message = Loc.SpaceShare.Join.message( + inviteView.spaceName.withPlaceholder.trimmingCharacters(in: .whitespaces), + inviteView.creatorName.withPlaceholder.trimmingCharacters(in: .whitespaces) + ) + button = Loc.SpaceShare.Join.button + } + } } diff --git a/Libraryfile b/Libraryfile index 4ea79f75ab..cad235c16c 100644 --- a/Libraryfile +++ b/Libraryfile @@ -1 +1 @@ -MIDDLE_VERSION=v0.41.0-rc4 \ No newline at end of file +MIDDLE_VERSION=f259480e6 diff --git a/Modules/Loc/Sources/Loc/Generated/Strings.swift b/Modules/Loc/Sources/Loc/Generated/Strings.swift index fe67aa75da..7899e40404 100644 --- a/Modules/Loc/Sources/Loc/Generated/Strings.swift +++ b/Modules/Loc/Sources/Loc/Generated/Strings.swift @@ -1915,7 +1915,6 @@ public enum Loc { public static let title = Loc.tr("Localizable", "SpaceShare.HowToShare.Title", fallback: "How to share a space?") } public enum Invite { - public static let description = Loc.tr("Localizable", "SpaceShare.Invite.Description", fallback: "Share this invite link so that others can join your Space. Once they click your link and request access, you can set their access rights.") public static let empty = Loc.tr("Localizable", "SpaceShare.Invite.Empty", fallback: "Create invite link to share space and add new members") public static let generate = Loc.tr("Localizable", "SpaceShare.Invite.Generate", fallback: "Generate invite link") public static func maxLimit(_ p1: Int) -> String { @@ -1923,6 +1922,10 @@ public enum Loc { } public static let share = Loc.tr("Localizable", "SpaceShare.Invite.Share", fallback: "Share invite link") public static let title = Loc.tr("Localizable", "SpaceShare.Invite.Title", fallback: "Invite link") + public enum Description { + public static let part1 = Loc.tr("Localizable", "SpaceShare.Invite.Description.part1", fallback: "Share this invite link so that others can join your space") + public static let part2 = Loc.tr("Localizable", "SpaceShare.Invite.Description.part2", fallback: "Once they click your link and request access, you can set their access rights.") + } public enum Stream { public static let description = Loc.tr("Localizable", "SpaceShare.Invite.Stream.Description", fallback: "Share this link so that others can join your Stream.") } @@ -1942,6 +1945,15 @@ public enum Loc { public enum NoAccess { public static let title = Loc.tr("Localizable", "SpaceShare.Join.NoAccess.Title", fallback: "No access to this space") } + public enum NoApprove { + public static let button = Loc.tr("Localizable", "SpaceShare.Join.NoApprove.button", fallback: "Join Space") + public static func message(_ p1: Any, _ p2: Any) -> String { + return Loc.tr("Localizable", "SpaceShare.Join.NoApprove.Message", String(describing: p1), String(describing: p2), fallback: "You've been invited to join %@, created by %@") + } + public static func title(_ p1: Any) -> String { + return Loc.tr("Localizable", "SpaceShare.Join.NoApprove.Title", String(describing: p1), fallback: "Join %@") + } + } public enum ObjectIsNotAvailable { public static let message = Loc.tr("Localizable", "SpaceShare.Join.ObjectIsNotAvailable.Message", fallback: "Ask the owner to share it with you.") } diff --git a/Modules/Loc/Sources/Loc/Resources/Localizable.xcstrings b/Modules/Loc/Sources/Loc/Resources/Localizable.xcstrings index 9097d76556..03f606b6f0 100644 --- a/Modules/Loc/Sources/Loc/Resources/Localizable.xcstrings +++ b/Modules/Loc/Sources/Loc/Resources/Localizable.xcstrings @@ -149313,7 +149313,7 @@ } } }, - "SpaceShare.Invite.Description" : { + "SpaceShare.Invite.Description.part1" : { "extractionState" : "manual", "localizations" : { "ar" : { @@ -149337,7 +149337,7 @@ "en" : { "stringUnit" : { "state" : "translated", - "value" : "Share this invite link so that others can join your Space. Once they click your link and request access, you can set their access rights." + "value" : "Share this invite link so that others can join your space" } }, "es" : { @@ -149462,6 +149462,17 @@ } } }, + "SpaceShare.Invite.Description.part2" : { + "extractionState" : "manual", + "localizations" : { + "en" : { + "stringUnit" : { + "state" : "translated", + "value" : "Once they click your link and request access, you can set their access rights." + } + } + } + }, "SpaceShare.Invite.Empty" : { "extractionState" : "manual", "localizations" : { @@ -151586,6 +151597,39 @@ } } }, + "SpaceShare.Join.NoApprove.button" : { + "extractionState" : "manual", + "localizations" : { + "en" : { + "stringUnit" : { + "state" : "translated", + "value" : "Join Space" + } + } + } + }, + "SpaceShare.Join.NoApprove.Message" : { + "extractionState" : "manual", + "localizations" : { + "en" : { + "stringUnit" : { + "state" : "translated", + "value" : "You've been invited to join %@, created by %@" + } + } + } + }, + "SpaceShare.Join.NoApprove.Title" : { + "extractionState" : "manual", + "localizations" : { + "en" : { + "stringUnit" : { + "state" : "translated", + "value" : "Join %@" + } + } + } + }, "SpaceShare.Join.ObjectIsNotAvailable.Message" : { "extractionState" : "manual", "localizations" : { diff --git a/Modules/ProtobufMessages/Sources/Generated/CommandsInvocation/invocation-adoption.generated.swift b/Modules/ProtobufMessages/Sources/Generated/CommandsInvocation/invocation-adoption.generated.swift index 7cc4149782..418004bf9a 100644 --- a/Modules/ProtobufMessages/Sources/Generated/CommandsInvocation/invocation-adoption.generated.swift +++ b/Modules/ProtobufMessages/Sources/Generated/CommandsInvocation/invocation-adoption.generated.swift @@ -1335,6 +1335,11 @@ extension Anytype_Rpc.Space.Delete.Response.Error: ResponseError { public var isNull: Bool { code == .null && description_p.isEmpty } } +extension Anytype_Rpc.Space.InviteChange.Response: ResultWithError {} +extension Anytype_Rpc.Space.InviteChange.Response.Error: ResponseError { + public var isNull: Bool { code == .null && description_p.isEmpty } +} + extension Anytype_Rpc.Space.InviteGenerate.Response: ResultWithError {} extension Anytype_Rpc.Space.InviteGenerate.Response.Error: ResponseError { public var isNull: Bool { code == .null && description_p.isEmpty } diff --git a/Modules/ProtobufMessages/Sources/Generated/service+invocation.swift b/Modules/ProtobufMessages/Sources/Generated/service+invocation.swift index 8b6ddf4e2d..222a5fa385 100644 --- a/Modules/ProtobufMessages/Sources/Generated/service+invocation.swift +++ b/Modules/ProtobufMessages/Sources/Generated/service+invocation.swift @@ -364,6 +364,16 @@ public struct ClientCommands { } } + public static func spaceInviteChange( + _ request: Anytype_Rpc.Space.InviteChange.Request = .init() + ) -> Invocation { + return Invocation(messageName: "SpaceInviteChange", request: request) { request in + let requestData = try request.serializedData() + let responseData = Lib.ServiceSpaceInviteChange(requestData) ?? Data() + return try Anytype_Rpc.Space.InviteChange.Response(serializedBytes: responseData) + } + } + public static func spaceInviteGetCurrent( _ request: Anytype_Rpc.Space.InviteGetCurrent.Request = .init() ) -> Invocation { diff --git a/Modules/ProtobufMessages/Sources/Loc/Generated/Error+Localization.swift b/Modules/ProtobufMessages/Sources/Loc/Generated/Error+Localization.swift index e64257ef55..17dcf3633a 100644 --- a/Modules/ProtobufMessages/Sources/Loc/Generated/Error+Localization.swift +++ b/Modules/ProtobufMessages/Sources/Loc/Generated/Error+Localization.swift @@ -6548,6 +6548,37 @@ extension Anytype_Rpc.Space.Delete.Response.Error: LocalizedError { } } +extension Anytype_Rpc.Space.InviteChange.Response.Error: LocalizedError { + public var errorDescription: String? { + let localizeError = localizeError() + if !localizeError.isEmpty { + return localizeError + } + return "Error: \(description_p) (\(code))" + } + + private func localizeError() -> String { + switch code { + case .null: + return "" + case .unknownError: + return "" + case .badInput: + return LocHelper.tr(table: "LocalizableError", key: "Space.InviteChange.badInput") + case .noSuchSpace: + return LocHelper.tr(table: "LocalizableError", key: "Space.InviteChange.noSuchSpace") + case .spaceIsDeleted: + return LocHelper.tr(table: "LocalizableError", key: "Space.InviteChange.spaceIsDeleted") + case .requestFailed: + return LocHelper.tr(table: "LocalizableError", key: "Space.InviteChange.requestFailed") + case .incorrectPermissions: + return LocHelper.tr(table: "LocalizableError", key: "Space.InviteChange.incorrectPermissions") + case .UNRECOGNIZED: + return "" + } + } +} + extension Anytype_Rpc.Space.InviteGenerate.Response.Error: LocalizedError { public var errorDescription: String? { let localizeError = localizeError() diff --git a/Modules/ProtobufMessages/Sources/Protocol/Commands/Anytype_Rpc.Space.InviteChange.swift b/Modules/ProtobufMessages/Sources/Protocol/Commands/Anytype_Rpc.Space.InviteChange.swift new file mode 100644 index 0000000000..4f5c384b55 --- /dev/null +++ b/Modules/ProtobufMessages/Sources/Protocol/Commands/Anytype_Rpc.Space.InviteChange.swift @@ -0,0 +1,284 @@ +// DO NOT EDIT. +// swift-format-ignore-file +// swiftlint:disable all +// +// Generated by the Swift generator plugin for the protocol buffer compiler. +// Source: pb/protos/commands.proto +// +// For information on using the generated types, please see the documentation: +// https://github.com/apple/swift-protobuf/ + +import Foundation +import SwiftProtobuf + +extension Anytype_Rpc.Space { + public struct InviteChange: Sendable { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public struct Request: Sendable { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var spaceID: String = String() + + public var permissions: Anytype_Model_ParticipantPermissions = .reader + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public init() {} + } + + public struct Response: Sendable { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var error: Anytype_Rpc.Space.InviteChange.Response.Error { + get {return _error ?? Anytype_Rpc.Space.InviteChange.Response.Error()} + set {_error = newValue} + } + /// Returns true if `error` has been explicitly set. + public var hasError: Bool {return self._error != nil} + /// Clears the value of `error`. Subsequent reads from it will return its default value. + public mutating func clearError() {self._error = nil} + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public struct Error: Sendable { + // SwiftProtobuf.Message conformance is added in an extension below. See the + // `Message` and `Message+*Additions` files in the SwiftProtobuf library for + // methods supported on all messages. + + public var code: Anytype_Rpc.Space.InviteChange.Response.Error.Code = .null + + public var description_p: String = String() + + public var unknownFields = SwiftProtobuf.UnknownStorage() + + public enum Code: SwiftProtobuf.Enum, Swift.CaseIterable { + public typealias RawValue = Int + case null // = 0 + case unknownError // = 1 + case badInput // = 2 + case noSuchSpace // = 101 + case spaceIsDeleted // = 102 + case requestFailed // = 103 + case incorrectPermissions // = 105 + case UNRECOGNIZED(Int) + + public init() { + self = .null + } + + public init?(rawValue: Int) { + switch rawValue { + case 0: self = .null + case 1: self = .unknownError + case 2: self = .badInput + case 101: self = .noSuchSpace + case 102: self = .spaceIsDeleted + case 103: self = .requestFailed + case 105: self = .incorrectPermissions + default: self = .UNRECOGNIZED(rawValue) + } + } + + public var rawValue: Int { + switch self { + case .null: return 0 + case .unknownError: return 1 + case .badInput: return 2 + case .noSuchSpace: return 101 + case .spaceIsDeleted: return 102 + case .requestFailed: return 103 + case .incorrectPermissions: return 105 + case .UNRECOGNIZED(let i): return i + } + } + + // The compiler won't synthesize support with the UNRECOGNIZED case. + public static let allCases: [Anytype_Rpc.Space.InviteChange.Response.Error.Code] = [ + .null, + .unknownError, + .badInput, + .noSuchSpace, + .spaceIsDeleted, + .requestFailed, + .incorrectPermissions, + ] + + } + + public init() {} + } + + public init() {} + + fileprivate var _error: Anytype_Rpc.Space.InviteChange.Response.Error? = nil + } + + public init() {} + } +} + +extension Anytype_Rpc.Space.InviteChange: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = Anytype_Rpc.Space.protoMessageName + ".InviteChange" + public static let _protobuf_nameMap = SwiftProtobuf._NameMap() + + public mutating func decodeMessage(decoder: inout D) throws { + // Load everything into unknown fields + while try decoder.nextFieldNumber() != nil {} + } + + public func traverse(visitor: inout V) throws { + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Anytype_Rpc.Space.InviteChange, rhs: Anytype_Rpc.Space.InviteChange) -> Bool { + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Anytype_Rpc.Space.InviteChange.Request: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = Anytype_Rpc.Space.InviteChange.protoMessageName + ".Request" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "spaceId"), + 2: .same(proto: "permissions"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularStringField(value: &self.spaceID) }() + case 2: try { try decoder.decodeSingularEnumField(value: &self.permissions) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if !self.spaceID.isEmpty { + try visitor.visitSingularStringField(value: self.spaceID, fieldNumber: 1) + } + if self.permissions != .reader { + try visitor.visitSingularEnumField(value: self.permissions, fieldNumber: 2) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Anytype_Rpc.Space.InviteChange.Request, rhs: Anytype_Rpc.Space.InviteChange.Request) -> Bool { + if lhs.spaceID != rhs.spaceID {return false} + if lhs.permissions != rhs.permissions {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Anytype_Rpc.Space.InviteChange.Response: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = Anytype_Rpc.Space.InviteChange.protoMessageName + ".Response" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "error"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularMessageField(value: &self._error) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every if/case branch local when no optimizations + // are enabled. https://github.com/apple/swift-protobuf/issues/1034 and + // https://github.com/apple/swift-protobuf/issues/1182 + try { if let v = self._error { + try visitor.visitSingularMessageField(value: v, fieldNumber: 1) + } }() + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Anytype_Rpc.Space.InviteChange.Response, rhs: Anytype_Rpc.Space.InviteChange.Response) -> Bool { + if lhs._error != rhs._error {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Anytype_Rpc.Space.InviteChange.Response.Error: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + public static let protoMessageName: String = Anytype_Rpc.Space.InviteChange.Response.protoMessageName + ".Error" + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "code"), + 2: .same(proto: "description"), + ] + + public mutating func decodeMessage(decoder: inout D) throws { + while let fieldNumber = try decoder.nextFieldNumber() { + // The use of inline closures is to circumvent an issue where the compiler + // allocates stack space for every case branch when no optimizations are + // enabled. https://github.com/apple/swift-protobuf/issues/1034 + switch fieldNumber { + case 1: try { try decoder.decodeSingularEnumField(value: &self.code) }() + case 2: try { try decoder.decodeSingularStringField(value: &self.description_p) }() + default: break + } + } + } + + public func traverse(visitor: inout V) throws { + if self.code != .null { + try visitor.visitSingularEnumField(value: self.code, fieldNumber: 1) + } + if !self.description_p.isEmpty { + try visitor.visitSingularStringField(value: self.description_p, fieldNumber: 2) + } + try unknownFields.traverse(visitor: &visitor) + } + + public static func ==(lhs: Anytype_Rpc.Space.InviteChange.Response.Error, rhs: Anytype_Rpc.Space.InviteChange.Response.Error) -> Bool { + if lhs.code != rhs.code {return false} + if lhs.description_p != rhs.description_p {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension Anytype_Rpc.Space.InviteChange.Response.Error.Code: SwiftProtobuf._ProtoNameProviding { + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 0: .same(proto: "NULL"), + 1: .same(proto: "UNKNOWN_ERROR"), + 2: .same(proto: "BAD_INPUT"), + 101: .same(proto: "NO_SUCH_SPACE"), + 102: .same(proto: "SPACE_IS_DELETED"), + 103: .same(proto: "REQUEST_FAILED"), + 105: .same(proto: "INCORRECT_PERMISSIONS"), + ] +} + +// If the compiler emits an error on this type, it is because this file +// was generated by a version of the `protoc` Swift plug-in that is +// incompatible with the version of SwiftProtobuf to which you are linking. +// Please ensure that you are building against the same version of the API +// that was used to generate this file. +fileprivate struct _GeneratedWithProtocGenSwiftVersion: SwiftProtobuf.ProtobufAPIVersionCheck { + struct _2: SwiftProtobuf.ProtobufAPIVersion_2 {} + typealias Version = _2 +} + +// MARK: - Code below here is support for the SwiftProtobuf runtime. + +fileprivate let _protobuf_package = "anytype" diff --git a/Modules/ProtobufMessages/Sources/Protocol/Commands/Anytype_Rpc.Space.InviteGenerate.swift b/Modules/ProtobufMessages/Sources/Protocol/Commands/Anytype_Rpc.Space.InviteGenerate.swift index 18f4edeb82..835004ae74 100644 --- a/Modules/ProtobufMessages/Sources/Protocol/Commands/Anytype_Rpc.Space.InviteGenerate.swift +++ b/Modules/ProtobufMessages/Sources/Protocol/Commands/Anytype_Rpc.Space.InviteGenerate.swift @@ -26,43 +26,11 @@ extension Anytype_Rpc.Space { public var spaceID: String = String() - public var inviteType: Anytype_Rpc.Space.InviteGenerate.Request.InviteType = .member + public var inviteType: Anytype_Model_InviteType = .member - public var unknownFields = SwiftProtobuf.UnknownStorage() - - public enum InviteType: SwiftProtobuf.Enum, Swift.CaseIterable { - public typealias RawValue = Int - case member // = 0 - case guest // = 1 - case UNRECOGNIZED(Int) - - public init() { - self = .member - } - - public init?(rawValue: Int) { - switch rawValue { - case 0: self = .member - case 1: self = .guest - default: self = .UNRECOGNIZED(rawValue) - } - } - - public var rawValue: Int { - switch self { - case .member: return 0 - case .guest: return 1 - case .UNRECOGNIZED(let i): return i - } - } - - // The compiler won't synthesize support with the UNRECOGNIZED case. - public static let allCases: [Anytype_Rpc.Space.InviteGenerate.Request.InviteType] = [ - .member, - .guest, - ] + public var permissions: Anytype_Model_ParticipantPermissions = .reader - } + public var unknownFields = SwiftProtobuf.UnknownStorage() public init() {} } @@ -85,6 +53,10 @@ extension Anytype_Rpc.Space { public var inviteFileKey: String = String() + public var inviteType: Anytype_Model_InviteType = .member + + public var permissions: Anytype_Model_ParticipantPermissions = .reader + public var unknownFields = SwiftProtobuf.UnknownStorage() public struct Error: Sendable { @@ -192,6 +164,7 @@ extension Anytype_Rpc.Space.InviteGenerate.Request: SwiftProtobuf.Message, Swift public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ 1: .same(proto: "spaceId"), 2: .same(proto: "inviteType"), + 3: .same(proto: "permissions"), ] public mutating func decodeMessage(decoder: inout D) throws { @@ -202,6 +175,7 @@ extension Anytype_Rpc.Space.InviteGenerate.Request: SwiftProtobuf.Message, Swift switch fieldNumber { case 1: try { try decoder.decodeSingularStringField(value: &self.spaceID) }() case 2: try { try decoder.decodeSingularEnumField(value: &self.inviteType) }() + case 3: try { try decoder.decodeSingularEnumField(value: &self.permissions) }() default: break } } @@ -214,30 +188,29 @@ extension Anytype_Rpc.Space.InviteGenerate.Request: SwiftProtobuf.Message, Swift if self.inviteType != .member { try visitor.visitSingularEnumField(value: self.inviteType, fieldNumber: 2) } + if self.permissions != .reader { + try visitor.visitSingularEnumField(value: self.permissions, fieldNumber: 3) + } try unknownFields.traverse(visitor: &visitor) } public static func ==(lhs: Anytype_Rpc.Space.InviteGenerate.Request, rhs: Anytype_Rpc.Space.InviteGenerate.Request) -> Bool { if lhs.spaceID != rhs.spaceID {return false} if lhs.inviteType != rhs.inviteType {return false} + if lhs.permissions != rhs.permissions {return false} if lhs.unknownFields != rhs.unknownFields {return false} return true } } -extension Anytype_Rpc.Space.InviteGenerate.Request.InviteType: SwiftProtobuf._ProtoNameProviding { - public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 0: .same(proto: "Member"), - 1: .same(proto: "Guest"), - ] -} - extension Anytype_Rpc.Space.InviteGenerate.Response: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { public static let protoMessageName: String = Anytype_Rpc.Space.InviteGenerate.protoMessageName + ".Response" public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ 1: .same(proto: "error"), 2: .same(proto: "inviteCid"), 3: .same(proto: "inviteFileKey"), + 4: .same(proto: "inviteType"), + 5: .same(proto: "permissions"), ] public mutating func decodeMessage(decoder: inout D) throws { @@ -249,6 +222,8 @@ extension Anytype_Rpc.Space.InviteGenerate.Response: SwiftProtobuf.Message, Swif case 1: try { try decoder.decodeSingularMessageField(value: &self._error) }() case 2: try { try decoder.decodeSingularStringField(value: &self.inviteCid) }() case 3: try { try decoder.decodeSingularStringField(value: &self.inviteFileKey) }() + case 4: try { try decoder.decodeSingularEnumField(value: &self.inviteType) }() + case 5: try { try decoder.decodeSingularEnumField(value: &self.permissions) }() default: break } } @@ -268,6 +243,12 @@ extension Anytype_Rpc.Space.InviteGenerate.Response: SwiftProtobuf.Message, Swif if !self.inviteFileKey.isEmpty { try visitor.visitSingularStringField(value: self.inviteFileKey, fieldNumber: 3) } + if self.inviteType != .member { + try visitor.visitSingularEnumField(value: self.inviteType, fieldNumber: 4) + } + if self.permissions != .reader { + try visitor.visitSingularEnumField(value: self.permissions, fieldNumber: 5) + } try unknownFields.traverse(visitor: &visitor) } @@ -275,6 +256,8 @@ extension Anytype_Rpc.Space.InviteGenerate.Response: SwiftProtobuf.Message, Swif if lhs._error != rhs._error {return false} if lhs.inviteCid != rhs.inviteCid {return false} if lhs.inviteFileKey != rhs.inviteFileKey {return false} + if lhs.inviteType != rhs.inviteType {return false} + if lhs.permissions != rhs.permissions {return false} if lhs.unknownFields != rhs.unknownFields {return false} return true } diff --git a/Modules/ProtobufMessages/Sources/Protocol/Commands/Anytype_Rpc.Space.InviteGetCurrent.swift b/Modules/ProtobufMessages/Sources/Protocol/Commands/Anytype_Rpc.Space.InviteGetCurrent.swift index 6342d9ec24..9a76e49a11 100644 --- a/Modules/ProtobufMessages/Sources/Protocol/Commands/Anytype_Rpc.Space.InviteGetCurrent.swift +++ b/Modules/ProtobufMessages/Sources/Protocol/Commands/Anytype_Rpc.Space.InviteGetCurrent.swift @@ -49,6 +49,10 @@ extension Anytype_Rpc.Space { public var inviteFileKey: String = String() + public var inviteType: Anytype_Model_InviteType = .member + + public var permissions: Anytype_Model_ParticipantPermissions = .reader + public var unknownFields = SwiftProtobuf.UnknownStorage() public struct Error: Sendable { @@ -173,6 +177,8 @@ extension Anytype_Rpc.Space.InviteGetCurrent.Response: SwiftProtobuf.Message, Sw 1: .same(proto: "error"), 2: .same(proto: "inviteCid"), 3: .same(proto: "inviteFileKey"), + 4: .same(proto: "inviteType"), + 5: .same(proto: "permissions"), ] public mutating func decodeMessage(decoder: inout D) throws { @@ -184,6 +190,8 @@ extension Anytype_Rpc.Space.InviteGetCurrent.Response: SwiftProtobuf.Message, Sw case 1: try { try decoder.decodeSingularMessageField(value: &self._error) }() case 2: try { try decoder.decodeSingularStringField(value: &self.inviteCid) }() case 3: try { try decoder.decodeSingularStringField(value: &self.inviteFileKey) }() + case 4: try { try decoder.decodeSingularEnumField(value: &self.inviteType) }() + case 5: try { try decoder.decodeSingularEnumField(value: &self.permissions) }() default: break } } @@ -203,6 +211,12 @@ extension Anytype_Rpc.Space.InviteGetCurrent.Response: SwiftProtobuf.Message, Sw if !self.inviteFileKey.isEmpty { try visitor.visitSingularStringField(value: self.inviteFileKey, fieldNumber: 3) } + if self.inviteType != .member { + try visitor.visitSingularEnumField(value: self.inviteType, fieldNumber: 4) + } + if self.permissions != .reader { + try visitor.visitSingularEnumField(value: self.permissions, fieldNumber: 5) + } try unknownFields.traverse(visitor: &visitor) } @@ -210,6 +224,8 @@ extension Anytype_Rpc.Space.InviteGetCurrent.Response: SwiftProtobuf.Message, Sw if lhs._error != rhs._error {return false} if lhs.inviteCid != rhs.inviteCid {return false} if lhs.inviteFileKey != rhs.inviteFileKey {return false} + if lhs.inviteType != rhs.inviteType {return false} + if lhs.permissions != rhs.permissions {return false} if lhs.unknownFields != rhs.unknownFields {return false} return true } diff --git a/Modules/ProtobufMessages/Sources/Protocol/Commands/Anytype_Rpc.Space.InviteView.swift b/Modules/ProtobufMessages/Sources/Protocol/Commands/Anytype_Rpc.Space.InviteView.swift index 0dce1506c0..6797462acd 100644 --- a/Modules/ProtobufMessages/Sources/Protocol/Commands/Anytype_Rpc.Space.InviteView.swift +++ b/Modules/ProtobufMessages/Sources/Protocol/Commands/Anytype_Rpc.Space.InviteView.swift @@ -55,8 +55,11 @@ extension Anytype_Rpc.Space { public var creatorName: String = String() + /// deprecated, use inviteType public var isGuestUserInvite: Bool = false + public var inviteType: Anytype_Model_InviteType = .member + public var unknownFields = SwiftProtobuf.UnknownStorage() public struct Error: Sendable { @@ -198,6 +201,7 @@ extension Anytype_Rpc.Space.InviteView.Response: SwiftProtobuf.Message, SwiftPro 4: .same(proto: "spaceIconCid"), 5: .same(proto: "creatorName"), 6: .same(proto: "isGuestUserInvite"), + 7: .same(proto: "inviteType"), ] public mutating func decodeMessage(decoder: inout D) throws { @@ -212,6 +216,7 @@ extension Anytype_Rpc.Space.InviteView.Response: SwiftProtobuf.Message, SwiftPro case 4: try { try decoder.decodeSingularStringField(value: &self.spaceIconCid) }() case 5: try { try decoder.decodeSingularStringField(value: &self.creatorName) }() case 6: try { try decoder.decodeSingularBoolField(value: &self.isGuestUserInvite) }() + case 7: try { try decoder.decodeSingularEnumField(value: &self.inviteType) }() default: break } } @@ -240,6 +245,9 @@ extension Anytype_Rpc.Space.InviteView.Response: SwiftProtobuf.Message, SwiftPro if self.isGuestUserInvite != false { try visitor.visitSingularBoolField(value: self.isGuestUserInvite, fieldNumber: 6) } + if self.inviteType != .member { + try visitor.visitSingularEnumField(value: self.inviteType, fieldNumber: 7) + } try unknownFields.traverse(visitor: &visitor) } @@ -250,6 +258,7 @@ extension Anytype_Rpc.Space.InviteView.Response: SwiftProtobuf.Message, SwiftPro if lhs.spaceIconCid != rhs.spaceIconCid {return false} if lhs.creatorName != rhs.creatorName {return false} if lhs.isGuestUserInvite != rhs.isGuestUserInvite {return false} + if lhs.inviteType != rhs.inviteType {return false} if lhs.unknownFields != rhs.unknownFields {return false} return true } diff --git a/Modules/ProtobufMessages/Sources/Protocol/Models/Anytype_Model_InvitePayload.InviteType.swift b/Modules/ProtobufMessages/Sources/Protocol/Models/Anytype_Model_InvitePayload.InviteType.swift deleted file mode 100644 index fdcd8dbe38..0000000000 --- a/Modules/ProtobufMessages/Sources/Protocol/Models/Anytype_Model_InvitePayload.InviteType.swift +++ /dev/null @@ -1,73 +0,0 @@ -// DO NOT EDIT. -// swift-format-ignore-file -// swiftlint:disable all -// -// Generated by the Swift generator plugin for the protocol buffer compiler. -// Source: pkg/lib/pb/model/protos/models.proto -// -// For information on using the generated types, please see the documentation: -// https://github.com/apple/swift-protobuf/ - -import Foundation -import SwiftProtobuf - -extension Anytype_Model_InvitePayload { - - public enum InviteType: SwiftProtobuf.Enum, Swift.CaseIterable { - public typealias RawValue = Int - - /// aclKey contains the key to sign the ACL record - case joinAsMember // = 0 - - /// guestKey contains the privateKey of the guest user - case joinAsGuest // = 1 - case UNRECOGNIZED(Int) - - public init() { - self = .joinAsMember - } - - public init?(rawValue: Int) { - switch rawValue { - case 0: self = .joinAsMember - case 1: self = .joinAsGuest - default: self = .UNRECOGNIZED(rawValue) - } - } - - public var rawValue: Int { - switch self { - case .joinAsMember: return 0 - case .joinAsGuest: return 1 - case .UNRECOGNIZED(let i): return i - } - } - - // The compiler won't synthesize support with the UNRECOGNIZED case. - public static let allCases: [Anytype_Model_InvitePayload.InviteType] = [ - .joinAsMember, - .joinAsGuest, - ] - - }} - -extension Anytype_Model_InvitePayload.InviteType: SwiftProtobuf._ProtoNameProviding { - public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ - 0: .same(proto: "JoinAsMember"), - 1: .same(proto: "JoinAsGuest"), - ] -} - -// If the compiler emits an error on this type, it is because this file -// was generated by a version of the `protoc` Swift plug-in that is -// incompatible with the version of SwiftProtobuf to which you are linking. -// Please ensure that you are building against the same version of the API -// that was used to generate this file. -fileprivate struct _GeneratedWithProtocGenSwiftVersion: SwiftProtobuf.ProtobufAPIVersionCheck { - struct _2: SwiftProtobuf.ProtobufAPIVersion_2 {} - typealias Version = _2 -} - -// MARK: - Code below here is support for the SwiftProtobuf runtime. - -fileprivate let _protobuf_package = "anytype.model" diff --git a/Modules/ProtobufMessages/Sources/Protocol/Models/Anytype_Model_InvitePayload.swift b/Modules/ProtobufMessages/Sources/Protocol/Models/Anytype_Model_InvitePayload.swift index a958fee2f4..6b5f14bc02 100644 --- a/Modules/ProtobufMessages/Sources/Protocol/Models/Anytype_Model_InvitePayload.swift +++ b/Modules/ProtobufMessages/Sources/Protocol/Models/Anytype_Model_InvitePayload.swift @@ -29,7 +29,7 @@ public struct Anytype_Model_InvitePayload: @unchecked Sendable { public var spaceIconEncryptionKeys: [Anytype_Model_FileEncryptionKey] = [] - public var inviteType: Anytype_Model_InvitePayload.InviteType = .joinAsMember + public var inviteType: Anytype_Model_InviteType = .member public var guestKey: Data = Data() @@ -94,7 +94,7 @@ extension Anytype_Model_InvitePayload: SwiftProtobuf.Message, SwiftProtobuf._Mes if !self.spaceIconEncryptionKeys.isEmpty { try visitor.visitRepeatedMessageField(value: self.spaceIconEncryptionKeys, fieldNumber: 7) } - if self.inviteType != .joinAsMember { + if self.inviteType != .member { try visitor.visitSingularEnumField(value: self.inviteType, fieldNumber: 8) } if !self.guestKey.isEmpty { diff --git a/Modules/ProtobufMessages/Sources/Protocol/Models/Anytype_Model_InviteType.swift b/Modules/ProtobufMessages/Sources/Protocol/Models/Anytype_Model_InviteType.swift new file mode 100644 index 0000000000..155e2fcb9b --- /dev/null +++ b/Modules/ProtobufMessages/Sources/Protocol/Models/Anytype_Model_InviteType.swift @@ -0,0 +1,78 @@ +// DO NOT EDIT. +// swift-format-ignore-file +// swiftlint:disable all +// +// Generated by the Swift generator plugin for the protocol buffer compiler. +// Source: pkg/lib/pb/model/protos/models.proto +// +// For information on using the generated types, please see the documentation: +// https://github.com/apple/swift-protobuf/ + +import Foundation +import SwiftProtobuf + +public enum Anytype_Model_InviteType: SwiftProtobuf.Enum, Swift.CaseIterable { + public typealias RawValue = Int + + /// aclKey contains the key to sign the ACL record + case member // = 0 + + /// guestKey contains the privateKey of the guest user + case guest // = 1 + + /// aclKey contains the key to sign the ACL record, but no approval needed + case withoutApprove // = 2 + case UNRECOGNIZED(Int) + + public init() { + self = .member + } + + public init?(rawValue: Int) { + switch rawValue { + case 0: self = .member + case 1: self = .guest + case 2: self = .withoutApprove + default: self = .UNRECOGNIZED(rawValue) + } + } + + public var rawValue: Int { + switch self { + case .member: return 0 + case .guest: return 1 + case .withoutApprove: return 2 + case .UNRECOGNIZED(let i): return i + } + } + + // The compiler won't synthesize support with the UNRECOGNIZED case. + public static let allCases: [Anytype_Model_InviteType] = [ + .member, + .guest, + .withoutApprove, + ] + +} + +extension Anytype_Model_InviteType: SwiftProtobuf._ProtoNameProviding { + public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 0: .same(proto: "Member"), + 1: .same(proto: "Guest"), + 2: .same(proto: "WithoutApprove"), + ] +} + +// If the compiler emits an error on this type, it is because this file +// was generated by a version of the `protoc` Swift plug-in that is +// incompatible with the version of SwiftProtobuf to which you are linking. +// Please ensure that you are building against the same version of the API +// that was used to generate this file. +fileprivate struct _GeneratedWithProtocGenSwiftVersion: SwiftProtobuf.ProtobufAPIVersionCheck { + struct _2: SwiftProtobuf.ProtobufAPIVersion_2 {} + typealias Version = _2 +} + +// MARK: - Code below here is support for the SwiftProtobuf runtime. + +fileprivate let _protobuf_package = "anytype.model" diff --git a/Modules/Services/Sources/Generated/BundledRelationKey+SystemKeys.swift b/Modules/Services/Sources/Generated/BundledRelationKey+SystemKeys.swift index 03b0b75552..2564365ccd 100644 --- a/Modules/Services/Sources/Generated/BundledRelationKey+SystemKeys.swift +++ b/Modules/Services/Sources/Generated/BundledRelationKey+SystemKeys.swift @@ -78,6 +78,8 @@ public extension BundledRelationKey { .spaceAccessType, .spaceInviteFileCid, .spaceInviteFileKey, + .spaceInviteType, + .spaceInvitePermissions, .readersLimit, .writersLimit, .sharedSpacesLimit, diff --git a/Modules/Services/Sources/Generated/BundledRelationKey.swift b/Modules/Services/Sources/Generated/BundledRelationKey.swift index 8b456cc5d8..14f13c2d2e 100644 --- a/Modules/Services/Sources/Generated/BundledRelationKey.swift +++ b/Modules/Services/Sources/Generated/BundledRelationKey.swift @@ -328,6 +328,9 @@ public enum BundledRelationKey: String, Sendable { /// Encoded encryption key of invite file for current space. It stored in SpaceView case spaceInviteFileKey = "spaceInviteFileKey" + /// Encoded encryption key of invite file for current space. It stored in SpaceView + case spaceInviteType = "spaceInviteType" + /// CID of invite file for for guest user in the current space. It's stored in SpaceView case spaceInviteGuestFileCid = "spaceInviteGuestFileCid" @@ -340,6 +343,9 @@ public enum BundledRelationKey: String, Sendable { /// Participant permissions. Possible values: models.ParticipantPermissions case participantPermissions = "participantPermissions" + /// Invite permissions. Possible values: models.ParticipantPermissions + case spaceInvitePermissions = "spaceInvitePermissions" + /// Identity case identity = "identity" diff --git a/Modules/Services/Sources/Generated/BundledRelationsValueProvider.swift b/Modules/Services/Sources/Generated/BundledRelationsValueProvider.swift index 139ce87bb9..6040553658 100644 --- a/Modules/Services/Sources/Generated/BundledRelationsValueProvider.swift +++ b/Modules/Services/Sources/Generated/BundledRelationsValueProvider.swift @@ -123,10 +123,12 @@ public protocol BundledRelationsValueProvider { var spaceAccountStatus: Int? { get } var spaceInviteFileCid: String { get } var spaceInviteFileKey: String { get } + var spaceInviteType: Int? { get } var spaceInviteGuestFileCid: String { get } var spaceInviteGuestFileKey: String { get } var guestKey: String { get } var participantPermissions: Int? { get } + var spaceInvitePermissions: Int? { get } var identity: String { get } var participantStatus: Int? { get } var identityProfileLink: ObjectId { get } @@ -597,6 +599,10 @@ public extension BundledRelationsValueProvider where Self: RelationValueProvider var spaceInviteFileKey: String { return value(for: BundledRelationKey.spaceInviteFileKey.rawValue) } + /// Encoded encryption key of invite file for current space. It stored in SpaceView + var spaceInviteType: Int? { + return value(for: BundledRelationKey.spaceInviteType.rawValue) + } /// CID of invite file for for guest user in the current space. It's stored in SpaceView var spaceInviteGuestFileCid: String { return value(for: BundledRelationKey.spaceInviteGuestFileCid.rawValue) @@ -613,6 +619,10 @@ public extension BundledRelationsValueProvider where Self: RelationValueProvider var participantPermissions: Int? { return value(for: BundledRelationKey.participantPermissions.rawValue) } + /// Invite permissions. Possible values: models.ParticipantPermissions + var spaceInvitePermissions: Int? { + return value(for: BundledRelationKey.spaceInvitePermissions.rawValue) + } /// Identity var identity: String { return value(for: BundledRelationKey.identity.rawValue) diff --git a/Modules/Services/Sources/Models/Space/SpaceAliases.swift b/Modules/Services/Sources/Models/Space/SpaceAliases.swift index ac9567f536..9d34b1aa8e 100644 --- a/Modules/Services/Sources/Models/Space/SpaceAliases.swift +++ b/Modules/Services/Sources/Models/Space/SpaceAliases.swift @@ -4,3 +4,4 @@ import AnytypeCore public typealias SpaceStatus = Anytype_Model_SpaceStatus public typealias SpaceUxType = Anytype_Model_SpaceUxType +public typealias InviteType = Anytype_Model_InviteType diff --git a/Modules/Services/Sources/Models/Space/SpaceInvite.swift b/Modules/Services/Sources/Models/Space/SpaceInvite.swift index f7997670f8..0afd79ef7a 100644 --- a/Modules/Services/Sources/Models/Space/SpaceInvite.swift +++ b/Modules/Services/Sources/Models/Space/SpaceInvite.swift @@ -4,22 +4,23 @@ import ProtobufMessages public struct SpaceInvite: Sendable { public let cid: String public let fileKey: String + public let inviteType: InviteType? } extension Anytype_Rpc.Space.InviteGenerate.Response { func asModel() -> SpaceInvite { - return SpaceInvite(cid: inviteCid, fileKey: inviteFileKey) + return SpaceInvite(cid: inviteCid, fileKey: inviteFileKey, inviteType: inviteType) } } extension Anytype_Rpc.Space.InviteGetCurrent.Response { func asModel() -> SpaceInvite { - return SpaceInvite(cid: inviteCid, fileKey: inviteFileKey) + return SpaceInvite(cid: inviteCid, fileKey: inviteFileKey, inviteType: inviteType) } } extension Anytype_Rpc.Space.InviteGetGuest.Response { func asModel() -> SpaceInvite { - return SpaceInvite(cid: inviteCid, fileKey: inviteFileKey) + return SpaceInvite(cid: inviteCid, fileKey: inviteFileKey, inviteType: nil) } } diff --git a/Modules/Services/Sources/Models/Space/SpaceInviteView.swift b/Modules/Services/Sources/Models/Space/SpaceInviteView.swift index ea3ffc0afd..327fcaf0ed 100644 --- a/Modules/Services/Sources/Models/Space/SpaceInviteView.swift +++ b/Modules/Services/Sources/Models/Space/SpaceInviteView.swift @@ -6,6 +6,7 @@ public struct SpaceInviteView: Sendable { public let spaceName: String public let spaceIconCid: String public let creatorName: String + public let inviteType: InviteType } extension Anytype_Rpc.Space.InviteView.Response { @@ -14,7 +15,14 @@ extension Anytype_Rpc.Space.InviteView.Response { spaceId: spaceID, spaceName: spaceName, spaceIconCid: spaceIconCid, - creatorName: creatorName + creatorName: creatorName, + inviteType: inviteType ) } } + +public extension InviteType { + var withoutApprove: Bool { + self == .withoutApprove + } +}