Add exclusiveProcessIdentifier to SSKJobRecord
This commit is contained in:
parent
33d3066806
commit
fee1bbddad
@ -12,7 +12,8 @@
|
||||
"TSAttachmentStream.isAnimatedCached": "Bool",
|
||||
"OWSBackupFragment.uncompressedDataLength": "UInt64",
|
||||
"TestModel.nsNumberValueUsingInt64": "Int64",
|
||||
"TestModel.nsNumberValueUsingUInt64": "UInt64"
|
||||
"TestModel.nsNumberValueUsingUInt64": "UInt64",
|
||||
"SSKJobRecord.exclusiveProcessIdentifier": "Int32"
|
||||
},
|
||||
"properties_to_ignore": [
|
||||
"TSYapDatabaseObject.grdbId",
|
||||
@ -73,7 +74,8 @@
|
||||
"OWSOutgoingResendRequest",
|
||||
"OWSReceiptsForSenderMessage",
|
||||
"OWSUnknownDBObject",
|
||||
"TSOutgoingDeleteMessage"
|
||||
"TSOutgoingDeleteMessage",
|
||||
"OWSOutgoingResendResponse"
|
||||
],
|
||||
"manually_typed_fields": {
|
||||
"TSThread.conversationColorName": {
|
||||
|
||||
@ -125,6 +125,7 @@
|
||||
"JobRecordRecord.attachmentIdMap": 4,
|
||||
"JobRecordRecord.contactThreadId": 5,
|
||||
"JobRecordRecord.envelopeData": 6,
|
||||
"JobRecordRecord.exclusiveProcessIdentifier": 14,
|
||||
"JobRecordRecord.failureCount": 1,
|
||||
"JobRecordRecord.invisibleMessage": 7,
|
||||
"JobRecordRecord.isMediaMessage": 12,
|
||||
|
||||
@ -241,6 +241,7 @@ CREATE
|
||||
,"attachmentId" TEXT
|
||||
,"isMediaMessage" BOOLEAN
|
||||
,"serverDeliveryTimestamp" INTEGER
|
||||
,"exclusiveProcessIdentifier" INTEGER
|
||||
)
|
||||
;
|
||||
|
||||
|
||||
@ -74,7 +74,8 @@ class SSKMessageDecryptJobRecordSerializer: SDSSerializer {
|
||||
let attachmentId: String? = nil
|
||||
let isMediaMessage: Bool? = nil
|
||||
let serverDeliveryTimestamp: UInt64? = model.serverDeliveryTimestamp
|
||||
let exclusiveProcessIdentifier: Int32? = archiveOptionalNSNumber(model.exclusiveProcessIdentifier, conversion: { $0.int32Value })
|
||||
|
||||
return JobRecordRecord(delegate: model, id: id, recordType: recordType, uniqueId: uniqueId, failureCount: failureCount, label: label, status: status, attachmentIdMap: attachmentIdMap, contactThreadId: contactThreadId, envelopeData: envelopeData, invisibleMessage: invisibleMessage, messageId: messageId, removeMessageAfterSending: removeMessageAfterSending, threadId: threadId, attachmentId: attachmentId, isMediaMessage: isMediaMessage, serverDeliveryTimestamp: serverDeliveryTimestamp)
|
||||
return JobRecordRecord(delegate: model, id: id, recordType: recordType, uniqueId: uniqueId, failureCount: failureCount, label: label, status: status, attachmentIdMap: attachmentIdMap, contactThreadId: contactThreadId, envelopeData: envelopeData, invisibleMessage: invisibleMessage, messageId: messageId, removeMessageAfterSending: removeMessageAfterSending, threadId: threadId, attachmentId: attachmentId, isMediaMessage: isMediaMessage, serverDeliveryTimestamp: serverDeliveryTimestamp, exclusiveProcessIdentifier: exclusiveProcessIdentifier)
|
||||
}
|
||||
}
|
||||
|
||||
@ -34,13 +34,14 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
- (instancetype)initWithGrdbId:(int64_t)grdbId
|
||||
uniqueId:(NSString *)uniqueId
|
||||
exclusiveProcessIdentifier:(nullable NSNumber *)exclusiveProcessIdentifier
|
||||
failureCount:(NSUInteger)failureCount
|
||||
label:(NSString *)label
|
||||
sortId:(unsigned long long)sortId
|
||||
status:(SSKJobRecordStatus)status
|
||||
envelopeData:(nullable NSData *)envelopeData
|
||||
serverDeliveryTimestamp:(uint64_t)serverDeliveryTimestamp
|
||||
NS_DESIGNATED_INITIALIZER NS_SWIFT_NAME(init(grdbId:uniqueId:failureCount:label:sortId:status:envelopeData:serverDeliveryTimestamp:));
|
||||
NS_DESIGNATED_INITIALIZER NS_SWIFT_NAME(init(grdbId:uniqueId:exclusiveProcessIdentifier:failureCount:label:sortId:status:envelopeData:serverDeliveryTimestamp:));
|
||||
|
||||
// clang-format on
|
||||
|
||||
|
||||
@ -36,6 +36,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
- (instancetype)initWithGrdbId:(int64_t)grdbId
|
||||
uniqueId:(NSString *)uniqueId
|
||||
exclusiveProcessIdentifier:(nullable NSNumber *)exclusiveProcessIdentifier
|
||||
failureCount:(NSUInteger)failureCount
|
||||
label:(NSString *)label
|
||||
sortId:(unsigned long long)sortId
|
||||
@ -45,6 +46,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
{
|
||||
self = [super initWithGrdbId:grdbId
|
||||
uniqueId:uniqueId
|
||||
exclusiveProcessIdentifier:exclusiveProcessIdentifier
|
||||
failureCount:failureCount
|
||||
label:label
|
||||
sortId:sortId
|
||||
|
||||
@ -109,6 +109,7 @@ public class GRDBSchemaMigrator: NSObject {
|
||||
case addMessageSendLog
|
||||
case updatePendingReadReceipts
|
||||
case addSendCompletionToMessageSendLog
|
||||
case addExclusiveProcessIdentifierToJobRecord
|
||||
|
||||
// NOTE: Every time we add a migration id, consider
|
||||
// incrementing grdbSchemaVersionLatest.
|
||||
@ -1295,6 +1296,16 @@ public class GRDBSchemaMigrator: NSObject {
|
||||
}
|
||||
}
|
||||
|
||||
migrator.registerMigration(MigrationId.addExclusiveProcessIdentifierToJobRecord.rawValue) { db in
|
||||
do {
|
||||
try db.alter(table: "model_SSKJobRecord") { (table: TableAlteration) -> Void in
|
||||
table.add(column: "exclusiveProcessIdentifier", .integer)
|
||||
}
|
||||
} catch {
|
||||
owsFail("Error: \(error)")
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Schema Migration Insertion Point
|
||||
}
|
||||
|
||||
|
||||
@ -74,7 +74,8 @@ class OWSBroadcastMediaMessageJobRecordSerializer: SDSSerializer {
|
||||
let attachmentId: String? = nil
|
||||
let isMediaMessage: Bool? = nil
|
||||
let serverDeliveryTimestamp: UInt64? = nil
|
||||
let exclusiveProcessIdentifier: Int32? = archiveOptionalNSNumber(model.exclusiveProcessIdentifier, conversion: { $0.int32Value })
|
||||
|
||||
return JobRecordRecord(delegate: model, id: id, recordType: recordType, uniqueId: uniqueId, failureCount: failureCount, label: label, status: status, attachmentIdMap: attachmentIdMap, contactThreadId: contactThreadId, envelopeData: envelopeData, invisibleMessage: invisibleMessage, messageId: messageId, removeMessageAfterSending: removeMessageAfterSending, threadId: threadId, attachmentId: attachmentId, isMediaMessage: isMediaMessage, serverDeliveryTimestamp: serverDeliveryTimestamp)
|
||||
return JobRecordRecord(delegate: model, id: id, recordType: recordType, uniqueId: uniqueId, failureCount: failureCount, label: label, status: status, attachmentIdMap: attachmentIdMap, contactThreadId: contactThreadId, envelopeData: envelopeData, invisibleMessage: invisibleMessage, messageId: messageId, removeMessageAfterSending: removeMessageAfterSending, threadId: threadId, attachmentId: attachmentId, isMediaMessage: isMediaMessage, serverDeliveryTimestamp: serverDeliveryTimestamp, exclusiveProcessIdentifier: exclusiveProcessIdentifier)
|
||||
}
|
||||
}
|
||||
|
||||
@ -49,12 +49,13 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
- (instancetype)initWithGrdbId:(int64_t)grdbId
|
||||
uniqueId:(NSString *)uniqueId
|
||||
exclusiveProcessIdentifier:(nullable NSNumber *)exclusiveProcessIdentifier
|
||||
failureCount:(NSUInteger)failureCount
|
||||
label:(NSString *)label
|
||||
sortId:(unsigned long long)sortId
|
||||
status:(SSKJobRecordStatus)status
|
||||
attachmentIdMap:(NSDictionary<NSString *,NSArray<NSString *> *> *)attachmentIdMap
|
||||
NS_DESIGNATED_INITIALIZER NS_SWIFT_NAME(init(grdbId:uniqueId:failureCount:label:sortId:status:attachmentIdMap:));
|
||||
NS_DESIGNATED_INITIALIZER NS_SWIFT_NAME(init(grdbId:uniqueId:exclusiveProcessIdentifier:failureCount:label:sortId:status:attachmentIdMap:));
|
||||
|
||||
// clang-format on
|
||||
|
||||
|
||||
@ -39,6 +39,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
- (instancetype)initWithGrdbId:(int64_t)grdbId
|
||||
uniqueId:(NSString *)uniqueId
|
||||
exclusiveProcessIdentifier:(nullable NSNumber *)exclusiveProcessIdentifier
|
||||
failureCount:(NSUInteger)failureCount
|
||||
label:(NSString *)label
|
||||
sortId:(unsigned long long)sortId
|
||||
@ -47,6 +48,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
{
|
||||
self = [super initWithGrdbId:grdbId
|
||||
uniqueId:uniqueId
|
||||
exclusiveProcessIdentifier:exclusiveProcessIdentifier
|
||||
failureCount:failureCount
|
||||
label:label
|
||||
sortId:sortId
|
||||
|
||||
@ -74,7 +74,8 @@ class OWSIncomingContactSyncJobRecordSerializer: SDSSerializer {
|
||||
let attachmentId: String? = model.attachmentId
|
||||
let isMediaMessage: Bool? = nil
|
||||
let serverDeliveryTimestamp: UInt64? = nil
|
||||
let exclusiveProcessIdentifier: Int32? = archiveOptionalNSNumber(model.exclusiveProcessIdentifier, conversion: { $0.int32Value })
|
||||
|
||||
return JobRecordRecord(delegate: model, id: id, recordType: recordType, uniqueId: uniqueId, failureCount: failureCount, label: label, status: status, attachmentIdMap: attachmentIdMap, contactThreadId: contactThreadId, envelopeData: envelopeData, invisibleMessage: invisibleMessage, messageId: messageId, removeMessageAfterSending: removeMessageAfterSending, threadId: threadId, attachmentId: attachmentId, isMediaMessage: isMediaMessage, serverDeliveryTimestamp: serverDeliveryTimestamp)
|
||||
return JobRecordRecord(delegate: model, id: id, recordType: recordType, uniqueId: uniqueId, failureCount: failureCount, label: label, status: status, attachmentIdMap: attachmentIdMap, contactThreadId: contactThreadId, envelopeData: envelopeData, invisibleMessage: invisibleMessage, messageId: messageId, removeMessageAfterSending: removeMessageAfterSending, threadId: threadId, attachmentId: attachmentId, isMediaMessage: isMediaMessage, serverDeliveryTimestamp: serverDeliveryTimestamp, exclusiveProcessIdentifier: exclusiveProcessIdentifier)
|
||||
}
|
||||
}
|
||||
|
||||
@ -33,12 +33,13 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
- (instancetype)initWithGrdbId:(int64_t)grdbId
|
||||
uniqueId:(NSString *)uniqueId
|
||||
exclusiveProcessIdentifier:(nullable NSNumber *)exclusiveProcessIdentifier
|
||||
failureCount:(NSUInteger)failureCount
|
||||
label:(NSString *)label
|
||||
sortId:(unsigned long long)sortId
|
||||
status:(SSKJobRecordStatus)status
|
||||
attachmentId:(NSString *)attachmentId
|
||||
NS_DESIGNATED_INITIALIZER NS_SWIFT_NAME(init(grdbId:uniqueId:failureCount:label:sortId:status:attachmentId:));
|
||||
NS_DESIGNATED_INITIALIZER NS_SWIFT_NAME(init(grdbId:uniqueId:exclusiveProcessIdentifier:failureCount:label:sortId:status:attachmentId:));
|
||||
|
||||
// clang-format on
|
||||
|
||||
|
||||
@ -31,6 +31,7 @@
|
||||
|
||||
- (instancetype)initWithGrdbId:(int64_t)grdbId
|
||||
uniqueId:(NSString *)uniqueId
|
||||
exclusiveProcessIdentifier:(nullable NSNumber *)exclusiveProcessIdentifier
|
||||
failureCount:(NSUInteger)failureCount
|
||||
label:(NSString *)label
|
||||
sortId:(unsigned long long)sortId
|
||||
@ -39,6 +40,7 @@
|
||||
{
|
||||
self = [super initWithGrdbId:grdbId
|
||||
uniqueId:uniqueId
|
||||
exclusiveProcessIdentifier:exclusiveProcessIdentifier
|
||||
failureCount:failureCount
|
||||
label:label
|
||||
sortId:sortId
|
||||
|
||||
@ -74,7 +74,8 @@ class OWSIncomingGroupSyncJobRecordSerializer: SDSSerializer {
|
||||
let attachmentId: String? = model.attachmentId
|
||||
let isMediaMessage: Bool? = nil
|
||||
let serverDeliveryTimestamp: UInt64? = nil
|
||||
let exclusiveProcessIdentifier: Int32? = archiveOptionalNSNumber(model.exclusiveProcessIdentifier, conversion: { $0.int32Value })
|
||||
|
||||
return JobRecordRecord(delegate: model, id: id, recordType: recordType, uniqueId: uniqueId, failureCount: failureCount, label: label, status: status, attachmentIdMap: attachmentIdMap, contactThreadId: contactThreadId, envelopeData: envelopeData, invisibleMessage: invisibleMessage, messageId: messageId, removeMessageAfterSending: removeMessageAfterSending, threadId: threadId, attachmentId: attachmentId, isMediaMessage: isMediaMessage, serverDeliveryTimestamp: serverDeliveryTimestamp)
|
||||
return JobRecordRecord(delegate: model, id: id, recordType: recordType, uniqueId: uniqueId, failureCount: failureCount, label: label, status: status, attachmentIdMap: attachmentIdMap, contactThreadId: contactThreadId, envelopeData: envelopeData, invisibleMessage: invisibleMessage, messageId: messageId, removeMessageAfterSending: removeMessageAfterSending, threadId: threadId, attachmentId: attachmentId, isMediaMessage: isMediaMessage, serverDeliveryTimestamp: serverDeliveryTimestamp, exclusiveProcessIdentifier: exclusiveProcessIdentifier)
|
||||
}
|
||||
}
|
||||
|
||||
@ -33,12 +33,13 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
- (instancetype)initWithGrdbId:(int64_t)grdbId
|
||||
uniqueId:(NSString *)uniqueId
|
||||
exclusiveProcessIdentifier:(nullable NSNumber *)exclusiveProcessIdentifier
|
||||
failureCount:(NSUInteger)failureCount
|
||||
label:(NSString *)label
|
||||
sortId:(unsigned long long)sortId
|
||||
status:(SSKJobRecordStatus)status
|
||||
attachmentId:(NSString *)attachmentId
|
||||
NS_DESIGNATED_INITIALIZER NS_SWIFT_NAME(init(grdbId:uniqueId:failureCount:label:sortId:status:attachmentId:));
|
||||
NS_DESIGNATED_INITIALIZER NS_SWIFT_NAME(init(grdbId:uniqueId:exclusiveProcessIdentifier:failureCount:label:sortId:status:attachmentId:));
|
||||
|
||||
// clang-format on
|
||||
|
||||
|
||||
@ -31,6 +31,7 @@
|
||||
|
||||
- (instancetype)initWithGrdbId:(int64_t)grdbId
|
||||
uniqueId:(NSString *)uniqueId
|
||||
exclusiveProcessIdentifier:(nullable NSNumber *)exclusiveProcessIdentifier
|
||||
failureCount:(NSUInteger)failureCount
|
||||
label:(NSString *)label
|
||||
sortId:(unsigned long long)sortId
|
||||
@ -39,6 +40,7 @@
|
||||
{
|
||||
self = [super initWithGrdbId:grdbId
|
||||
uniqueId:uniqueId
|
||||
exclusiveProcessIdentifier:exclusiveProcessIdentifier
|
||||
failureCount:failureCount
|
||||
label:label
|
||||
sortId:sortId
|
||||
|
||||
@ -74,7 +74,8 @@ class OWSSessionResetJobRecordSerializer: SDSSerializer {
|
||||
let attachmentId: String? = nil
|
||||
let isMediaMessage: Bool? = nil
|
||||
let serverDeliveryTimestamp: UInt64? = nil
|
||||
let exclusiveProcessIdentifier: Int32? = archiveOptionalNSNumber(model.exclusiveProcessIdentifier, conversion: { $0.int32Value })
|
||||
|
||||
return JobRecordRecord(delegate: model, id: id, recordType: recordType, uniqueId: uniqueId, failureCount: failureCount, label: label, status: status, attachmentIdMap: attachmentIdMap, contactThreadId: contactThreadId, envelopeData: envelopeData, invisibleMessage: invisibleMessage, messageId: messageId, removeMessageAfterSending: removeMessageAfterSending, threadId: threadId, attachmentId: attachmentId, isMediaMessage: isMediaMessage, serverDeliveryTimestamp: serverDeliveryTimestamp)
|
||||
return JobRecordRecord(delegate: model, id: id, recordType: recordType, uniqueId: uniqueId, failureCount: failureCount, label: label, status: status, attachmentIdMap: attachmentIdMap, contactThreadId: contactThreadId, envelopeData: envelopeData, invisibleMessage: invisibleMessage, messageId: messageId, removeMessageAfterSending: removeMessageAfterSending, threadId: threadId, attachmentId: attachmentId, isMediaMessage: isMediaMessage, serverDeliveryTimestamp: serverDeliveryTimestamp, exclusiveProcessIdentifier: exclusiveProcessIdentifier)
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
//
|
||||
// Copyright (c) 2020 Open Whisper Systems. All rights reserved.
|
||||
// Copyright (c) 2021 Open Whisper Systems. All rights reserved.
|
||||
//
|
||||
|
||||
#import <SignalServiceKit/SSKJobRecord.h>
|
||||
@ -34,12 +34,13 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
- (instancetype)initWithGrdbId:(int64_t)grdbId
|
||||
uniqueId:(NSString *)uniqueId
|
||||
exclusiveProcessIdentifier:(nullable NSNumber *)exclusiveProcessIdentifier
|
||||
failureCount:(NSUInteger)failureCount
|
||||
label:(NSString *)label
|
||||
sortId:(unsigned long long)sortId
|
||||
status:(SSKJobRecordStatus)status
|
||||
contactThreadId:(NSString *)contactThreadId
|
||||
NS_DESIGNATED_INITIALIZER NS_SWIFT_NAME(init(grdbId:uniqueId:failureCount:label:sortId:status:contactThreadId:));
|
||||
NS_DESIGNATED_INITIALIZER NS_SWIFT_NAME(init(grdbId:uniqueId:exclusiveProcessIdentifier:failureCount:label:sortId:status:contactThreadId:));
|
||||
|
||||
// clang-format on
|
||||
|
||||
|
||||
@ -34,6 +34,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
- (instancetype)initWithGrdbId:(int64_t)grdbId
|
||||
uniqueId:(NSString *)uniqueId
|
||||
exclusiveProcessIdentifier:(nullable NSNumber *)exclusiveProcessIdentifier
|
||||
failureCount:(NSUInteger)failureCount
|
||||
label:(NSString *)label
|
||||
sortId:(unsigned long long)sortId
|
||||
@ -42,6 +43,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
{
|
||||
self = [super initWithGrdbId:grdbId
|
||||
uniqueId:uniqueId
|
||||
exclusiveProcessIdentifier:exclusiveProcessIdentifier
|
||||
failureCount:failureCount
|
||||
label:label
|
||||
sortId:sortId
|
||||
|
||||
@ -41,6 +41,7 @@ public struct JobRecordRecord: SDSRecord {
|
||||
public let attachmentId: String?
|
||||
public let isMediaMessage: Bool?
|
||||
public let serverDeliveryTimestamp: UInt64?
|
||||
public let exclusiveProcessIdentifier: Int32?
|
||||
|
||||
public enum CodingKeys: String, CodingKey, ColumnExpression, CaseIterable {
|
||||
case id
|
||||
@ -59,6 +60,7 @@ public struct JobRecordRecord: SDSRecord {
|
||||
case attachmentId
|
||||
case isMediaMessage
|
||||
case serverDeliveryTimestamp
|
||||
case exclusiveProcessIdentifier
|
||||
}
|
||||
|
||||
public static func columnName(_ column: JobRecordRecord.CodingKeys, fullyQualified: Bool = false) -> String {
|
||||
@ -98,6 +100,7 @@ public extension JobRecordRecord {
|
||||
attachmentId = row[13]
|
||||
isMediaMessage = row[14]
|
||||
serverDeliveryTimestamp = row[15]
|
||||
exclusiveProcessIdentifier = row[16]
|
||||
}
|
||||
}
|
||||
|
||||
@ -129,6 +132,7 @@ extension SSKJobRecord {
|
||||
case .broadcastMediaMessageJobRecord:
|
||||
|
||||
let uniqueId: String = record.uniqueId
|
||||
let exclusiveProcessIdentifier: NSNumber? = SDSDeserialization.optionalNumericAsNSNumber(record.exclusiveProcessIdentifier, name: "exclusiveProcessIdentifier", conversion: { NSNumber(value: $0) })
|
||||
let failureCount: UInt = record.failureCount
|
||||
let label: String = record.label
|
||||
let sortId: UInt64 = UInt64(recordId)
|
||||
@ -138,6 +142,7 @@ extension SSKJobRecord {
|
||||
|
||||
return OWSBroadcastMediaMessageJobRecord(grdbId: recordId,
|
||||
uniqueId: uniqueId,
|
||||
exclusiveProcessIdentifier: exclusiveProcessIdentifier,
|
||||
failureCount: failureCount,
|
||||
label: label,
|
||||
sortId: sortId,
|
||||
@ -147,6 +152,7 @@ extension SSKJobRecord {
|
||||
case .incomingContactSyncJobRecord:
|
||||
|
||||
let uniqueId: String = record.uniqueId
|
||||
let exclusiveProcessIdentifier: NSNumber? = SDSDeserialization.optionalNumericAsNSNumber(record.exclusiveProcessIdentifier, name: "exclusiveProcessIdentifier", conversion: { NSNumber(value: $0) })
|
||||
let failureCount: UInt = record.failureCount
|
||||
let label: String = record.label
|
||||
let sortId: UInt64 = UInt64(recordId)
|
||||
@ -155,6 +161,7 @@ extension SSKJobRecord {
|
||||
|
||||
return OWSIncomingContactSyncJobRecord(grdbId: recordId,
|
||||
uniqueId: uniqueId,
|
||||
exclusiveProcessIdentifier: exclusiveProcessIdentifier,
|
||||
failureCount: failureCount,
|
||||
label: label,
|
||||
sortId: sortId,
|
||||
@ -164,6 +171,7 @@ extension SSKJobRecord {
|
||||
case .incomingGroupSyncJobRecord:
|
||||
|
||||
let uniqueId: String = record.uniqueId
|
||||
let exclusiveProcessIdentifier: NSNumber? = SDSDeserialization.optionalNumericAsNSNumber(record.exclusiveProcessIdentifier, name: "exclusiveProcessIdentifier", conversion: { NSNumber(value: $0) })
|
||||
let failureCount: UInt = record.failureCount
|
||||
let label: String = record.label
|
||||
let sortId: UInt64 = UInt64(recordId)
|
||||
@ -172,6 +180,7 @@ extension SSKJobRecord {
|
||||
|
||||
return OWSIncomingGroupSyncJobRecord(grdbId: recordId,
|
||||
uniqueId: uniqueId,
|
||||
exclusiveProcessIdentifier: exclusiveProcessIdentifier,
|
||||
failureCount: failureCount,
|
||||
label: label,
|
||||
sortId: sortId,
|
||||
@ -181,6 +190,7 @@ extension SSKJobRecord {
|
||||
case .sessionResetJobRecord:
|
||||
|
||||
let uniqueId: String = record.uniqueId
|
||||
let exclusiveProcessIdentifier: NSNumber? = SDSDeserialization.optionalNumericAsNSNumber(record.exclusiveProcessIdentifier, name: "exclusiveProcessIdentifier", conversion: { NSNumber(value: $0) })
|
||||
let failureCount: UInt = record.failureCount
|
||||
let label: String = record.label
|
||||
let sortId: UInt64 = UInt64(recordId)
|
||||
@ -189,6 +199,7 @@ extension SSKJobRecord {
|
||||
|
||||
return OWSSessionResetJobRecord(grdbId: recordId,
|
||||
uniqueId: uniqueId,
|
||||
exclusiveProcessIdentifier: exclusiveProcessIdentifier,
|
||||
failureCount: failureCount,
|
||||
label: label,
|
||||
sortId: sortId,
|
||||
@ -198,6 +209,7 @@ extension SSKJobRecord {
|
||||
case .jobRecord:
|
||||
|
||||
let uniqueId: String = record.uniqueId
|
||||
let exclusiveProcessIdentifier: NSNumber? = SDSDeserialization.optionalNumericAsNSNumber(record.exclusiveProcessIdentifier, name: "exclusiveProcessIdentifier", conversion: { NSNumber(value: $0) })
|
||||
let failureCount: UInt = record.failureCount
|
||||
let label: String = record.label
|
||||
let sortId: UInt64 = UInt64(recordId)
|
||||
@ -205,6 +217,7 @@ extension SSKJobRecord {
|
||||
|
||||
return SSKJobRecord(grdbId: recordId,
|
||||
uniqueId: uniqueId,
|
||||
exclusiveProcessIdentifier: exclusiveProcessIdentifier,
|
||||
failureCount: failureCount,
|
||||
label: label,
|
||||
sortId: sortId,
|
||||
@ -213,6 +226,7 @@ extension SSKJobRecord {
|
||||
case .messageDecryptJobRecord:
|
||||
|
||||
let uniqueId: String = record.uniqueId
|
||||
let exclusiveProcessIdentifier: NSNumber? = SDSDeserialization.optionalNumericAsNSNumber(record.exclusiveProcessIdentifier, name: "exclusiveProcessIdentifier", conversion: { NSNumber(value: $0) })
|
||||
let failureCount: UInt = record.failureCount
|
||||
let label: String = record.label
|
||||
let sortId: UInt64 = UInt64(recordId)
|
||||
@ -222,6 +236,7 @@ extension SSKJobRecord {
|
||||
|
||||
return SSKMessageDecryptJobRecord(grdbId: recordId,
|
||||
uniqueId: uniqueId,
|
||||
exclusiveProcessIdentifier: exclusiveProcessIdentifier,
|
||||
failureCount: failureCount,
|
||||
label: label,
|
||||
sortId: sortId,
|
||||
@ -232,6 +247,7 @@ extension SSKJobRecord {
|
||||
case .messageSenderJobRecord:
|
||||
|
||||
let uniqueId: String = record.uniqueId
|
||||
let exclusiveProcessIdentifier: NSNumber? = SDSDeserialization.optionalNumericAsNSNumber(record.exclusiveProcessIdentifier, name: "exclusiveProcessIdentifier", conversion: { NSNumber(value: $0) })
|
||||
let failureCount: UInt = record.failureCount
|
||||
let label: String = record.label
|
||||
let sortId: UInt64 = UInt64(recordId)
|
||||
@ -245,6 +261,7 @@ extension SSKJobRecord {
|
||||
|
||||
return SSKMessageSenderJobRecord(grdbId: recordId,
|
||||
uniqueId: uniqueId,
|
||||
exclusiveProcessIdentifier: exclusiveProcessIdentifier,
|
||||
failureCount: failureCount,
|
||||
label: label,
|
||||
sortId: sortId,
|
||||
@ -321,6 +338,7 @@ extension SSKJobRecord: DeepCopyable {
|
||||
if let modelToCopy = self as? SSKMessageSenderJobRecord {
|
||||
assert(type(of: modelToCopy) == SSKMessageSenderJobRecord.self)
|
||||
let uniqueId: String = modelToCopy.uniqueId
|
||||
let exclusiveProcessIdentifier: NSNumber? = modelToCopy.exclusiveProcessIdentifier
|
||||
let failureCount: UInt = modelToCopy.failureCount
|
||||
let label: String = modelToCopy.label
|
||||
let sortId: UInt64 = modelToCopy.sortId
|
||||
@ -345,6 +363,7 @@ extension SSKJobRecord: DeepCopyable {
|
||||
|
||||
return SSKMessageSenderJobRecord(grdbId: id,
|
||||
uniqueId: uniqueId,
|
||||
exclusiveProcessIdentifier: exclusiveProcessIdentifier,
|
||||
failureCount: failureCount,
|
||||
label: label,
|
||||
sortId: sortId,
|
||||
@ -359,6 +378,7 @@ extension SSKJobRecord: DeepCopyable {
|
||||
if let modelToCopy = self as? SSKMessageDecryptJobRecord {
|
||||
assert(type(of: modelToCopy) == SSKMessageDecryptJobRecord.self)
|
||||
let uniqueId: String = modelToCopy.uniqueId
|
||||
let exclusiveProcessIdentifier: NSNumber? = modelToCopy.exclusiveProcessIdentifier
|
||||
let failureCount: UInt = modelToCopy.failureCount
|
||||
let label: String = modelToCopy.label
|
||||
let sortId: UInt64 = modelToCopy.sortId
|
||||
@ -368,6 +388,7 @@ extension SSKJobRecord: DeepCopyable {
|
||||
|
||||
return SSKMessageDecryptJobRecord(grdbId: id,
|
||||
uniqueId: uniqueId,
|
||||
exclusiveProcessIdentifier: exclusiveProcessIdentifier,
|
||||
failureCount: failureCount,
|
||||
label: label,
|
||||
sortId: sortId,
|
||||
@ -379,6 +400,7 @@ extension SSKJobRecord: DeepCopyable {
|
||||
if let modelToCopy = self as? OWSSessionResetJobRecord {
|
||||
assert(type(of: modelToCopy) == OWSSessionResetJobRecord.self)
|
||||
let uniqueId: String = modelToCopy.uniqueId
|
||||
let exclusiveProcessIdentifier: NSNumber? = modelToCopy.exclusiveProcessIdentifier
|
||||
let failureCount: UInt = modelToCopy.failureCount
|
||||
let label: String = modelToCopy.label
|
||||
let sortId: UInt64 = modelToCopy.sortId
|
||||
@ -387,6 +409,7 @@ extension SSKJobRecord: DeepCopyable {
|
||||
|
||||
return OWSSessionResetJobRecord(grdbId: id,
|
||||
uniqueId: uniqueId,
|
||||
exclusiveProcessIdentifier: exclusiveProcessIdentifier,
|
||||
failureCount: failureCount,
|
||||
label: label,
|
||||
sortId: sortId,
|
||||
@ -397,6 +420,7 @@ extension SSKJobRecord: DeepCopyable {
|
||||
if let modelToCopy = self as? OWSIncomingGroupSyncJobRecord {
|
||||
assert(type(of: modelToCopy) == OWSIncomingGroupSyncJobRecord.self)
|
||||
let uniqueId: String = modelToCopy.uniqueId
|
||||
let exclusiveProcessIdentifier: NSNumber? = modelToCopy.exclusiveProcessIdentifier
|
||||
let failureCount: UInt = modelToCopy.failureCount
|
||||
let label: String = modelToCopy.label
|
||||
let sortId: UInt64 = modelToCopy.sortId
|
||||
@ -405,6 +429,7 @@ extension SSKJobRecord: DeepCopyable {
|
||||
|
||||
return OWSIncomingGroupSyncJobRecord(grdbId: id,
|
||||
uniqueId: uniqueId,
|
||||
exclusiveProcessIdentifier: exclusiveProcessIdentifier,
|
||||
failureCount: failureCount,
|
||||
label: label,
|
||||
sortId: sortId,
|
||||
@ -415,6 +440,7 @@ extension SSKJobRecord: DeepCopyable {
|
||||
if let modelToCopy = self as? OWSIncomingContactSyncJobRecord {
|
||||
assert(type(of: modelToCopy) == OWSIncomingContactSyncJobRecord.self)
|
||||
let uniqueId: String = modelToCopy.uniqueId
|
||||
let exclusiveProcessIdentifier: NSNumber? = modelToCopy.exclusiveProcessIdentifier
|
||||
let failureCount: UInt = modelToCopy.failureCount
|
||||
let label: String = modelToCopy.label
|
||||
let sortId: UInt64 = modelToCopy.sortId
|
||||
@ -423,6 +449,7 @@ extension SSKJobRecord: DeepCopyable {
|
||||
|
||||
return OWSIncomingContactSyncJobRecord(grdbId: id,
|
||||
uniqueId: uniqueId,
|
||||
exclusiveProcessIdentifier: exclusiveProcessIdentifier,
|
||||
failureCount: failureCount,
|
||||
label: label,
|
||||
sortId: sortId,
|
||||
@ -433,6 +460,7 @@ extension SSKJobRecord: DeepCopyable {
|
||||
if let modelToCopy = self as? OWSBroadcastMediaMessageJobRecord {
|
||||
assert(type(of: modelToCopy) == OWSBroadcastMediaMessageJobRecord.self)
|
||||
let uniqueId: String = modelToCopy.uniqueId
|
||||
let exclusiveProcessIdentifier: NSNumber? = modelToCopy.exclusiveProcessIdentifier
|
||||
let failureCount: UInt = modelToCopy.failureCount
|
||||
let label: String = modelToCopy.label
|
||||
let sortId: UInt64 = modelToCopy.sortId
|
||||
@ -443,6 +471,7 @@ extension SSKJobRecord: DeepCopyable {
|
||||
|
||||
return OWSBroadcastMediaMessageJobRecord(grdbId: id,
|
||||
uniqueId: uniqueId,
|
||||
exclusiveProcessIdentifier: exclusiveProcessIdentifier,
|
||||
failureCount: failureCount,
|
||||
label: label,
|
||||
sortId: sortId,
|
||||
@ -454,6 +483,7 @@ extension SSKJobRecord: DeepCopyable {
|
||||
let modelToCopy = self
|
||||
assert(type(of: modelToCopy) == SSKJobRecord.self)
|
||||
let uniqueId: String = modelToCopy.uniqueId
|
||||
let exclusiveProcessIdentifier: NSNumber? = modelToCopy.exclusiveProcessIdentifier
|
||||
let failureCount: UInt = modelToCopy.failureCount
|
||||
let label: String = modelToCopy.label
|
||||
let sortId: UInt64 = modelToCopy.sortId
|
||||
@ -461,6 +491,7 @@ extension SSKJobRecord: DeepCopyable {
|
||||
|
||||
return SSKJobRecord(grdbId: id,
|
||||
uniqueId: uniqueId,
|
||||
exclusiveProcessIdentifier: exclusiveProcessIdentifier,
|
||||
failureCount: failureCount,
|
||||
label: label,
|
||||
sortId: sortId,
|
||||
@ -493,6 +524,7 @@ extension SSKJobRecordSerializer {
|
||||
static let attachmentIdColumn = SDSColumnMetadata(columnName: "attachmentId", columnType: .unicodeString, isOptional: true)
|
||||
static let isMediaMessageColumn = SDSColumnMetadata(columnName: "isMediaMessage", columnType: .int, isOptional: true)
|
||||
static let serverDeliveryTimestampColumn = SDSColumnMetadata(columnName: "serverDeliveryTimestamp", columnType: .int64, isOptional: true)
|
||||
static let exclusiveProcessIdentifierColumn = SDSColumnMetadata(columnName: "exclusiveProcessIdentifier", columnType: .int64, isOptional: true)
|
||||
|
||||
// TODO: We should decide on a naming convention for
|
||||
// tables that store models.
|
||||
@ -514,7 +546,8 @@ extension SSKJobRecordSerializer {
|
||||
threadIdColumn,
|
||||
attachmentIdColumn,
|
||||
isMediaMessageColumn,
|
||||
serverDeliveryTimestampColumn
|
||||
serverDeliveryTimestampColumn,
|
||||
exclusiveProcessIdentifierColumn
|
||||
])
|
||||
}
|
||||
|
||||
@ -919,8 +952,9 @@ class SSKJobRecordSerializer: SDSSerializer {
|
||||
let attachmentId: String? = nil
|
||||
let isMediaMessage: Bool? = nil
|
||||
let serverDeliveryTimestamp: UInt64? = nil
|
||||
let exclusiveProcessIdentifier: Int32? = archiveOptionalNSNumber(model.exclusiveProcessIdentifier, conversion: { $0.int32Value })
|
||||
|
||||
return JobRecordRecord(delegate: model, id: id, recordType: recordType, uniqueId: uniqueId, failureCount: failureCount, label: label, status: status, attachmentIdMap: attachmentIdMap, contactThreadId: contactThreadId, envelopeData: envelopeData, invisibleMessage: invisibleMessage, messageId: messageId, removeMessageAfterSending: removeMessageAfterSending, threadId: threadId, attachmentId: attachmentId, isMediaMessage: isMediaMessage, serverDeliveryTimestamp: serverDeliveryTimestamp)
|
||||
return JobRecordRecord(delegate: model, id: id, recordType: recordType, uniqueId: uniqueId, failureCount: failureCount, label: label, status: status, attachmentIdMap: attachmentIdMap, contactThreadId: contactThreadId, envelopeData: envelopeData, invisibleMessage: invisibleMessage, messageId: messageId, removeMessageAfterSending: removeMessageAfterSending, threadId: threadId, attachmentId: attachmentId, isMediaMessage: isMediaMessage, serverDeliveryTimestamp: serverDeliveryTimestamp, exclusiveProcessIdentifier: exclusiveProcessIdentifier)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -46,11 +46,12 @@ typedef NS_CLOSED_ENUM(NSUInteger, SSKJobRecordStatus){
|
||||
|
||||
- (instancetype)initWithGrdbId:(int64_t)grdbId
|
||||
uniqueId:(NSString *)uniqueId
|
||||
exclusiveProcessIdentifier:(nullable NSNumber *)exclusiveProcessIdentifier
|
||||
failureCount:(NSUInteger)failureCount
|
||||
label:(NSString *)label
|
||||
sortId:(unsigned long long)sortId
|
||||
status:(SSKJobRecordStatus)status
|
||||
NS_DESIGNATED_INITIALIZER NS_SWIFT_NAME(init(grdbId:uniqueId:failureCount:label:sortId:status:));
|
||||
NS_DESIGNATED_INITIALIZER NS_SWIFT_NAME(init(grdbId:uniqueId:exclusiveProcessIdentifier:failureCount:label:sortId:status:));
|
||||
|
||||
// clang-format on
|
||||
|
||||
@ -60,6 +61,12 @@ NS_DESIGNATED_INITIALIZER NS_SWIFT_NAME(init(grdbId:uniqueId:failureCount:label:
|
||||
|
||||
// GRDB TODO: Replace sortId column with autoincremented id column
|
||||
@property (nonatomic, readonly) UInt64 sortId;
|
||||
@property (nonatomic, readonly, nullable) NSNumber *exclusiveProcessIdentifier;
|
||||
|
||||
- (void)flagAsExclusiveForCurrentProcessIdentifier;
|
||||
|
||||
- (void)updateWithExclusiveForCurrentProcessIdentifierWithTransaction:(SDSAnyWriteTransaction *)transaction
|
||||
NS_SWIFT_NAME(flagAsOnlyValidForCurrentProcessIdentifier(transaction:));
|
||||
|
||||
- (BOOL)saveAsStartedWithTransaction:(SDSAnyWriteTransaction *)transaction
|
||||
error:(NSError **)outError NS_SWIFT_NAME(saveAsStarted(transaction:));
|
||||
|
||||
@ -15,6 +15,7 @@ NSErrorDomain const SSKJobRecordErrorDomain = @"SignalServiceKit.JobRecord";
|
||||
|
||||
@property (nonatomic) SSKJobRecordStatus status;
|
||||
@property (nonatomic) UInt64 sortId;
|
||||
@property (nonatomic, nullable) NSNumber *exclusiveProcessIdentifier;
|
||||
|
||||
@end
|
||||
|
||||
@ -48,6 +49,7 @@ NSErrorDomain const SSKJobRecordErrorDomain = @"SignalServiceKit.JobRecord";
|
||||
|
||||
- (instancetype)initWithGrdbId:(int64_t)grdbId
|
||||
uniqueId:(NSString *)uniqueId
|
||||
exclusiveProcessIdentifier:(nullable NSNumber *)exclusiveProcessIdentifier
|
||||
failureCount:(NSUInteger)failureCount
|
||||
label:(NSString *)label
|
||||
sortId:(unsigned long long)sortId
|
||||
@ -60,6 +62,7 @@ NSErrorDomain const SSKJobRecordErrorDomain = @"SignalServiceKit.JobRecord";
|
||||
return self;
|
||||
}
|
||||
|
||||
_exclusiveProcessIdentifier = exclusiveProcessIdentifier;
|
||||
_failureCount = failureCount;
|
||||
_label = label;
|
||||
_sortId = sortId;
|
||||
@ -84,6 +87,17 @@ NSErrorDomain const SSKJobRecordErrorDomain = @"SignalServiceKit.JobRecord";
|
||||
|
||||
#pragma mark -
|
||||
|
||||
- (void)flagAsExclusiveForCurrentProcessIdentifier
|
||||
{
|
||||
self.exclusiveProcessIdentifier = @(NSProcessInfo.processInfo.processIdentifier);
|
||||
}
|
||||
|
||||
- (void)updateWithExclusiveForCurrentProcessIdentifierWithTransaction:(SDSAnyWriteTransaction *)transaction
|
||||
{
|
||||
[self anyUpdateWithTransaction:transaction
|
||||
block:^(SSKJobRecord *record) { [record flagAsExclusiveForCurrentProcessIdentifier]; }];
|
||||
}
|
||||
|
||||
- (void)updateStatus:(SSKJobRecordStatus)status transaction:(SDSAnyWriteTransaction *)transaction
|
||||
{
|
||||
[self anyUpdateWithTransaction:transaction
|
||||
|
||||
@ -74,7 +74,8 @@ class SSKMessageSenderJobRecordSerializer: SDSSerializer {
|
||||
let attachmentId: String? = nil
|
||||
let isMediaMessage: Bool? = model.isMediaMessage
|
||||
let serverDeliveryTimestamp: UInt64? = nil
|
||||
let exclusiveProcessIdentifier: Int32? = archiveOptionalNSNumber(model.exclusiveProcessIdentifier, conversion: { $0.int32Value })
|
||||
|
||||
return JobRecordRecord(delegate: model, id: id, recordType: recordType, uniqueId: uniqueId, failureCount: failureCount, label: label, status: status, attachmentIdMap: attachmentIdMap, contactThreadId: contactThreadId, envelopeData: envelopeData, invisibleMessage: invisibleMessage, messageId: messageId, removeMessageAfterSending: removeMessageAfterSending, threadId: threadId, attachmentId: attachmentId, isMediaMessage: isMediaMessage, serverDeliveryTimestamp: serverDeliveryTimestamp)
|
||||
return JobRecordRecord(delegate: model, id: id, recordType: recordType, uniqueId: uniqueId, failureCount: failureCount, label: label, status: status, attachmentIdMap: attachmentIdMap, contactThreadId: contactThreadId, envelopeData: envelopeData, invisibleMessage: invisibleMessage, messageId: messageId, removeMessageAfterSending: removeMessageAfterSending, threadId: threadId, attachmentId: attachmentId, isMediaMessage: isMediaMessage, serverDeliveryTimestamp: serverDeliveryTimestamp, exclusiveProcessIdentifier: exclusiveProcessIdentifier)
|
||||
}
|
||||
}
|
||||
|
||||
@ -42,6 +42,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
- (instancetype)initWithGrdbId:(int64_t)grdbId
|
||||
uniqueId:(NSString *)uniqueId
|
||||
exclusiveProcessIdentifier:(nullable NSNumber *)exclusiveProcessIdentifier
|
||||
failureCount:(NSUInteger)failureCount
|
||||
label:(NSString *)label
|
||||
sortId:(unsigned long long)sortId
|
||||
@ -51,7 +52,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
messageId:(nullable NSString *)messageId
|
||||
removeMessageAfterSending:(BOOL)removeMessageAfterSending
|
||||
threadId:(nullable NSString *)threadId
|
||||
NS_DESIGNATED_INITIALIZER NS_SWIFT_NAME(init(grdbId:uniqueId:failureCount:label:sortId:status:invisibleMessage:isMediaMessage:messageId:removeMessageAfterSending:threadId:));
|
||||
NS_DESIGNATED_INITIALIZER NS_SWIFT_NAME(init(grdbId:uniqueId:exclusiveProcessIdentifier:failureCount:label:sortId:status:invisibleMessage:isMediaMessage:messageId:removeMessageAfterSending:threadId:));
|
||||
|
||||
// clang-format on
|
||||
|
||||
|
||||
@ -61,6 +61,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
- (instancetype)initWithGrdbId:(int64_t)grdbId
|
||||
uniqueId:(NSString *)uniqueId
|
||||
exclusiveProcessIdentifier:(nullable NSNumber *)exclusiveProcessIdentifier
|
||||
failureCount:(NSUInteger)failureCount
|
||||
label:(NSString *)label
|
||||
sortId:(unsigned long long)sortId
|
||||
@ -73,6 +74,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
{
|
||||
self = [super initWithGrdbId:grdbId
|
||||
uniqueId:uniqueId
|
||||
exclusiveProcessIdentifier:exclusiveProcessIdentifier
|
||||
failureCount:failureCount
|
||||
label:label
|
||||
sortId:sortId
|
||||
|
||||
@ -2,15 +2,15 @@
|
||||
// Copyright (c) 2021 Open Whisper Systems. All rights reserved.
|
||||
//
|
||||
|
||||
#import "TSYapDatabaseObject.h"
|
||||
#import <SignalServiceKit/SSKEnvironment.h>
|
||||
#import <SignalServiceKit/SignalServiceKit-Swift.h>
|
||||
#import <SignalServiceKit/TSYapDatabaseObject.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface TSYapDatabaseObject ()
|
||||
|
||||
@property (nonatomic, nullable) NSString *uniqueId;
|
||||
@property (nonatomic) NSString *uniqueId;
|
||||
@property (atomic, nullable) NSNumber *grdbId;
|
||||
|
||||
@end
|
||||
|
||||
Loading…
Reference in New Issue
Block a user