Files
Morgan Pretty be6f840f0d Fixed a number of issues found during QA testing
• Added a dev action to be able to share a file by entering it's download url
• Added a minor recovery mechanism for lost/missing already-download files
• Dropped unused columns and a foreign key constraint from the Quote table
• Updated the MessageViewModel to no longer directly query Quote data (the associated MessageViewModel.QuotedInfo retrieves it)
• Fixed an issue where the current users profile may not update in all places
• Fixed an issue where sharing files was incorrectly trying to share them as URLs (most obvious when trying to share the log file)
• Fixed an issue where link preview images weren't being uploaded
• Fixed a buggy LinkPreviewView loading state
2025-10-20 17:00:36 +11:00

67 lines
1.9 KiB
Swift

// Copyright © 2022 Rangeproof Pty Ltd. All rights reserved.
import Foundation
import SessionUtilitiesKit
public extension VisibleMessage {
struct VMQuote: Codable {
public let timestamp: UInt64?
public let authorId: String?
public func isValid(isSending: Bool) -> Bool { timestamp != nil && authorId != nil }
// MARK: - Initialization
internal init(timestamp: UInt64, authorId: String) {
self.timestamp = timestamp
self.authorId = authorId
}
// MARK: - Proto Conversion
public static func fromProto(_ proto: SNProtoDataMessageQuote) -> VMQuote? {
return VMQuote(
timestamp: proto.id,
authorId: proto.author
)
}
public func toProto() -> SNProtoDataMessageQuote? {
guard let timestamp = timestamp, let authorId = authorId else {
Log.warn(.messageSender, "Couldn't construct quote proto from: \(self).")
return nil
}
let quoteProto = SNProtoDataMessageQuote.builder(id: timestamp, author: authorId)
do {
return try quoteProto.build()
} catch {
Log.warn(.messageSender, "Couldn't construct quote proto from: \(self).")
return nil
}
}
// MARK: - Description
public var description: String {
"""
Quote(
timestamp: \(timestamp?.description ?? "null"),
authorId: \(authorId ?? "null")
)
"""
}
}
}
// MARK: - Database Type Conversion
public extension VisibleMessage.VMQuote {
static func from(quote: Quote) -> VisibleMessage.VMQuote {
return VisibleMessage.VMQuote(
timestamp: UInt64(quote.timestampMs),
authorId: quote.authorId
)
}
}