mirror of
https://github.com/ichmagmaus111/ghostgram.git
synced 2026-05-08 15:24:56 +02:00
chore: migrate to new version + fixed several critical bugs
- Migrated project to latest Telegram iOS base (v12.3.2+) - Fixed circular dependency between GhostModeManager and MiscSettingsManager - Fixed multiple Bazel build configuration errors (select() default conditions) - Fixed duplicate type definitions in PeerInfoScreen - Fixed swiftmodule directory resolution in build scripts - Added Ghostgram Settings tab in main Settings menu with all 5 features - Cleared sensitive credentials from config.json (template-only now) - Excluded bazel-cache from version control
This commit is contained in:
@@ -0,0 +1,87 @@
|
||||
import Foundation
|
||||
import Postbox
|
||||
import TelegramApi
|
||||
|
||||
public final class SummarizationMessageAttribute: Equatable, MessageAttribute {
|
||||
public struct Summary: Equatable, Codable, PostboxCoding {
|
||||
public let text: String
|
||||
public let entities: [MessageTextEntity]
|
||||
|
||||
public init(
|
||||
text: String,
|
||||
entities: [MessageTextEntity]
|
||||
) {
|
||||
self.text = text
|
||||
self.entities = entities
|
||||
}
|
||||
|
||||
public init(decoder: PostboxDecoder) {
|
||||
self.text = decoder.decodeStringForKey("text", orElse: "")
|
||||
self.entities = decoder.decodeObjectArrayWithDecoderForKey("entities")
|
||||
}
|
||||
|
||||
public func encode(_ encoder: PostboxEncoder) {
|
||||
encoder.encodeString(self.text, forKey: "text")
|
||||
encoder.encodeObjectArray(self.entities, forKey: "entities")
|
||||
}
|
||||
}
|
||||
|
||||
public let fromLang: String
|
||||
public let summary: Summary?
|
||||
public let translated: [String: Summary]
|
||||
|
||||
public init(
|
||||
fromLang: String,
|
||||
summary: Summary? = nil,
|
||||
translated: [String: Summary] = [:]
|
||||
) {
|
||||
self.fromLang = fromLang
|
||||
self.summary = summary
|
||||
self.translated = translated
|
||||
}
|
||||
|
||||
required public init(decoder: PostboxDecoder) {
|
||||
self.fromLang = decoder.decodeStringForKey("fl", orElse: "")
|
||||
self.summary = decoder.decodeObjectForKey("s", decoder: { Summary(decoder: $0) }) as? Summary
|
||||
self.translated = decoder.decodeObjectDictionaryForKey("t", keyDecoder: { decoder in
|
||||
return decoder.decodeStringForKey("k", orElse: "")
|
||||
}, valueDecoder: { decoder in
|
||||
return Summary(decoder: decoder)
|
||||
})
|
||||
}
|
||||
|
||||
public func encode(_ encoder: PostboxEncoder) {
|
||||
encoder.encodeString(self.fromLang, forKey: "fl")
|
||||
if let summary = self.summary {
|
||||
encoder.encodeObject(summary, forKey: "s")
|
||||
} else {
|
||||
encoder.encodeNil(forKey: "s")
|
||||
}
|
||||
encoder.encodeObjectDictionary(self.translated, forKey: "t", keyEncoder: { k, e in
|
||||
e.encodeString(k, forKey: "k")
|
||||
})
|
||||
}
|
||||
|
||||
public static func ==(lhs: SummarizationMessageAttribute, rhs: SummarizationMessageAttribute) -> Bool {
|
||||
if lhs.fromLang != rhs.fromLang {
|
||||
return false
|
||||
}
|
||||
if lhs.summary != rhs.summary {
|
||||
return false
|
||||
}
|
||||
if lhs.translated != rhs.translated {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
public extension SummarizationMessageAttribute {
|
||||
func summaryForLang(_ lang: String?) -> Summary? {
|
||||
if let lang {
|
||||
return self.translated[lang]
|
||||
} else {
|
||||
return self.summary
|
||||
}
|
||||
}
|
||||
}
|
||||
+10
@@ -111,6 +111,11 @@ public extension Message {
|
||||
}
|
||||
|
||||
var minAutoremoveOrClearTimeout: Int32? {
|
||||
// MISC: Bypass if view-once setting is enabled
|
||||
if MiscSettingsManager.shared.shouldDisableViewOnceAutoDelete {
|
||||
return nil
|
||||
}
|
||||
|
||||
var timeout: Int32?
|
||||
for attribute in self.attributes {
|
||||
if let attribute = attribute as? AutoremoveTimeoutMessageAttribute {
|
||||
@@ -137,6 +142,11 @@ public extension Message {
|
||||
}
|
||||
|
||||
var containsSecretMedia: Bool {
|
||||
// MISC: Bypass if view-once setting is enabled
|
||||
if MiscSettingsManager.shared.shouldDisableViewOnceAutoDelete {
|
||||
return false
|
||||
}
|
||||
|
||||
guard let timeout = self.minAutoremoveOrClearTimeout else {
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -323,6 +323,7 @@ private enum PreferencesKeyValues: Int32 {
|
||||
case persistentChatInterfaceData = 45
|
||||
case globalPostSearchState = 46
|
||||
case savedMusicIds = 47
|
||||
case emojiGameInfo = 48
|
||||
}
|
||||
|
||||
public func applicationSpecificPreferencesKey(_ value: Int32) -> ValueBoxKey {
|
||||
@@ -591,6 +592,12 @@ public struct PreferencesKeys {
|
||||
key.setInt32(0, value: PreferencesKeyValues.savedMusicIds.rawValue)
|
||||
return key
|
||||
}
|
||||
|
||||
public static func emojiGameInfo() -> ValueBoxKey {
|
||||
let key = ValueBoxKey(length: 4)
|
||||
key.setInt32(0, value: PreferencesKeyValues.emojiGameInfo.rawValue)
|
||||
return key
|
||||
}
|
||||
}
|
||||
|
||||
private enum SharedDataKeyValues: Int32 {
|
||||
|
||||
@@ -62,7 +62,8 @@ public struct TelegramChatAdminRightsFlags: OptionSet, Hashable {
|
||||
.canPostStories,
|
||||
.canEditStories,
|
||||
.canDeleteStories,
|
||||
.canManageDirect
|
||||
.canManageDirect,
|
||||
.canBanUsers
|
||||
]
|
||||
|
||||
public static func peerSpecific(peer: EnginePeer) -> TelegramChatAdminRightsFlags {
|
||||
|
||||
@@ -1,29 +1,57 @@
|
||||
import Foundation
|
||||
import Postbox
|
||||
|
||||
public final class TelegramMediaDice: Media, Equatable {
|
||||
public struct GameOutcome: Equatable {
|
||||
let seed: Data
|
||||
public let tonAmount: Int64
|
||||
}
|
||||
|
||||
public let emoji: String
|
||||
public let tonAmount: Int64?
|
||||
public let value: Int32?
|
||||
public let gameOutcome: GameOutcome?
|
||||
|
||||
public let id: MediaId? = nil
|
||||
public let peerIds: [PeerId] = []
|
||||
|
||||
public init(emoji: String, value: Int32? = nil) {
|
||||
public init(emoji: String, tonAmount: Int64? = nil, value: Int32? = nil, gameOutcome: GameOutcome? = nil) {
|
||||
self.emoji = emoji
|
||||
self.tonAmount = tonAmount
|
||||
self.value = value
|
||||
self.gameOutcome = gameOutcome
|
||||
}
|
||||
|
||||
public init(decoder: PostboxDecoder) {
|
||||
self.emoji = decoder.decodeStringForKey("e", orElse: "🎲")
|
||||
self.tonAmount = decoder.decodeOptionalInt64ForKey("ta")
|
||||
self.value = decoder.decodeOptionalInt32ForKey("v")
|
||||
if let seed = decoder.decodeDataForKey("gos"), let tonAmount = decoder.decodeOptionalInt64ForKey("goa") {
|
||||
self.gameOutcome = GameOutcome(seed: seed, tonAmount: tonAmount)
|
||||
} else {
|
||||
self.gameOutcome = nil
|
||||
}
|
||||
}
|
||||
|
||||
public func encode(_ encoder: PostboxEncoder) {
|
||||
encoder.encodeString(self.emoji, forKey: "e")
|
||||
if let tonAmount = self.tonAmount {
|
||||
encoder.encodeInt64(tonAmount, forKey: "ta")
|
||||
} else {
|
||||
encoder.encodeNil(forKey: "ta")
|
||||
}
|
||||
if let value = self.value {
|
||||
encoder.encodeInt32(value, forKey: "v")
|
||||
} else {
|
||||
encoder.encodeNil(forKey: "v")
|
||||
}
|
||||
if let gameOutcome = self.gameOutcome {
|
||||
encoder.encodeData(gameOutcome.seed, forKey: "gos")
|
||||
encoder.encodeInt64(gameOutcome.tonAmount, forKey: "goa")
|
||||
} else {
|
||||
encoder.encodeNil(forKey: "gos")
|
||||
encoder.encodeNil(forKey: "goa")
|
||||
}
|
||||
}
|
||||
|
||||
public static func ==(lhs: TelegramMediaDice, rhs: TelegramMediaDice) -> Bool {
|
||||
@@ -35,9 +63,15 @@ public final class TelegramMediaDice: Media, Equatable {
|
||||
if self.emoji != other.emoji {
|
||||
return false
|
||||
}
|
||||
if self.tonAmount != other.tonAmount {
|
||||
return false
|
||||
}
|
||||
if self.value != other.value {
|
||||
return false
|
||||
}
|
||||
if self.gameOutcome != other.gameOutcome {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
return false
|
||||
|
||||
Reference in New Issue
Block a user