Files
Morgan Pretty b11d8bc394 Started working on new reupload logic for user display pics
• Started working on the updated logic for the ReuploadUserDisplayPictureJob
• Pulled across a few changes from the refactored networking
• Pulled across the profile_updated changes from the animated profile pictures PR
2025-09-24 15:29:28 +10:00

63 lines
2.5 KiB
Swift

// Copyright © 2022 Rangeproof Pty Ltd. All rights reserved.
import Foundation
import GRDB
import SessionUtilitiesKit
import SessionNetworkingKit
/// This migration sets up the standard jobs, since we want these jobs to run before any "once-off" jobs we do this migration
/// before running the `YDBToGRDBMigration`
enum _007_SMK_SetupStandardJobs: Migration {
static let identifier: String = "messagingKit.SetupStandardJobs"
static let minExpectedRunDuration: TimeInterval = 0.1
static let createdTables: [(TableRecord & FetchableRecord).Type] = []
static func migrate(_ db: ObservingDatabase, using dependencies: Dependencies) throws {
/// Only insert jobs if the `jobs` table exists or we aren't running tests (when running tests this allows us to skip running the
/// SNUtilitiesKit migrations)
guard
!SNUtilitiesKit.isRunningTests ||
((try? db.tableExists("job")) == true)
else { return MigrationExecution.updateProgress(1) }
// Start by adding the jobs that don't have collections (in the jobs like these
// will be added via migrations)
try db.execute(sql: """
INSERT INTO job (variant, behaviour, shouldBlock)
VALUES
(
\(Job.Variant.disappearingMessages.rawValue),
\(Job.Behaviour.recurringOnLaunch.rawValue),
true
),
(
\(Job.Variant.failedMessageSends.rawValue),
\(Job.Behaviour.recurringOnLaunch.rawValue),
true
),
(
\(Job.Variant.failedAttachmentDownloads.rawValue),
\(Job.Behaviour.recurringOnLaunch.rawValue),
true
),
(
\(Job.Variant.reuploadUserDisplayPicture.rawValue),
\(Job.Behaviour.recurringOnActive.rawValue),
false
),
(
\(Job.Variant.retrieveDefaultOpenGroupRooms.rawValue),
\(Job.Behaviour.recurringOnActive.rawValue),
false
),
(
\(Job.Variant.garbageCollection.rawValue),
\(Job.Behaviour.recurringOnActive.rawValue),
false
)
""")
MigrationExecution.updateProgress(1)
}
}