mirror of
https://github.com/ichmagmaus111/ghostgram.git
synced 2026-09-22 12:20:43 +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:
@@ -482,6 +482,12 @@ private class AdMessagesHistoryContextImpl {
|
||||
}
|
||||
self.isActivated = true
|
||||
|
||||
// MISC: Block ads if setting enabled
|
||||
if MiscSettingsManager.shared.shouldBlockAds {
|
||||
self.stateValue = State(interPostInterval: nil, startDelay: nil, betweenDelay: nil, messages: [])
|
||||
return
|
||||
}
|
||||
|
||||
let peerId = self.peerId
|
||||
let accountPeerId = self.account.peerId
|
||||
let account = self.account
|
||||
|
||||
+4
-1
@@ -64,7 +64,10 @@ func _internal_applyMaxReadIndexInteractively(transaction: Transaction, stateMan
|
||||
}
|
||||
}
|
||||
} else if index.id.peerId.namespace == Namespaces.Peer.CloudUser || index.id.peerId.namespace == Namespaces.Peer.CloudGroup || index.id.peerId.namespace == Namespaces.Peer.CloudChannel {
|
||||
stateManager.notifyAppliedIncomingReadMessages([index.id])
|
||||
// GHOST MODE: Don't send read receipts (blue checkmarks)
|
||||
if !GhostModeManager.shared.shouldHideReadReceipts {
|
||||
stateManager.notifyAppliedIncomingReadMessages([index.id])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+8
-1
@@ -51,6 +51,11 @@ func _internal_markMessageContentAsConsumedInteractively(postbox: Postbox, messa
|
||||
for i in 0 ..< updatedAttributes.count {
|
||||
if let attribute = updatedAttributes[i] as? AutoremoveTimeoutMessageAttribute {
|
||||
if attribute.countdownBeginTime == nil || attribute.countdownBeginTime == 0 {
|
||||
// MISC: Don't start countdown for view-once if bypass enabled
|
||||
if attribute.timeout == viewOnceTimeout && MiscSettingsManager.shared.shouldDisableViewOnceAutoDelete {
|
||||
continue
|
||||
}
|
||||
|
||||
var timeout = attribute.timeout
|
||||
if let duration = message.secretMediaDuration {
|
||||
timeout = max(timeout, Int32(duration))
|
||||
@@ -194,7 +199,9 @@ func markMessageContentAsConsumedRemotely(transaction: Transaction, messageId: M
|
||||
|
||||
if message.id.peerId.namespace == Namespaces.Peer.SecretChat {
|
||||
} else {
|
||||
if attribute.timeout == viewOnceTimeout || timestamp >= countdownBeginTime + attribute.timeout {
|
||||
// MISC: Don't expire view-once media if bypass enabled
|
||||
let shouldExpire = !(attribute.timeout == viewOnceTimeout && MiscSettingsManager.shared.shouldDisableViewOnceAutoDelete)
|
||||
if shouldExpire && (attribute.timeout == viewOnceTimeout || timestamp >= countdownBeginTime + attribute.timeout) {
|
||||
for i in 0 ..< updatedMedia.count {
|
||||
if let _ = updatedMedia[i] as? TelegramMediaImage {
|
||||
updatedMedia[i] = TelegramMediaExpiredContent(data: .image)
|
||||
|
||||
@@ -0,0 +1,83 @@
|
||||
import Foundation
|
||||
import Postbox
|
||||
import SwiftSignalKit
|
||||
import TelegramApi
|
||||
import MtProtoKit
|
||||
|
||||
public enum SummarizeError {
|
||||
case generic
|
||||
case invalidMessageId
|
||||
case limitExceeded
|
||||
case invalidLanguage
|
||||
case limitExceededPremium
|
||||
}
|
||||
|
||||
func _internal_summarizeMessage(account: Account, messageId: EngineMessage.Id, translateToLang: String?) -> Signal<Never, SummarizeError> {
|
||||
return account.postbox.transaction { transaction -> Api.InputPeer? in
|
||||
return transaction.getPeer(messageId.peerId).flatMap(apiInputPeer)
|
||||
}
|
||||
|> castError(SummarizeError.self)
|
||||
|> mapToSignal { inputPeer -> Signal<Never, SummarizeError> in
|
||||
guard let inputPeer else {
|
||||
return .never()
|
||||
}
|
||||
|
||||
var flags: Int32 = 0
|
||||
if let _ = translateToLang {
|
||||
flags |= (1 << 0)
|
||||
}
|
||||
|
||||
return account.network.request(Api.functions.messages.summarizeText(flags: flags, peer: inputPeer, id: messageId.id, toLang: translateToLang))
|
||||
|> map(Optional.init)
|
||||
|> mapError { error -> SummarizeError in
|
||||
if error.errorDescription.hasPrefix("FLOOD_WAIT") {
|
||||
return .limitExceeded
|
||||
} else if error.errorDescription == "MSG_ID_INVALID" {
|
||||
return .invalidMessageId
|
||||
} else if error.errorDescription == "TO_LANG_INVALID" {
|
||||
return .invalidLanguage
|
||||
} else if error.errorDescription == "SUMMARY_FLOOD_PREMIUM" {
|
||||
return .limitExceededPremium
|
||||
} else {
|
||||
return .generic
|
||||
}
|
||||
}
|
||||
|> mapToSignal { result -> Signal<Void, SummarizeError> in
|
||||
return account.postbox.transaction { transaction in
|
||||
switch result {
|
||||
case let .textWithEntities(text, entities):
|
||||
transaction.updateMessage(messageId, update: { currentMessage in
|
||||
let storeForwardInfo = currentMessage.forwardInfo.flatMap(StoreMessageForwardInfo.init)
|
||||
var attributes = currentMessage.attributes
|
||||
|
||||
let currentAttribute = attributes.first(where: { $0 is SummarizationMessageAttribute }) as? SummarizationMessageAttribute
|
||||
let updatedAttribute: SummarizationMessageAttribute
|
||||
if let translateToLang {
|
||||
var translated = currentAttribute?.translated ?? [:]
|
||||
translated[translateToLang] = SummarizationMessageAttribute.Summary(text: text, entities: messageTextEntitiesFromApiEntities(entities))
|
||||
updatedAttribute = SummarizationMessageAttribute(
|
||||
fromLang: currentAttribute?.fromLang ?? "",
|
||||
summary: currentAttribute?.summary,
|
||||
translated: translated
|
||||
)
|
||||
} else {
|
||||
updatedAttribute = SummarizationMessageAttribute(
|
||||
fromLang: currentAttribute?.fromLang ?? "",
|
||||
summary: .init(text: text, entities: messageTextEntitiesFromApiEntities(entities)),
|
||||
translated: currentAttribute?.translated ?? [:]
|
||||
)
|
||||
}
|
||||
attributes = attributes.filter { !($0 is SummarizationMessageAttribute) }
|
||||
attributes.append(updatedAttribute)
|
||||
|
||||
return .update(StoreMessage(id: currentMessage.id, customStableId: nil, globallyUniqueId: currentMessage.globallyUniqueId, groupingKey: currentMessage.groupingKey, threadId: currentMessage.threadId, timestamp: currentMessage.timestamp, flags: StoreMessageFlags(currentMessage.flags), tags: currentMessage.tags, globalTags: currentMessage.globalTags, localTags: currentMessage.localTags, forwardInfo: storeForwardInfo, authorId: currentMessage.author?.id, text: currentMessage.text, attributes: attributes, media: currentMessage.media))
|
||||
})
|
||||
default:
|
||||
break
|
||||
}
|
||||
}
|
||||
|> castError(SummarizeError.self)
|
||||
}
|
||||
|> ignoreValues
|
||||
}
|
||||
}
|
||||
@@ -604,6 +604,10 @@ public extension TelegramEngine {
|
||||
return _internal_togglePeerMessagesTranslationHidden(account: self.account, peerId: peerId, hidden: hidden)
|
||||
}
|
||||
|
||||
public func summarizeMessage(messageId: EngineMessage.Id, translateToLang: String?) -> Signal<Never, SummarizeError> {
|
||||
return _internal_summarizeMessage(account: self.account, messageId: messageId, translateToLang: translateToLang)
|
||||
}
|
||||
|
||||
public func transcribeAudio(messageId: MessageId) -> Signal<EngineAudioTranscriptionResult, NoError> {
|
||||
return _internal_transcribeAudio(postbox: self.account.postbox, network: self.account.network, messageId: messageId)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user