mirror of https://github.com/oxen-io/session-ios
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
23 lines
948 B
Swift
23 lines
948 B
Swift
|
|
extension OWSLinkPreview {
|
|
|
|
public static func from(_ linkPreview: VisibleMessage.LinkPreview?) -> OWSLinkPreview? {
|
|
guard let linkPreview = linkPreview else { return nil }
|
|
return OWSLinkPreview(urlString: linkPreview.url!, title: linkPreview.title, imageAttachmentId: linkPreview.attachmentID)
|
|
}
|
|
}
|
|
|
|
extension VisibleMessage.LinkPreview {
|
|
|
|
@objc(from:using:)
|
|
public static func from(_ linkPreview: OWSLinkPreviewDraft?, using transaction: YapDatabaseReadWriteTransaction) -> VisibleMessage.LinkPreview? {
|
|
guard let linkPreview = linkPreview else { return nil }
|
|
do {
|
|
let linkPreview = try OWSLinkPreview.buildValidatedLinkPreview(fromInfo: linkPreview, transaction: transaction)
|
|
return VisibleMessage.LinkPreview(title: linkPreview.title, url: linkPreview.urlString!, attachmentID: linkPreview.imageAttachmentId)
|
|
} catch {
|
|
return nil
|
|
}
|
|
}
|
|
}
|