From 2377ada199b0a7279ca02f9c8357edbcf54836dc Mon Sep 17 00:00:00 2001 From: Riley Testut Date: Thu, 30 Nov 2023 14:33:08 -0600 Subject: [PATCH] Supports remotely disabling workaround for downloading Patreon attachments In case our workaround for downloading Patreon post attachments breaks, we can remotely disable it and force AltStore to use its fallback instead (taking user to post directly). --- AltStore/Operations/DownloadAppOperation.swift | 5 +++++ AltStore/Operations/FetchSourceOperation.swift | 5 +++++ AltStoreCore/Extensions/UserDefaults+AltStore.swift | 2 ++ AltStoreCore/Types/ALTSourceUserInfoKey.h | 1 + AltStoreCore/Types/ALTSourceUserInfoKey.m | 1 + 5 files changed, 14 insertions(+) diff --git a/AltStore/Operations/DownloadAppOperation.swift b/AltStore/Operations/DownloadAppOperation.swift index 99c01136..4b0bbadb 100644 --- a/AltStore/Operations/DownloadAppOperation.swift +++ b/AltStore/Operations/DownloadAppOperation.swift @@ -301,6 +301,11 @@ private extension DownloadAppOperation func downloadPatreonApp(from patreonURL: URL) async throws -> URL { + guard !UserDefaults.shared.skipPatreonDownloads else { + // Skip all hacks, take user straight to Patreon post. + return try await downloadFromPatreonPost() + } + do { // User is pledged to this app, attempt to download. diff --git a/AltStore/Operations/FetchSourceOperation.swift b/AltStore/Operations/FetchSourceOperation.swift index 36c12ef3..7c0ec04e 100644 --- a/AltStore/Operations/FetchSourceOperation.swift +++ b/AltStore/Operations/FetchSourceOperation.swift @@ -153,6 +153,11 @@ class FetchSourceOperation: ResultOperation let identifier = source.identifier + if identifier == Source.altStoreIdentifier, let skipPatreonDownloads = source.userInfo?[.skipPatreonDownloads] + { + UserDefaults.shared.skipPatreonDownloads = (skipPatreonDownloads == "true") + } + try self.verify(source, response: response) try self.verifyPledges(for: source, in: childContext) diff --git a/AltStoreCore/Extensions/UserDefaults+AltStore.swift b/AltStoreCore/Extensions/UserDefaults+AltStore.swift index 9b3551f4..507d443c 100644 --- a/AltStoreCore/Extensions/UserDefaults+AltStore.swift +++ b/AltStoreCore/Extensions/UserDefaults+AltStore.swift @@ -39,6 +39,8 @@ public extension UserDefaults @NSManaged var patronsRefreshID: String? + @NSManaged var skipPatreonDownloads: Bool + @nonobjc var activeAppsLimit: Int? { get { diff --git a/AltStoreCore/Types/ALTSourceUserInfoKey.h b/AltStoreCore/Types/ALTSourceUserInfoKey.h index f18a0365..5621334e 100644 --- a/AltStoreCore/Types/ALTSourceUserInfoKey.h +++ b/AltStoreCore/Types/ALTSourceUserInfoKey.h @@ -10,3 +10,4 @@ typedef NSString *ALTSourceUserInfoKey NS_TYPED_EXTENSIBLE_ENUM; extern ALTSourceUserInfoKey const ALTSourceUserInfoKeyPatreonAccessToken; +extern ALTSourceUserInfoKey const ALTSourceUserInfoKeySkipPatreonDownloads; diff --git a/AltStoreCore/Types/ALTSourceUserInfoKey.m b/AltStoreCore/Types/ALTSourceUserInfoKey.m index 4d715cdc..d326b71f 100644 --- a/AltStoreCore/Types/ALTSourceUserInfoKey.m +++ b/AltStoreCore/Types/ALTSourceUserInfoKey.m @@ -9,3 +9,4 @@ #import "ALTSourceUserInfoKey.h" ALTSourceUserInfoKey const ALTSourceUserInfoKeyPatreonAccessToken = @"patreonAccessToken"; +ALTSourceUserInfoKey const ALTSourceUserInfoKeySkipPatreonDownloads = @"skipPatreonDownloads";