pull/308/head
nielsandriesse 5 years ago
parent 18755e8e64
commit a782f36aa4

@ -1,5 +1,5 @@
import SessionUtilities
import SessionProtocolKit
import SessionUtilities
@objc(SNClosedGroupUpdate)
public final class ClosedGroupUpdate : ControlMessage {

@ -1,5 +1,5 @@
import SessionUtilities
import SessionProtocolKit
import SessionUtilities
@objc(SNSessionRequest)
public final class SessionRequest : ControlMessage {

@ -7,7 +7,7 @@ public extension VisibleMessage {
public var title: String?
public var url: String?
internal init(title: String, url: String) {
internal init(title: String?, url: String) {
self.title = title
self.url = url
}
@ -23,18 +23,18 @@ public extension VisibleMessage {
}
public static func fromProto(_ proto: SNProtoDataMessagePreview) -> LinkPreview? {
guard let title = proto.title else { return nil }
let title = proto.title
let url = proto.url
return LinkPreview(title: title, url: url)
}
public func toProto() -> SNProtoDataMessagePreview? {
guard let title = title, let url = url else {
guard let url = url else {
SNLog("Couldn't construct link preview proto from: \(self).")
return nil
}
let linkPreviewProto = SNProtoDataMessagePreview.builder(url: url)
linkPreviewProto.setTitle(title)
if let title = title { linkPreviewProto.setTitle(title) }
do {
return try linkPreviewProto.build()
} catch {

@ -37,15 +37,21 @@ public extension VisibleMessage {
}
}
public func toProto() -> SNProtoDataMessageLokiProfile? {
public func toProto() -> SNProtoDataMessage? {
guard let displayName = displayName else {
SNLog("Couldn't construct profile proto from: \(self).")
return nil
}
let dataMessageProto = SNProtoDataMessage.builder()
let profileProto = SNProtoDataMessageLokiProfile.builder()
profileProto.setDisplayName(displayName)
if let profileKey = profileKey, let profilePictureURL = profilePictureURL {
dataMessageProto.setProfileKey(profileKey)
profileProto.setProfilePicture(profilePictureURL)
}
do {
return try profileProto.build()
dataMessageProto.setProfile(try profileProto.build())
return try dataMessageProto.build()
} catch {
SNLog("Couldn't construct profile proto from: \(self).")
return nil

@ -34,12 +34,12 @@ public extension VisibleMessage {
}
public func toProto() -> SNProtoDataMessageQuote? {
guard let timestamp = timestamp, let publicKey = publicKey else {
guard let timestamp = timestamp, let publicKey = publicKey, let text = text else {
SNLog("Couldn't construct quote proto from: \(self).")
return nil
}
let quoteProto = SNProtoDataMessageQuote.builder(id: timestamp, author: publicKey)
if let text = text { quoteProto.setText(text) }
quoteProto.setText(text)
do {
return try quoteProto.build()
} catch {

@ -1,5 +1,5 @@
import SessionUtilities
import SessionSnodeKit
import SessionUtilities
enum ProofOfWork {

Loading…
Cancel
Save