Files
Leeksov 4647310322 GLEGram 12.5 — Initial public release
Based on Swiftgram 12.5 (Telegram iOS 12.5).
All GLEGram features ported and organized in GLEGram/ folder.

Features: Ghost Mode, Saved Deleted Messages, Content Protection Bypass,
Font Replacement, Fake Profile, Chat Export, Plugin System, and more.

See CHANGELOG_12.5.md for full details.
2026-04-06 09:48:12 +03:00

63 lines
2.3 KiB
Swift

import Foundation
import JSONUtilities
import PathKit
protocol PathContainer {
static var pathProperties: [PathProperty] { get }
}
enum PathProperty {
case string(String)
case dictionary([PathProperty])
case object(String, [PathProperty])
}
extension Array where Element == PathProperty {
func resolvingPaths(in jsonDictionary: JSONDictionary, relativeTo path: Path) -> JSONDictionary {
var result = jsonDictionary
for pathProperty in self {
switch pathProperty {
case .string(let key):
if let source = result[key] as? String {
result[key] = (path + source).string
} else if let source = result[key] as? [Any] {
result[key] = source.map { any -> Any in
if let string = any as? String {
return (path + string).string
} else {
return any
}
}
} else if let source = result[key] as? [String: String] {
result[key] = source.mapValues { (path + $0).string }
}
case .dictionary(let pathProperties):
for (key, dictionary) in result {
if let source = dictionary as? JSONDictionary {
result[key] = pathProperties.resolvingPaths(in: source, relativeTo: path)
}
}
case .object(let key, let pathProperties):
if let source = result[key] as? JSONDictionary {
result[key] = pathProperties.resolvingPaths(in: source, relativeTo: path)
} else if let source = result[key] as? [Any] {
result[key] = source.map { any -> Any in
if let dictionary = any as? JSONDictionary {
return pathProperties.resolvingPaths(in: dictionary, relativeTo: path)
} else {
return any
}
}
} else if let source = result[key] as? [String: JSONDictionary] {
result[key] = source.mapValues { pathProperties.resolvingPaths(in: $0, relativeTo: path) }
}
}
}
return result
}
}