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

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

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

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

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

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

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

Loading…
Cancel
Save