diff --git a/SessionMessagingKit/Protos/Generated/SNProto.swift b/SessionMessagingKit/Protos/Generated/SNProto.swift index 457848361..442d87c2e 100644 --- a/SessionMessagingKit/Protos/Generated/SNProto.swift +++ b/SessionMessagingKit/Protos/Generated/SNProto.swift @@ -1633,6 +1633,171 @@ extension SNProtoDataMessagePreview.SNProtoDataMessagePreviewBuilder { #endif +// MARK: - SNProtoDataMessageReaction + +@objc public class SNProtoDataMessageReaction: NSObject { + + // MARK: - SNProtoDataMessageReactionAction + + @objc public enum SNProtoDataMessageReactionAction: Int32 { + case react = 0 + case remove = 1 + } + + private class func SNProtoDataMessageReactionActionWrap(_ value: SessionProtos_DataMessage.Reaction.Action) -> SNProtoDataMessageReactionAction { + switch value { + case .react: return .react + case .remove: return .remove + } + } + + private class func SNProtoDataMessageReactionActionUnwrap(_ value: SNProtoDataMessageReactionAction) -> SessionProtos_DataMessage.Reaction.Action { + switch value { + case .react: return .react + case .remove: return .remove + } + } + + // MARK: - SNProtoDataMessageReactionBuilder + + @objc public class func builder(id: UInt64, author: String, action: SNProtoDataMessageReactionAction) -> SNProtoDataMessageReactionBuilder { + return SNProtoDataMessageReactionBuilder(id: id, author: author, action: action) + } + + // asBuilder() constructs a builder that reflects the proto's contents. + @objc public func asBuilder() -> SNProtoDataMessageReactionBuilder { + let builder = SNProtoDataMessageReactionBuilder(id: id, author: author, action: action) + if let _value = emoji { + builder.setEmoji(_value) + } + return builder + } + + @objc public class SNProtoDataMessageReactionBuilder: NSObject { + + private var proto = SessionProtos_DataMessage.Reaction() + + @objc fileprivate override init() {} + + @objc fileprivate init(id: UInt64, author: String, action: SNProtoDataMessageReactionAction) { + super.init() + + setId(id) + setAuthor(author) + setAction(action) + } + + @objc public func setId(_ valueParam: UInt64) { + proto.id = valueParam + } + + @objc public func setAuthor(_ valueParam: String) { + proto.author = valueParam + } + + @objc public func setEmoji(_ valueParam: String) { + proto.emoji = valueParam + } + + @objc public func setAction(_ valueParam: SNProtoDataMessageReactionAction) { + proto.action = SNProtoDataMessageReactionActionUnwrap(valueParam) + } + + @objc public func build() throws -> SNProtoDataMessageReaction { + return try SNProtoDataMessageReaction.parseProto(proto) + } + + @objc public func buildSerializedData() throws -> Data { + return try SNProtoDataMessageReaction.parseProto(proto).serializedData() + } + } + + fileprivate let proto: SessionProtos_DataMessage.Reaction + + @objc public let id: UInt64 + + @objc public let author: String + + @objc public let action: SNProtoDataMessageReactionAction + + @objc public var emoji: String? { + guard proto.hasEmoji else { + return nil + } + return proto.emoji + } + @objc public var hasEmoji: Bool { + return proto.hasEmoji + } + + private init(proto: SessionProtos_DataMessage.Reaction, + id: UInt64, + author: String, + action: SNProtoDataMessageReactionAction) { + self.proto = proto + self.id = id + self.author = author + self.action = action + } + + @objc + public func serializedData() throws -> Data { + return try self.proto.serializedData() + } + + @objc public class func parseData(_ serializedData: Data) throws -> SNProtoDataMessageReaction { + let proto = try SessionProtos_DataMessage.Reaction(serializedData: serializedData) + return try parseProto(proto) + } + + fileprivate class func parseProto(_ proto: SessionProtos_DataMessage.Reaction) throws -> SNProtoDataMessageReaction { + guard proto.hasID else { + throw SNProtoError.invalidProtobuf(description: "\(logTag) missing required field: id") + } + let id = proto.id + + guard proto.hasAuthor else { + throw SNProtoError.invalidProtobuf(description: "\(logTag) missing required field: author") + } + let author = proto.author + + guard proto.hasAction else { + throw SNProtoError.invalidProtobuf(description: "\(logTag) missing required field: action") + } + let action = SNProtoDataMessageReactionActionWrap(proto.action) + + // MARK: - Begin Validation Logic for SNProtoDataMessageReaction - + + // MARK: - End Validation Logic for SNProtoDataMessageReaction - + + let result = SNProtoDataMessageReaction(proto: proto, + id: id, + author: author, + action: action) + return result + } + + @objc public override var debugDescription: String { + return "\(proto)" + } +} + +#if DEBUG + +extension SNProtoDataMessageReaction { + @objc public func serializedDataIgnoringErrors() -> Data? { + return try! self.serializedData() + } +} + +extension SNProtoDataMessageReaction.SNProtoDataMessageReactionBuilder { + @objc public func buildIgnoringErrors() -> SNProtoDataMessageReaction? { + return try! self.build() + } +} + +#endif + // MARK: - SNProtoDataMessageLokiProfile @objc public class SNProtoDataMessageLokiProfile: NSObject { diff --git a/SessionMessagingKit/Protos/Generated/SessionProtos.pb.swift b/SessionMessagingKit/Protos/Generated/SessionProtos.pb.swift index 854fd1ad2..cc1bf5c28 100644 --- a/SessionMessagingKit/Protos/Generated/SessionProtos.pb.swift +++ b/SessionMessagingKit/Protos/Generated/SessionProtos.pb.swift @@ -821,6 +821,86 @@ struct SessionProtos_DataMessage { fileprivate var _image: SessionProtos_AttachmentPointer? = nil } + struct Reaction { + // 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. + + /// @required + var id: UInt64 { + get {return _id ?? 0} + set {_id = newValue} + } + /// Returns true if `id` has been explicitly set. + var hasID: Bool {return self._id != nil} + /// Clears the value of `id`. Subsequent reads from it will return its default value. + mutating func clearID() {self._id = nil} + + /// @required + var author: String { + get {return _author ?? String()} + set {_author = newValue} + } + /// Returns true if `author` has been explicitly set. + var hasAuthor: Bool {return self._author != nil} + /// Clears the value of `author`. Subsequent reads from it will return its default value. + mutating func clearAuthor() {self._author = nil} + + var emoji: String { + get {return _emoji ?? String()} + set {_emoji = newValue} + } + /// Returns true if `emoji` has been explicitly set. + var hasEmoji: Bool {return self._emoji != nil} + /// Clears the value of `emoji`. Subsequent reads from it will return its default value. + mutating func clearEmoji() {self._emoji = nil} + + /// @required + var action: SessionProtos_DataMessage.Reaction.Action { + get {return _action ?? .react} + set {_action = newValue} + } + /// Returns true if `action` has been explicitly set. + var hasAction: Bool {return self._action != nil} + /// Clears the value of `action`. Subsequent reads from it will return its default value. + mutating func clearAction() {self._action = nil} + + var unknownFields = SwiftProtobuf.UnknownStorage() + + enum Action: SwiftProtobuf.Enum { + typealias RawValue = Int + case react // = 0 + case remove // = 1 + + init() { + self = .react + } + + init?(rawValue: Int) { + switch rawValue { + case 0: self = .react + case 1: self = .remove + default: return nil + } + } + + var rawValue: Int { + switch self { + case .react: return 0 + case .remove: return 1 + } + } + + } + + init() {} + + fileprivate var _id: UInt64? = nil + fileprivate var _author: String? = nil + fileprivate var _emoji: String? = nil + fileprivate var _action: SessionProtos_DataMessage.Reaction.Action? = nil + } + struct LokiProfile { // SwiftProtobuf.Message conformance is added in an extension below. See the // `Message` and `Message+*Additions` files in the SwiftProtobuf library for @@ -1052,6 +1132,10 @@ extension SessionProtos_DataMessage.Quote.QuotedAttachment.Flags: CaseIterable { // Support synthesized by the compiler. } +extension SessionProtos_DataMessage.Reaction.Action: CaseIterable { + // Support synthesized by the compiler. +} + extension SessionProtos_DataMessage.ClosedGroupControlMessage.TypeEnum: CaseIterable { // Support synthesized by the compiler. } @@ -2428,6 +2512,70 @@ extension SessionProtos_DataMessage.Preview: SwiftProtobuf.Message, SwiftProtobu } } +extension SessionProtos_DataMessage.Reaction: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { + static let protoMessageName: String = SessionProtos_DataMessage.protoMessageName + ".Reaction" + static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 1: .same(proto: "id"), + 2: .same(proto: "author"), + 3: .same(proto: "emoji"), + 4: .same(proto: "action"), + ] + + public var isInitialized: Bool { + if self._id == nil {return false} + if self._author == nil {return false} + if self._action == nil {return false} + return true + } + + 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.decodeSingularUInt64Field(value: &self._id) }() + case 2: try { try decoder.decodeSingularStringField(value: &self._author) }() + case 3: try { try decoder.decodeSingularStringField(value: &self._emoji) }() + case 4: try { try decoder.decodeSingularEnumField(value: &self._action) }() + default: break + } + } + } + + func traverse(visitor: inout V) throws { + if let v = self._id { + try visitor.visitSingularUInt64Field(value: v, fieldNumber: 1) + } + if let v = self._author { + try visitor.visitSingularStringField(value: v, fieldNumber: 2) + } + if let v = self._emoji { + try visitor.visitSingularStringField(value: v, fieldNumber: 3) + } + if let v = self._action { + try visitor.visitSingularEnumField(value: v, fieldNumber: 4) + } + try unknownFields.traverse(visitor: &visitor) + } + + static func ==(lhs: SessionProtos_DataMessage.Reaction, rhs: SessionProtos_DataMessage.Reaction) -> Bool { + if lhs._id != rhs._id {return false} + if lhs._author != rhs._author {return false} + if lhs._emoji != rhs._emoji {return false} + if lhs._action != rhs._action {return false} + if lhs.unknownFields != rhs.unknownFields {return false} + return true + } +} + +extension SessionProtos_DataMessage.Reaction.Action: SwiftProtobuf._ProtoNameProviding { + static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ + 0: .same(proto: "REACT"), + 1: .same(proto: "REMOVE"), + ] +} + extension SessionProtos_DataMessage.LokiProfile: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { static let protoMessageName: String = SessionProtos_DataMessage.protoMessageName + ".LokiProfile" static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ diff --git a/SessionMessagingKit/Protos/SessionProtos.proto b/SessionMessagingKit/Protos/SessionProtos.proto index 1f3962c55..6df37aef9 100644 --- a/SessionMessagingKit/Protos/SessionProtos.proto +++ b/SessionMessagingKit/Protos/SessionProtos.proto @@ -133,6 +133,20 @@ message DataMessage { optional AttachmentPointer image = 3; } + message Reaction { + enum Action { + REACT = 0; + REMOVE = 1; + } + // @required + required uint64 id = 1; // Message timestamp + // @required + required string author = 2; + optional string emoji = 3; + // @required + required Action action = 4; + } + message LokiProfile { optional string displayName = 1; optional string profilePicture = 2;