Skip to content

Commit

Permalink
Release 1.4.7 (195)
Browse files Browse the repository at this point in the history
  • Loading branch information
denis15yo committed Nov 27, 2023
1 parent 3c7f485 commit 498c9db
Show file tree
Hide file tree
Showing 87 changed files with 1,602 additions and 2,397 deletions.
1 change: 1 addition & 0 deletions .github/workflows/beta.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
push:
branches:
- beta
- 'beta-*'

workflow_dispatch:

Expand Down
10 changes: 0 additions & 10 deletions Nicegram/NGAppCache/Sources/AppCache.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@ public final class AppCache {
@UserDefaultsBacked(key: "firstAppLaunchDate", storage: .standard, defaultValue: nil)
public static var firstAppLaunchDate: Date?

@UserDefaultsBacked(key: "currentProductID", storage: .standard, defaultValue: nil)
public static var currentProductID: String?

@UserDefaultsBacked(key: "currentUserID", storage: .standard, defaultValue: nil)
public static var currentUserID: String?

Expand All @@ -20,9 +17,6 @@ public final class AppCache {

@UserDefaultsBacked(key: "wasLauchedBefore", storage: .standard, defaultValue: false)
private static var _wasLauchedBefore: Bool

@UserDefaultsBacked(key: "hasUnlimPremium", storage: .standard, defaultValue: false)
public static var hasUnlimPremium: Bool

@UserDefaultsBacked(key: "wasOnboardingShown", storage: .standard, defaultValue: false)
public static var wasOnboardingShown: Bool
Expand All @@ -38,10 +32,6 @@ public final class AppCache {
_wasLauchedBefore = newValue
}
}

public static var haveValidSubscription: Bool {
return currentProductID != nil || hasUnlimPremium
}

public static var mobileIdentifier: String {
if let identifier = KeychainWrapper.standard.string(forKey: "ng_mobileIdentifier", withAccessibility: .afterFirstUnlock),
Expand Down
2 changes: 1 addition & 1 deletion Nicegram/NGCopyProtectedContent/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ swift_library(
deps = [
"//Nicegram/NGData:NGData",
"//Nicegram/NGRemoteConfig:NGRemoteConfig",
"@swiftpkg_nicegram_assistant_ios//:Sources_NGPremiumUI",
"@swiftpkg_nicegram_assistant_ios//:Sources_FeatPremiumUI",
],
visibility = [
"//visibility:public",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import FeatPremiumUI
import Foundation
import NGData
import NGPremiumUI
import NGRemoteConfig
import Postbox
import UIKit
Expand Down
9 changes: 8 additions & 1 deletion Nicegram/NGData/Sources/NGSettings.swift
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import FeatPremium
import Foundation
import NGAppCache

Expand Down Expand Up @@ -130,7 +131,13 @@ public var VarNGSharedSettings = NGSharedSettings()


public func isPremium() -> Bool {
return AppCache.haveValidSubscription
if #available(iOS 13.0, *) {
return PremiumContainer.shared
.getPremiumStatusUseCase()
.hasPremiumOnDeviceNonIsolated()
} else {
return false
}
}

public func usetrButton() -> [(Bool, [String])] {
Expand Down
65 changes: 0 additions & 65 deletions Nicegram/NGData/Sources/NGWeb.swift
Original file line number Diff line number Diff line change
Expand Up @@ -171,68 +171,3 @@ public func updateNGInfo(userId: Int64) {
ngLog("SYNC_CHATS \(VARNGAPISETTINGS.SYNC_CHATS)\nRESTRICTED \(VARNGAPISETTINGS.RESTRICTED)\nALLOWED \(VARNGAPISETTINGS.ALLOWED)\nRESTRICTED_REASONS count \(VARNGAPISETTINGS.RESTRICTION_REASONS.count)\nPREMIUM", LOGTAG)
})
}


public func requestValidator(_ receipt: Data, completion: @escaping (_ apiResult: String) -> Void) {
let startTime = CFAbsoluteTimeGetCurrent()
ngLog("DECLARING REQUEST VALIDATOR", LOGTAG)
let urlString = NGENV.validator_url

let url = URL(string: urlString)!
var request : URLRequest = URLRequest(url: url)
request.httpBody = receipt
request.httpMethod = "POST"
let task = URLSession.shared.dataTask(with: request) { (data, response, error) in
let timeElapsed = CFAbsoluteTimeGetCurrent() - startTime
ngLog("PROCESSED REQUEST VALIDATOR IN \(timeElapsed) s.", LOGTAG)
if let error = error {
ngLog("Error validating: \(error)", LOGTAG)
completion("error")
} else {
if let response = response as? HTTPURLResponse {
if response.statusCode == 200 {
if let data = data, let dataString = String(data: data, encoding: .utf8) {
completion(dataString)
}
}
}
}
}
task.resume()
}



public func validatePremium(_ current: Bool, forceValid: Bool = false) {
let sem = DispatchSemaphore(value: 0)
if (current) {
guard let receiptURL = Bundle.main.appStoreReceiptURL,
let data = try? Data(contentsOf: receiptURL) else {
// NGSettings.premium = false
ngLog("Hello hacker?????", LOGTAG)
sem.signal()
return
}

let encodedData = data.base64EncodedData(options: [])
requestValidator(encodedData, completion: { validStatus in
if validStatus == "0" { // Hacker
// NGSettings.premium = false
ngLog("Hello hacker", LOGTAG)
// preconditionFailure("Hello hacker")
} else if validStatus == "1" { // OK
ngLog("Okie-dokie", LOGTAG)
} else { // Error
if forceValid {
// NGSettings.premium = false
ngLog("Hello hacker?", LOGTAG)
}
}
sem.signal()
return
})
}
sem.wait()
return
}

9 changes: 0 additions & 9 deletions Nicegram/NGEnv/Sources/NGEnv.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,15 @@ import BuildConfig
public struct NGEnvObj: Decodable {
public let app_review_login_code: String
public let app_review_login_phone: String
public let bundle_id: String
public let premium_bundle: String
public let ng_api_url: String
public let validator_url: String
public let ng_lab_url: String
public let ng_lab_token: String
public let moby_key: String
public let app_id: String
public let privacy_url: String
public let terms_url: String
public let restore_url: String
public let reg_date_url: String
public let reg_date_key: String
public let esim_api_url: String
public let esim_api_key: String
public let google_client_id: String
public let ecommpay_merchant_id: String
public let ecommpay_project_id: Int
public let referral_bot: String
public let remote_config_cache_duration_seconds: Double
public let telegram_auth_bot: String
Expand Down
2 changes: 1 addition & 1 deletion Nicegram/NGOnboarding/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ swift_library(
"//submodules/UIKitRuntimeUtils:UIKitRuntimeUtils",
"//Nicegram/NGData:NGData",
"//Nicegram/NGStrings:NGStrings",
"@swiftpkg_nicegram_assistant_ios//:Sources_FeatPremiumUI",
"@swiftpkg_nicegram_assistant_ios//:Sources_NGAiChat",
"@swiftpkg_nicegram_assistant_ios//:Sources_NGPremiumUI",
],
visibility = [
"//visibility:public",
Expand Down
2 changes: 1 addition & 1 deletion Nicegram/NGOnboarding/Sources/OnboardingFlow.swift
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import FeatPremiumUI
import Foundation
import UIKit
import NGAiChat
import NGData
import NGPremiumUI
import NGStrings

public func onboardingController(languageCode: String, onComplete: @escaping () -> Void) -> UIViewController {
Expand Down
79 changes: 1 addition & 78 deletions Nicegram/NGUI/Sources/NicegramSettingsController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,6 @@ private enum NicegramSettingsControllerEntry: ItemListNodeEntry {

case Account(String)
case doubleBottom(String)
case restorePremium(String, String)

case unblockHeader(String)
case unblock(String, URL)
Expand Down Expand Up @@ -150,7 +149,7 @@ private enum NicegramSettingsControllerEntry: ItemListNodeEntry {
return NicegramSettingsControllerSection.QuickReplies.rawValue
case .unblockHeader, .unblock:
return NicegramSettingsControllerSection.Unblock.rawValue
case .Account, .restorePremium, .doubleBottom:
case .Account, .doubleBottom:
return NicegramSettingsControllerSection.Account.rawValue
case .secretMenu:
return NicegramSettingsControllerSection.SecretMenu.rawValue
Expand Down Expand Up @@ -231,9 +230,6 @@ private enum NicegramSettingsControllerEntry: ItemListNodeEntry {
case .Account:
return 2500

case .restorePremium:
return 2600

case .doubleBottom:
return 2700

Expand Down Expand Up @@ -372,12 +368,6 @@ private enum NicegramSettingsControllerEntry: ItemListNodeEntry {
} else {
return false
}
case let .restorePremium(lhsText, lhsId):
if case let .restorePremium(rhsText, rhsId) = rhs, lhsText == rhsText, lhsId == rhsId {
return true
} else {
return false
}
case let .doubleBottom(lhsText):
if case let .doubleBottom(rhsText) = rhs, lhsText == rhsText {
return true
Expand Down Expand Up @@ -557,72 +547,6 @@ private enum NicegramSettingsControllerEntry: ItemListNodeEntry {
}
case let .Account(text):
return ItemListSectionHeaderItem(presentationData: presentationData, text: text, sectionId: section)
case let .restorePremium(text, id):
return ItemListActionItem(presentationData: presentationData, title: text, kind: .neutral, alignment: .natural, sectionId: section, style: .blocks) {
SharedLoadingView.start()
guard var urlComponents = URLComponents(string: NGENV.restore_url) else { return }
urlComponents.queryItems = [
URLQueryItem(name: "id", value: id)
]
guard let url = urlComponents.url else { return }
var request = URLRequest(url: url)
request.httpMethod = "GET"
let task = URLSession.shared.dataTask(with: request) { (data, response, error) in
var alertTitle = ""
var alertText = ""
guard
let data = data, // is there data
let response = response as? HTTPURLResponse, // is there HTTP response
200 ..< 300 ~= response.statusCode, // is statusCode 2XX
error == nil // was there no error
else {
SharedLoadingView.stop()
DispatchQueue.main.async {
let controller = standardTextAlertController(
theme: AlertControllerTheme(presentationData: arguments.context.sharedContext.currentPresentationData.with { $0 }),
title: l("TelegramPremium.Failure.Title", locale),
text: l("TelegramPremium.Failure.Description", locale),
actions: [
TextAlertAction(type: .genericAction, title: presentationData.strings.Common_OK, action: {})
]
)
arguments.presentController(controller, nil)
}
return
}
let responseObject = (try? JSONSerialization.jsonObject(with: data)) as? [String: Any]

SharedLoadingView.stop()

if let premiumData = responseObject?["data"] as? [String: Any], let premiumAccess = premiumData["premiumAccess"] as? Bool {
if premiumAccess {
AppCache.hasUnlimPremium = true
alertTitle = l("TelegramPremium.Success.Title", locale)
alertText = l("TelegramPremium.Success.Description", locale)
} else {
AppCache.hasUnlimPremium = false
alertTitle = l("TelegramPremium.Failure.Title", locale)
alertText = l("TelegramPremium.Failure.Pending", locale)
}
} else {
alertTitle = l("TelegramPremium.Failure.Title", locale)
alertText = l("TelegramPremium.Failure.Description", locale)
}

DispatchQueue.main.async {
let controller = standardTextAlertController(
theme: AlertControllerTheme(presentationData: arguments.context.sharedContext.currentPresentationData.with { $0 }),
title: alertTitle,
text: alertText,
actions: [
TextAlertAction(type: .genericAction, title: presentationData.strings.Common_OK, action: {})
]
)
arguments.presentController(controller, nil)
}
}
task.resume()
}
case let .doubleBottom(text):
return ItemListActionItem(presentationData: presentationData, title: text, kind: .neutral, alignment: .natural, sectionId: section, style: .blocks) {
arguments.pushController(doubleBottomListController(context: arguments.context, presentationData: arguments.context.sharedContext.currentPresentationData.with { $0 }, accountsContexts: arguments.accountsContexts))
Expand Down Expand Up @@ -792,7 +716,6 @@ private func nicegramSettingsControllerEntries(presentationData: PresentationDat


entries.append(.Account(l("NiceFeatures.Account.Header", locale)))
entries.append(.restorePremium(l("TelegramPremium.Title", locale), "\(context.account.peerId.id._internalGetInt64Value())"))
if !context.account.isHidden || !VarSystemNGSettings.inDoubleBottom {
entries.append(.doubleBottom(l("DoubleBottom.Title", locale)))
}
Expand Down
Loading

0 comments on commit 498c9db

Please sign in to comment.