mirror of
https://github.com/lux-tel/session-ios.git
synced 2026-10-30 20:38:32 +00:00
• 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
78 lines
2.1 KiB
Swift
78 lines
2.1 KiB
Swift
// Copyright © 2022 Rangeproof Pty Ltd. All rights reserved.
|
|
|
|
import Foundation
|
|
import GRDB
|
|
import SessionUtilitiesKit
|
|
|
|
public struct Quote: Codable, Equatable, Hashable, FetchableRecord, PersistableRecord, TableRecord, ColumnExpressible {
|
|
public static var databaseTableName: String { "quote" }
|
|
|
|
public typealias Columns = CodingKeys
|
|
public enum CodingKeys: String, CodingKey, ColumnExpression {
|
|
case interactionId
|
|
case authorId
|
|
case timestampMs
|
|
}
|
|
|
|
/// The id for the interaction this Quote belongs to
|
|
public let interactionId: Int64
|
|
|
|
/// The id for the author this Quote belongs to
|
|
public let authorId: String
|
|
|
|
/// The timestamp in milliseconds since epoch when the quoted interaction was sent
|
|
public let timestampMs: Int64
|
|
|
|
// MARK: - Interaction
|
|
|
|
public init(
|
|
interactionId: Int64,
|
|
authorId: String,
|
|
timestampMs: Int64
|
|
) {
|
|
self.interactionId = interactionId
|
|
self.authorId = authorId
|
|
self.timestampMs = timestampMs
|
|
}
|
|
}
|
|
|
|
// MARK: - Mutation
|
|
|
|
public extension Quote {
|
|
func with(
|
|
interactionId: Int64? = nil,
|
|
authorId: String? = nil,
|
|
timestampMs: Int64? = nil
|
|
) -> Quote {
|
|
return Quote(
|
|
interactionId: interactionId ?? self.interactionId,
|
|
authorId: authorId ?? self.authorId,
|
|
timestampMs: timestampMs ?? self.timestampMs
|
|
)
|
|
}
|
|
|
|
func withOriginalMessageDeleted() -> Quote {
|
|
return Quote(
|
|
interactionId: self.interactionId,
|
|
authorId: self.authorId,
|
|
timestampMs: self.timestampMs
|
|
)
|
|
}
|
|
}
|
|
|
|
// MARK: - Protobuf
|
|
|
|
public extension Quote {
|
|
init?(proto: SNProtoDataMessage, interactionId: Int64, thread: SessionThread) throws {
|
|
guard
|
|
let quoteProto = proto.quote,
|
|
quoteProto.id != 0,
|
|
!quoteProto.author.isEmpty
|
|
else { return nil }
|
|
|
|
self.interactionId = interactionId
|
|
self.timestampMs = Int64(quoteProto.id)
|
|
self.authorId = quoteProto.author
|
|
}
|
|
}
|