Don’t use SDSRecordType for TSThread
This commit is contained in:
parent
8663b50018
commit
aa7bced824
@ -53,10 +53,8 @@
|
||||
"SignalRecipient": 31,
|
||||
"StickerPack": 14,
|
||||
"TSCall": 20,
|
||||
"TSContactThread": 27,
|
||||
"TSErrorMessage": 9,
|
||||
"TSGroupMember": 69,
|
||||
"TSGroupThread": 26,
|
||||
"TSIncomingMessage": 19,
|
||||
"TSInfoMessage": 10,
|
||||
"TSInteraction": 16,
|
||||
@ -68,9 +66,7 @@
|
||||
"TSOutgoingMessage": 21,
|
||||
"TSPaymentModel": 67,
|
||||
"TSPaymentRequestModel": 66,
|
||||
"TSPrivateStoryThread": 72,
|
||||
"TSRecipientReadReceipt": 12,
|
||||
"TSThread": 2,
|
||||
"TSUnreadIndicatorInteraction": 4,
|
||||
"TestModel": 59
|
||||
}
|
||||
@ -19,19 +19,27 @@ public enum TSThreadStoryViewMode: UInt {
|
||||
case disabled = 3
|
||||
}
|
||||
|
||||
public enum TSThreadType: UInt {
|
||||
case thread = 2
|
||||
case contactThread = 27
|
||||
case groupThread = 26
|
||||
case privateStoryThread = 72
|
||||
case releaseNotesThread = 80
|
||||
}
|
||||
|
||||
@objc
|
||||
open class TSThread: NSObject, SDSCodableModel, InheritableRecord {
|
||||
public static let databaseTableName: String = "model_TSThread"
|
||||
public class var recordType: SDSRecordType { .thread }
|
||||
public class var recordType: TSThreadType { .thread }
|
||||
|
||||
static func concreteType(forRecordType recordType: UInt) -> (any InheritableRecord.Type)? {
|
||||
switch recordType {
|
||||
case SDSRecordType.thread.rawValue: TSThread.self
|
||||
case SDSRecordType.contactThread.rawValue: TSContactThread.self
|
||||
case SDSRecordType.groupThread.rawValue: TSGroupThread.self
|
||||
case SDSRecordType.privateStoryThread.rawValue: TSPrivateStoryThread.self
|
||||
case SDSRecordType.releaseNotesThread.rawValue: TSReleaseNotesThread.self
|
||||
default: nil
|
||||
switch TSThreadType(rawValue: recordType) {
|
||||
case .thread: TSThread.self
|
||||
case .contactThread: TSContactThread.self
|
||||
case .groupThread: TSGroupThread.self
|
||||
case .privateStoryThread: TSPrivateStoryThread.self
|
||||
case .releaseNotesThread: TSReleaseNotesThread.self
|
||||
case nil: nil
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -541,7 +541,7 @@ extension TSGroupModel {
|
||||
TSThread.anyEnumerate(
|
||||
transaction: transaction,
|
||||
sql: "SELECT * FROM \(TSThread.databaseTableName) WHERE \(threadColumn: .recordType) = ?",
|
||||
arguments: [SDSRecordType.groupThread.rawValue],
|
||||
arguments: [TSThreadType.groupThread.rawValue],
|
||||
block: { thread, stop in
|
||||
// [SDS] TODO: Fetch TSGroupThreads directly.
|
||||
guard let avatarHash = (thread as? TSGroupThread)?.groupModel.avatarHash else {
|
||||
|
||||
@ -5277,7 +5277,7 @@ public class GRDBSchemaMigrator {
|
||||
sql: """
|
||||
SELECT *
|
||||
FROM \(TSThread.databaseTableName)
|
||||
WHERE \(threadColumn: .recordType) = \(SDSRecordType.groupThread.rawValue)
|
||||
WHERE \(threadColumn: .recordType) = \(TSThreadType.groupThread.rawValue)
|
||||
""",
|
||||
arguments: [],
|
||||
) { thread, _ in
|
||||
@ -5369,7 +5369,7 @@ public class GRDBSchemaMigrator {
|
||||
migrator.registerMigration(.dataMigration_reindexGroupMembershipAndMigrateLegacyAvatarDataFixed) { transaction in
|
||||
TSThread.anyEnumerate(
|
||||
transaction: transaction,
|
||||
sql: "SELECT * FROM \(TSThread.databaseTableName) WHERE \(threadColumn: .recordType) = \(SDSRecordType.groupThread.rawValue)",
|
||||
sql: "SELECT * FROM \(TSThread.databaseTableName) WHERE \(threadColumn: .recordType) = \(TSThreadType.groupThread.rawValue)",
|
||||
arguments: [],
|
||||
) { thread, _ in
|
||||
// [SDS] TODO: Fetch TSGroupThreads directly.
|
||||
|
||||
@ -61,7 +61,7 @@ public class ThreadFinder {
|
||||
let sql = """
|
||||
SELECT *
|
||||
FROM \(TSThread.databaseTableName)
|
||||
WHERE \(threadColumn: .recordType) = \(SDSRecordType.privateStoryThread.rawValue)
|
||||
WHERE \(threadColumn: .recordType) = \(TSThreadType.privateStoryThread.rawValue)
|
||||
"""
|
||||
|
||||
var cursor = FailIfThrowsRecordCursor {
|
||||
@ -85,7 +85,7 @@ public class ThreadFinder {
|
||||
let sql = """
|
||||
SELECT *
|
||||
FROM \(TSThread.databaseTableName)
|
||||
WHERE \(threadColumn: .recordType) = \(SDSRecordType.groupThread.rawValue)
|
||||
WHERE \(threadColumn: .recordType) = \(TSThreadType.groupThread.rawValue)
|
||||
ORDER BY \(threadColumn: .lastInteractionRowId) DESC
|
||||
"""
|
||||
|
||||
@ -117,7 +117,7 @@ public class ThreadFinder {
|
||||
return try TSThread.fetchCursor(
|
||||
tx.database,
|
||||
sql: sql,
|
||||
arguments: [SDSRecordType.privateStoryThread.rawValue],
|
||||
arguments: [TSThreadType.privateStoryThread.rawValue],
|
||||
)
|
||||
}
|
||||
|
||||
@ -301,7 +301,7 @@ public class ThreadFinder {
|
||||
LIMIT 1
|
||||
)
|
||||
"""
|
||||
let arguments: StatementArguments = [SDSRecordType.groupThread.rawValue]
|
||||
let arguments: StatementArguments = [TSThreadType.groupThread.rawValue]
|
||||
return failIfThrows {
|
||||
return try Bool.fetchOne(
|
||||
transaction.database,
|
||||
@ -353,7 +353,7 @@ public class ThreadFinder {
|
||||
AND \(threadColumn: .storyViewMode) != \(TSThreadStoryViewMode.default.rawValue)
|
||||
OR (
|
||||
\(threadColumn: .storyViewMode) = \(TSThreadStoryViewMode.default.rawValue)
|
||||
AND \(threadColumn: .recordType) = \(SDSRecordType.groupThread.rawValue)
|
||||
AND \(threadColumn: .recordType) = \(TSThreadType.groupThread.rawValue)
|
||||
AND \(threadColumn: .uniqueId) IN (\(allowedDefaultThreadIds.map { "\"\($0)\"" }.joined(separator: ", ")))
|
||||
)
|
||||
ORDER BY \(threadColumn: .lastSentStoryTimestamp) DESC
|
||||
|
||||
@ -12,7 +12,6 @@ import GRDB
|
||||
@objc
|
||||
public enum SDSRecordType: UInt, CaseIterable {
|
||||
case invalidIdentityKeyReceivingErrorMessage = 1
|
||||
case thread = 2
|
||||
case unreadIndicatorInteraction = 4
|
||||
case unknownContactBlockOfferMessage = 5
|
||||
case addToProfileWhitelistOfferMessage = 7
|
||||
@ -32,8 +31,6 @@ public enum SDSRecordType: UInt, CaseIterable {
|
||||
case invalidIdentityKeySendingErrorMessage = 23
|
||||
case installedSticker = 24
|
||||
case addToContactsOfferMessage = 25
|
||||
case groupThread = 26
|
||||
case contactThread = 27
|
||||
case disappearingConfigurationUpdateInfoMessage = 28
|
||||
case signalAccount = 30
|
||||
case signalRecipient = 31
|
||||
@ -76,7 +73,6 @@ public enum SDSRecordType: UInt, CaseIterable {
|
||||
case groupMember = 69
|
||||
case recoverableDecryptionPlaceholder = 70
|
||||
case receiptCredentialRedemptionJobRecord = 71
|
||||
case privateStoryThread = 72
|
||||
case sendGiftBadgeJobRecord = 73
|
||||
case localUserLeaveGroupJobRecord = 74
|
||||
case incomingPaymentMessage = 75
|
||||
@ -84,5 +80,4 @@ public enum SDSRecordType: UInt, CaseIterable {
|
||||
case paymentActivationRequestFinishedMessage = 77
|
||||
case incomingArchivedPaymentMessage = 78
|
||||
case outgoingArchivedPaymentMessage = 79
|
||||
case releaseNotesThread = 80
|
||||
}
|
||||
|
||||
@ -7,7 +7,7 @@ public import GRDB
|
||||
import LibSignalClient
|
||||
|
||||
open class TSContactThread: TSThread {
|
||||
override public class var recordType: SDSRecordType { .contactThread }
|
||||
override public class var recordType: TSThreadType { .contactThread }
|
||||
|
||||
/// Represents the uppercase ServiceId string for this contact.
|
||||
/// - Note
|
||||
|
||||
@ -13,7 +13,7 @@ extension Notification.Name {
|
||||
public let TSGroupThread_NotificationKey_UniqueId = "TSGroupThread_NotificationKey_UniqueId"
|
||||
|
||||
open class TSGroupThread: TSThread {
|
||||
override public class var recordType: SDSRecordType { .groupThread }
|
||||
override public class var recordType: TSThreadType { .groupThread }
|
||||
|
||||
public private(set) var groupModel: TSGroupModel
|
||||
|
||||
|
||||
@ -8,7 +8,7 @@ public import GRDB
|
||||
|
||||
/// Represents a story distribution list.
|
||||
public final class TSPrivateStoryThread: TSThread {
|
||||
override public class var recordType: SDSRecordType { .privateStoryThread }
|
||||
override public class var recordType: TSThreadType { .privateStoryThread }
|
||||
|
||||
public private(set) var allowsReplies: Bool
|
||||
public private(set) var _name: String
|
||||
|
||||
@ -7,7 +7,7 @@ import Foundation
|
||||
|
||||
/// Represents the Release Notes thread.
|
||||
public final class TSReleaseNotesThread: TSThread {
|
||||
override public class var recordType: SDSRecordType { .releaseNotesThread }
|
||||
override public class var recordType: TSThreadType { .releaseNotesThread }
|
||||
|
||||
@objc
|
||||
public class var releaseNotesUniqueId: String {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user