Update protos to reflect link previews.
This commit is contained in:
parent
623c2574d0
commit
76f410b2b7
|
@ -206,6 +206,12 @@ message DataMessage {
|
|||
optional string organization = 7;
|
||||
}
|
||||
|
||||
message Preview {
|
||||
optional string url = 1;
|
||||
optional string title = 2;
|
||||
optional AttachmentPointer image = 3;
|
||||
}
|
||||
|
||||
optional string body = 1;
|
||||
repeated AttachmentPointer attachments = 2;
|
||||
optional GroupContext group = 3;
|
||||
|
@ -215,6 +221,7 @@ message DataMessage {
|
|||
optional uint64 timestamp = 7;
|
||||
optional Quote quote = 8;
|
||||
repeated Contact contact = 9;
|
||||
optional Preview preview = 10;
|
||||
}
|
||||
|
||||
message NullMessage {
|
||||
|
|
|
@ -2673,6 +2673,134 @@ extension SSKProtoDataMessageContact.SSKProtoDataMessageContactBuilder {
|
|||
|
||||
#endif
|
||||
|
||||
// MARK: - SSKProtoDataMessagePreview
|
||||
|
||||
@objc public class SSKProtoDataMessagePreview: NSObject {
|
||||
|
||||
// MARK: - SSKProtoDataMessagePreviewBuilder
|
||||
|
||||
@objc public class func builder() -> SSKProtoDataMessagePreviewBuilder {
|
||||
return SSKProtoDataMessagePreviewBuilder()
|
||||
}
|
||||
|
||||
// asBuilder() constructs a builder that reflects the proto's contents.
|
||||
@objc public func asBuilder() -> SSKProtoDataMessagePreviewBuilder {
|
||||
let builder = SSKProtoDataMessagePreviewBuilder()
|
||||
if let _value = url {
|
||||
builder.setUrl(_value)
|
||||
}
|
||||
if let _value = title {
|
||||
builder.setTitle(_value)
|
||||
}
|
||||
if let _value = image {
|
||||
builder.setImage(_value)
|
||||
}
|
||||
return builder
|
||||
}
|
||||
|
||||
@objc public class SSKProtoDataMessagePreviewBuilder: NSObject {
|
||||
|
||||
private var proto = SignalServiceProtos_DataMessage.Preview()
|
||||
|
||||
@objc fileprivate override init() {}
|
||||
|
||||
@objc public func setUrl(_ valueParam: String) {
|
||||
proto.url = valueParam
|
||||
}
|
||||
|
||||
@objc public func setTitle(_ valueParam: String) {
|
||||
proto.title = valueParam
|
||||
}
|
||||
|
||||
@objc public func setImage(_ valueParam: SSKProtoAttachmentPointer) {
|
||||
proto.image = valueParam.proto
|
||||
}
|
||||
|
||||
@objc public func build() throws -> SSKProtoDataMessagePreview {
|
||||
return try SSKProtoDataMessagePreview.parseProto(proto)
|
||||
}
|
||||
|
||||
@objc public func buildSerializedData() throws -> Data {
|
||||
return try SSKProtoDataMessagePreview.parseProto(proto).serializedData()
|
||||
}
|
||||
}
|
||||
|
||||
fileprivate let proto: SignalServiceProtos_DataMessage.Preview
|
||||
|
||||
@objc public let image: SSKProtoAttachmentPointer?
|
||||
|
||||
@objc public var url: String? {
|
||||
guard proto.hasUrl else {
|
||||
return nil
|
||||
}
|
||||
return proto.url
|
||||
}
|
||||
@objc public var hasUrl: Bool {
|
||||
return proto.hasUrl
|
||||
}
|
||||
|
||||
@objc public var title: String? {
|
||||
guard proto.hasTitle else {
|
||||
return nil
|
||||
}
|
||||
return proto.title
|
||||
}
|
||||
@objc public var hasTitle: Bool {
|
||||
return proto.hasTitle
|
||||
}
|
||||
|
||||
private init(proto: SignalServiceProtos_DataMessage.Preview,
|
||||
image: SSKProtoAttachmentPointer?) {
|
||||
self.proto = proto
|
||||
self.image = image
|
||||
}
|
||||
|
||||
@objc
|
||||
public func serializedData() throws -> Data {
|
||||
return try self.proto.serializedData()
|
||||
}
|
||||
|
||||
@objc public class func parseData(_ serializedData: Data) throws -> SSKProtoDataMessagePreview {
|
||||
let proto = try SignalServiceProtos_DataMessage.Preview(serializedData: serializedData)
|
||||
return try parseProto(proto)
|
||||
}
|
||||
|
||||
fileprivate class func parseProto(_ proto: SignalServiceProtos_DataMessage.Preview) throws -> SSKProtoDataMessagePreview {
|
||||
var image: SSKProtoAttachmentPointer? = nil
|
||||
if proto.hasImage {
|
||||
image = try SSKProtoAttachmentPointer.parseProto(proto.image)
|
||||
}
|
||||
|
||||
// MARK: - Begin Validation Logic for SSKProtoDataMessagePreview -
|
||||
|
||||
// MARK: - End Validation Logic for SSKProtoDataMessagePreview -
|
||||
|
||||
let result = SSKProtoDataMessagePreview(proto: proto,
|
||||
image: image)
|
||||
return result
|
||||
}
|
||||
|
||||
@objc public override var debugDescription: String {
|
||||
return "\(proto)"
|
||||
}
|
||||
}
|
||||
|
||||
#if DEBUG
|
||||
|
||||
extension SSKProtoDataMessagePreview {
|
||||
@objc public func serializedDataIgnoringErrors() -> Data? {
|
||||
return try! self.serializedData()
|
||||
}
|
||||
}
|
||||
|
||||
extension SSKProtoDataMessagePreview.SSKProtoDataMessagePreviewBuilder {
|
||||
@objc public func buildIgnoringErrors() -> SSKProtoDataMessagePreview? {
|
||||
return try! self.build()
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
// MARK: - SSKProtoDataMessage
|
||||
|
||||
@objc public class SSKProtoDataMessage: NSObject {
|
||||
|
@ -2733,6 +2861,9 @@ extension SSKProtoDataMessageContact.SSKProtoDataMessageContactBuilder {
|
|||
builder.setQuote(_value)
|
||||
}
|
||||
builder.setContact(contact)
|
||||
if let _value = preview {
|
||||
builder.setPreview(_value)
|
||||
}
|
||||
return builder
|
||||
}
|
||||
|
||||
|
@ -2790,6 +2921,10 @@ extension SSKProtoDataMessageContact.SSKProtoDataMessageContactBuilder {
|
|||
proto.contact = wrappedItems.map { $0.proto }
|
||||
}
|
||||
|
||||
@objc public func setPreview(_ valueParam: SSKProtoDataMessagePreview) {
|
||||
proto.preview = valueParam.proto
|
||||
}
|
||||
|
||||
@objc public func build() throws -> SSKProtoDataMessage {
|
||||
return try SSKProtoDataMessage.parseProto(proto)
|
||||
}
|
||||
|
@ -2809,6 +2944,8 @@ extension SSKProtoDataMessageContact.SSKProtoDataMessageContactBuilder {
|
|||
|
||||
@objc public let contact: [SSKProtoDataMessageContact]
|
||||
|
||||
@objc public let preview: SSKProtoDataMessagePreview?
|
||||
|
||||
@objc public var body: String? {
|
||||
guard proto.hasBody else {
|
||||
return nil
|
||||
|
@ -2854,12 +2991,14 @@ extension SSKProtoDataMessageContact.SSKProtoDataMessageContactBuilder {
|
|||
attachments: [SSKProtoAttachmentPointer],
|
||||
group: SSKProtoGroupContext?,
|
||||
quote: SSKProtoDataMessageQuote?,
|
||||
contact: [SSKProtoDataMessageContact]) {
|
||||
contact: [SSKProtoDataMessageContact],
|
||||
preview: SSKProtoDataMessagePreview?) {
|
||||
self.proto = proto
|
||||
self.attachments = attachments
|
||||
self.group = group
|
||||
self.quote = quote
|
||||
self.contact = contact
|
||||
self.preview = preview
|
||||
}
|
||||
|
||||
@objc
|
||||
|
@ -2889,6 +3028,11 @@ extension SSKProtoDataMessageContact.SSKProtoDataMessageContactBuilder {
|
|||
var contact: [SSKProtoDataMessageContact] = []
|
||||
contact = try proto.contact.map { try SSKProtoDataMessageContact.parseProto($0) }
|
||||
|
||||
var preview: SSKProtoDataMessagePreview? = nil
|
||||
if proto.hasPreview {
|
||||
preview = try SSKProtoDataMessagePreview.parseProto(proto.preview)
|
||||
}
|
||||
|
||||
// MARK: - Begin Validation Logic for SSKProtoDataMessage -
|
||||
|
||||
// MARK: - End Validation Logic for SSKProtoDataMessage -
|
||||
|
@ -2897,7 +3041,8 @@ extension SSKProtoDataMessageContact.SSKProtoDataMessageContactBuilder {
|
|||
attachments: attachments,
|
||||
group: group,
|
||||
quote: quote,
|
||||
contact: contact)
|
||||
contact: contact,
|
||||
preview: preview)
|
||||
return result
|
||||
}
|
||||
|
||||
|
|
|
@ -634,6 +634,15 @@ struct SignalServiceProtos_DataMessage {
|
|||
set {_uniqueStorage()._contact = newValue}
|
||||
}
|
||||
|
||||
var preview: SignalServiceProtos_DataMessage.Preview {
|
||||
get {return _storage._preview ?? SignalServiceProtos_DataMessage.Preview()}
|
||||
set {_uniqueStorage()._preview = newValue}
|
||||
}
|
||||
/// Returns true if `preview` has been explicitly set.
|
||||
var hasPreview: Bool {return _storage._preview != nil}
|
||||
/// Clears the value of `preview`. Subsequent reads from it will return its default value.
|
||||
mutating func clearPreview() {_uniqueStorage()._preview = nil}
|
||||
|
||||
var unknownFields = SwiftProtobuf.UnknownStorage()
|
||||
|
||||
enum Flags: SwiftProtobuf.Enum {
|
||||
|
@ -1212,6 +1221,45 @@ struct SignalServiceProtos_DataMessage {
|
|||
fileprivate var _storage = _StorageClass.defaultInstance
|
||||
}
|
||||
|
||||
struct Preview {
|
||||
// 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.
|
||||
|
||||
var url: String {
|
||||
get {return _storage._url ?? String()}
|
||||
set {_uniqueStorage()._url = newValue}
|
||||
}
|
||||
/// Returns true if `url` has been explicitly set.
|
||||
var hasURL: Bool {return _storage._url != nil}
|
||||
/// Clears the value of `url`. Subsequent reads from it will return its default value.
|
||||
mutating func clearURL() {_uniqueStorage()._url = nil}
|
||||
|
||||
var title: String {
|
||||
get {return _storage._title ?? String()}
|
||||
set {_uniqueStorage()._title = newValue}
|
||||
}
|
||||
/// Returns true if `title` has been explicitly set.
|
||||
var hasTitle: Bool {return _storage._title != nil}
|
||||
/// Clears the value of `title`. Subsequent reads from it will return its default value.
|
||||
mutating func clearTitle() {_uniqueStorage()._title = nil}
|
||||
|
||||
var image: SignalServiceProtos_AttachmentPointer {
|
||||
get {return _storage._image ?? SignalServiceProtos_AttachmentPointer()}
|
||||
set {_uniqueStorage()._image = newValue}
|
||||
}
|
||||
/// Returns true if `image` has been explicitly set.
|
||||
var hasImage: Bool {return _storage._image != nil}
|
||||
/// Clears the value of `image`. Subsequent reads from it will return its default value.
|
||||
mutating func clearImage() {_uniqueStorage()._image = nil}
|
||||
|
||||
var unknownFields = SwiftProtobuf.UnknownStorage()
|
||||
|
||||
init() {}
|
||||
|
||||
fileprivate var _storage = _StorageClass.defaultInstance
|
||||
}
|
||||
|
||||
init() {}
|
||||
|
||||
fileprivate var _storage = _StorageClass.defaultInstance
|
||||
|
@ -2772,6 +2820,7 @@ extension SignalServiceProtos_DataMessage: SwiftProtobuf.Message, SwiftProtobuf.
|
|||
7: .same(proto: "timestamp"),
|
||||
8: .same(proto: "quote"),
|
||||
9: .same(proto: "contact"),
|
||||
10: .same(proto: "preview"),
|
||||
]
|
||||
|
||||
fileprivate class _StorageClass {
|
||||
|
@ -2784,6 +2833,7 @@ extension SignalServiceProtos_DataMessage: SwiftProtobuf.Message, SwiftProtobuf.
|
|||
var _timestamp: UInt64? = nil
|
||||
var _quote: SignalServiceProtos_DataMessage.Quote? = nil
|
||||
var _contact: [SignalServiceProtos_DataMessage.Contact] = []
|
||||
var _preview: SignalServiceProtos_DataMessage.Preview? = nil
|
||||
|
||||
static let defaultInstance = _StorageClass()
|
||||
|
||||
|
@ -2799,6 +2849,7 @@ extension SignalServiceProtos_DataMessage: SwiftProtobuf.Message, SwiftProtobuf.
|
|||
_timestamp = source._timestamp
|
||||
_quote = source._quote
|
||||
_contact = source._contact
|
||||
_preview = source._preview
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2823,6 +2874,7 @@ extension SignalServiceProtos_DataMessage: SwiftProtobuf.Message, SwiftProtobuf.
|
|||
case 7: try decoder.decodeSingularUInt64Field(value: &_storage._timestamp)
|
||||
case 8: try decoder.decodeSingularMessageField(value: &_storage._quote)
|
||||
case 9: try decoder.decodeRepeatedMessageField(value: &_storage._contact)
|
||||
case 10: try decoder.decodeSingularMessageField(value: &_storage._preview)
|
||||
default: break
|
||||
}
|
||||
}
|
||||
|
@ -2858,6 +2910,9 @@ extension SignalServiceProtos_DataMessage: SwiftProtobuf.Message, SwiftProtobuf.
|
|||
if !_storage._contact.isEmpty {
|
||||
try visitor.visitRepeatedMessageField(value: _storage._contact, fieldNumber: 9)
|
||||
}
|
||||
if let v = _storage._preview {
|
||||
try visitor.visitSingularMessageField(value: v, fieldNumber: 10)
|
||||
}
|
||||
}
|
||||
try unknownFields.traverse(visitor: &visitor)
|
||||
}
|
||||
|
@ -2876,6 +2931,7 @@ extension SignalServiceProtos_DataMessage: SwiftProtobuf.Message, SwiftProtobuf.
|
|||
if _storage._timestamp != rhs_storage._timestamp {return false}
|
||||
if _storage._quote != rhs_storage._quote {return false}
|
||||
if _storage._contact != rhs_storage._contact {return false}
|
||||
if _storage._preview != rhs_storage._preview {return false}
|
||||
return true
|
||||
}
|
||||
if !storagesAreEqual {return false}
|
||||
|
@ -3445,6 +3501,83 @@ extension SignalServiceProtos_DataMessage.Contact.Avatar: SwiftProtobuf.Message,
|
|||
}
|
||||
}
|
||||
|
||||
extension SignalServiceProtos_DataMessage.Preview: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
|
||||
static let protoMessageName: String = SignalServiceProtos_DataMessage.protoMessageName + ".Preview"
|
||||
static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
|
||||
1: .same(proto: "url"),
|
||||
2: .same(proto: "title"),
|
||||
3: .same(proto: "image"),
|
||||
]
|
||||
|
||||
fileprivate class _StorageClass {
|
||||
var _url: String? = nil
|
||||
var _title: String? = nil
|
||||
var _image: SignalServiceProtos_AttachmentPointer? = nil
|
||||
|
||||
static let defaultInstance = _StorageClass()
|
||||
|
||||
private init() {}
|
||||
|
||||
init(copying source: _StorageClass) {
|
||||
_url = source._url
|
||||
_title = source._title
|
||||
_image = source._image
|
||||
}
|
||||
}
|
||||
|
||||
fileprivate mutating func _uniqueStorage() -> _StorageClass {
|
||||
if !isKnownUniquelyReferenced(&_storage) {
|
||||
_storage = _StorageClass(copying: _storage)
|
||||
}
|
||||
return _storage
|
||||
}
|
||||
|
||||
mutating func decodeMessage<D: SwiftProtobuf.Decoder>(decoder: inout D) throws {
|
||||
_ = _uniqueStorage()
|
||||
try withExtendedLifetime(_storage) { (_storage: _StorageClass) in
|
||||
while let fieldNumber = try decoder.nextFieldNumber() {
|
||||
switch fieldNumber {
|
||||
case 1: try decoder.decodeSingularStringField(value: &_storage._url)
|
||||
case 2: try decoder.decodeSingularStringField(value: &_storage._title)
|
||||
case 3: try decoder.decodeSingularMessageField(value: &_storage._image)
|
||||
default: break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func traverse<V: SwiftProtobuf.Visitor>(visitor: inout V) throws {
|
||||
try withExtendedLifetime(_storage) { (_storage: _StorageClass) in
|
||||
if let v = _storage._url {
|
||||
try visitor.visitSingularStringField(value: v, fieldNumber: 1)
|
||||
}
|
||||
if let v = _storage._title {
|
||||
try visitor.visitSingularStringField(value: v, fieldNumber: 2)
|
||||
}
|
||||
if let v = _storage._image {
|
||||
try visitor.visitSingularMessageField(value: v, fieldNumber: 3)
|
||||
}
|
||||
}
|
||||
try unknownFields.traverse(visitor: &visitor)
|
||||
}
|
||||
|
||||
static func ==(lhs: SignalServiceProtos_DataMessage.Preview, rhs: SignalServiceProtos_DataMessage.Preview) -> Bool {
|
||||
if lhs._storage !== rhs._storage {
|
||||
let storagesAreEqual: Bool = withExtendedLifetime((lhs._storage, rhs._storage)) { (_args: (_StorageClass, _StorageClass)) in
|
||||
let _storage = _args.0
|
||||
let rhs_storage = _args.1
|
||||
if _storage._url != rhs_storage._url {return false}
|
||||
if _storage._title != rhs_storage._title {return false}
|
||||
if _storage._image != rhs_storage._image {return false}
|
||||
return true
|
||||
}
|
||||
if !storagesAreEqual {return false}
|
||||
}
|
||||
if lhs.unknownFields != rhs.unknownFields {return false}
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
extension SignalServiceProtos_NullMessage: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
|
||||
static let protoMessageName: String = _protobuf_package + ".NullMessage"
|
||||
static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
|
||||
|
|
Loading…
Reference in New Issue