mirror of
https://github.com/TelegramMessenger/Telegram-iOS.git
synced 2026-06-20 18:24:43 +00:00
69bfc65da7
Consolidates 137 wave commits + 31 supporting commits (CLAUDE.md bump, typealias additions, AnyObject→EngineMedia restoration) into one squashed commit. Migrates dozens of consumer-side public APIs, struct fields, protocol methods, and enum payloads from Postbox protocols/structs to TelegramEngine engine wrappers and typealiases. Drops `import Postbox` from many files. Adds new TelegramCore typealiases and one TelegramEngineUnauthorized facade. Notable changes by category: **TelegramCore typealias additions** (rule 2 — narrow utility typealiases): - EngineChatListIndex, EngineTempBoxFile, EngineItemCollectionItemIndex, EngineItemCollectionViewEntryIndex, EngineValueBoxEncryptionParameters, EngineMessageAndThreadId, EnginePeerStoryStats, EngineMessageHistoryAnchorIndex, EngineChatListTotalUnreadStateCategory, EngineChatListTotalUnreadStateStats, EnginePeerSummaryCounterTags, EngineChatListTotalUnreadState, EngineItemCacheEntryId, EngineHashFunctions, EngineCachedMediaResourceRepresentationResult, EngineMediaResourceDataFetchResult, EngineMediaResourceDataFetchError, EngineMediaResourceStatus, EngineCachedPeerData **TelegramCore engine extensions/forwarders**: - EngineMessage.engineMedia, EngineMessage.enginePeers, EngineMessage.adAttribute, EngineMessage.effectivelyIncoming - engineFileSize forwarder - TelegramEngine.Resources.clearCachedMediaResources(mediaResourceIds: Set<EngineMediaResource.Id>) - TelegramEngine.Resources.fetchStatus(id:resourceSize:) - TelegramEngineUnauthorized.UnauthorizedResources facade with storeResourceData **Public API/struct migrations to engine types**: - ChatAvailableMessageActions.banAuthor/banAuthors → EnginePeer?/[EnginePeer] - WebSessionsContextState.peers → [EnginePeer.Id: EnginePeer] - CacheUsageStats.peers → [EnginePeer.Id: EnginePeer] - PeerCommand.peer → EnginePeer - PeerInfoControllerMode.calls(messages:) → [EngineMessage] - CallControllerNodeProtocol.updatePeer → EnginePeer params - ChatHistoryListNode.messageInCurrentHistoryView (and 4 variants) → EngineMessage? - ChatHistorySearchContainerNode.messageForGallery → EngineMessage? - PeerInfoPaneNode.findLoadedMessage / ensureMessageIsVisible / transitionNodeForGallery → engine-typed - GalleryHiddenMediaTarget.getTransitionInfo / GalleryHiddenMediaManager.findTarget → engine-typed - ChatPanelInterfaceInteraction.presentReactionDeletionOptions / presentBan*MessageOptions → EnginePeer - DrawingMessageRenderer.messages → [EngineMessage] - ChatVideoGalleryItemScrubberView.setFetchStatusSignal → EngineMediaResource.FetchStatus - ChannelDiscussionGroupActionSheetItem.peer, VoiceChatPeerEntry.peer, VoiceChatFullscreenParticipantItem.peer, MediaStreamComponent.chatPeer, MediaStreamVideoComponent.callPeer, ChatMessageContactBubbleContentNode.contactPeer, ChatMessageForwardInfoNode.peer, ChatMessageCommentFooterContentNode.replyPeers, ChatReportPeerTitlePanelNode.peer, ChatMessageActionUrlAuthController.bot, PeerMediaCollectionInterfaceState.peer, ChatMessageCallBubbleContentNode.peopleAvatars, ChatLoadingNode.renderedPeer (→ EngineRenderedPeer) — all to engine types **Wave-71-shadow stored-field migrations** (Postbox Peer/Message → Engine wrapper): - LegacyCallControllerNode.peer - CallStatusBarNode.currentPeer **Dead-code / dead-field removals**: - CallController.peer, CallControllerNodeV2.account, ContactMultiselectionController PeerNameIndex fields, preparedChatListNodeViewTransition account: Account param, FetchResource.swift entirely (unused function) **Module-level Postbox import drops**: 30+ files including TelegramRootController, EditStories, GiftViewScreen, AnimatedStickerUtils, FetchPhotoLibraryImageResource, PeerInfoGiftsPaneNode, PeerInfoPaneContainerNode, PresentAddMembers, PeerInfoProfileItems, ChatControllerAdminBanUsers, PresentationData typealiases, DefaultDayPresentationTheme, ChatListViewTransition, GalleryHiddenMediaManager, RecentSessionsController, GifContext, AuthorizationSequenceController, PeerInfoHeaderEditingContentNode, PeerInfoHeaderNode, PeerAllowedReactionListController, CallControllerNodeV2, and 6 PeerInfo pane files. **AnyObject restoration**: rule 8 added (never substitute Postbox protocols with Any/AnyObject) — undid previous AnyObject substitutions in waves 141/143 back to EngineMedia. Doc maintenance: CLAUDE.md updated to reflect new typealiases and forwarders. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
105 lines
3.6 KiB
Swift
105 lines
3.6 KiB
Swift
import Foundation
|
|
import TelegramCore
|
|
import SwiftSignalKit
|
|
|
|
public enum CachedChannelAdminRank: Codable, Equatable {
|
|
case creator(String?)
|
|
case admin(String?)
|
|
case member(String?)
|
|
|
|
public init(from decoder: Decoder) throws {
|
|
let container = try decoder.container(keyedBy: StringCodingKey.self)
|
|
|
|
let value: Int32 = try container.decode(Int32.self, forKey: "v")
|
|
switch value {
|
|
case 0:
|
|
self = .creator(try container.decodeIfPresent(String.self, forKey: "s"))
|
|
case 1:
|
|
self = .admin(try container.decodeIfPresent(String.self, forKey: "s"))
|
|
case 2:
|
|
self = .member(try container.decodeIfPresent(String.self, forKey: "s"))
|
|
default:
|
|
self = .member(nil)
|
|
}
|
|
}
|
|
|
|
public func encode(to encoder: Encoder) throws {
|
|
var container = encoder.container(keyedBy: StringCodingKey.self)
|
|
|
|
switch self {
|
|
case let .creator(rank):
|
|
try container.encode(0 as Int32, forKey: "v")
|
|
try container.encodeIfPresent(rank, forKey: "s")
|
|
case let .admin(rank):
|
|
try container.encode(1 as Int32, forKey: "v")
|
|
try container.encodeIfPresent(rank, forKey: "s")
|
|
case let .member(rank):
|
|
try container.encode(2 as Int32, forKey: "v")
|
|
try container.encodeIfPresent(rank, forKey: "s")
|
|
}
|
|
}
|
|
}
|
|
|
|
public final class CachedChannelAdminRanks: Codable {
|
|
private struct DictionaryKey: Codable, Hashable {
|
|
var key: EnginePeer.Id
|
|
|
|
init(_ key: EnginePeer.Id) {
|
|
self.key = key
|
|
}
|
|
|
|
init(from decoder: Decoder) throws {
|
|
let container = try decoder.container(keyedBy: StringCodingKey.self)
|
|
|
|
self.key = EnginePeer.Id(try container.decode(Int64.self, forKey: "k"))
|
|
}
|
|
|
|
func encode(to encoder: Encoder) throws {
|
|
var container = encoder.container(keyedBy: StringCodingKey.self)
|
|
|
|
try container.encode(self.key.toInt64(), forKey: "k")
|
|
}
|
|
}
|
|
|
|
public let ranks: [EnginePeer.Id: CachedChannelAdminRank]
|
|
|
|
public init(ranks: [EnginePeer.Id: CachedChannelAdminRank]) {
|
|
self.ranks = ranks
|
|
}
|
|
|
|
public init(from decoder: Decoder) throws {
|
|
let container = try decoder.container(keyedBy: StringCodingKey.self)
|
|
|
|
let dict = try container.decode([DictionaryKey: CachedChannelAdminRank].self, forKey: "ranks")
|
|
var mappedDict: [EnginePeer.Id: CachedChannelAdminRank] = [:]
|
|
for (key, value) in dict {
|
|
mappedDict[key.key] = value
|
|
}
|
|
self.ranks = mappedDict
|
|
}
|
|
|
|
public func encode(to encoder: Encoder) throws {
|
|
var container = encoder.container(keyedBy: StringCodingKey.self)
|
|
|
|
var mappedDict: [DictionaryKey: CachedChannelAdminRank] = [:]
|
|
for (k, v) in self.ranks {
|
|
mappedDict[DictionaryKey(k)] = v
|
|
}
|
|
try container.encode(mappedDict, forKey: "ranks")
|
|
}
|
|
|
|
public static func cacheKey(peerId: EnginePeer.Id) -> EngineDataBuffer {
|
|
let key = EngineDataBuffer(length: 8)
|
|
key.setInt64(0, value: peerId.toInt64())
|
|
return key
|
|
}
|
|
}
|
|
|
|
public func cachedChannelAdminRanksEntryId(peerId: EnginePeer.Id) -> EngineItemCacheEntryId {
|
|
return EngineItemCacheEntryId(collectionId: 100, key: CachedChannelAdminRanks.cacheKey(peerId: peerId))
|
|
}
|
|
|
|
func updateCachedChannelAdminRanks(engine: TelegramEngine, peerId: EnginePeer.Id, ranks: Dictionary<EnginePeer.Id, CachedChannelAdminRank>) -> Signal<Never, NoError> {
|
|
return engine.itemCache.put(collectionId: 100, id: CachedChannelAdminRanks.cacheKey(peerId: peerId), item: CachedChannelAdminRanks(ranks: ranks))
|
|
}
|