Files
Swiftgram/submodules/TelegramCore/Sources/ApiUtils/TelegramMediaWebDocument.swift
Isaac 55c53717af Refactor constructor use sites for types 360-379 to struct pattern
Migrated 20 types including userProfilePhoto, userStatus*, username, videoSize*,
wallPaper*, webDocument*, webPage*, webViewResultUrl, authorizations,
authorizationForm, autoDownloadSettings, businessChatLinks, chatThemes,
connectedBots, and contentSettings.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-18 22:45:35 +08:00

18 lines
1.1 KiB
Swift

import Foundation
import Postbox
import TelegramApi
extension TelegramMediaWebFile {
convenience init(_ document: Api.WebDocument) {
switch document {
case let .webDocument(webDocumentData):
let (url, accessHash, size, mimeType, attributes) = (webDocumentData.url, webDocumentData.accessHash, webDocumentData.size, webDocumentData.mimeType, webDocumentData.attributes)
self.init(resource: WebFileReferenceMediaResource(url: url, size: Int64(size), accessHash: accessHash), mimeType: mimeType, size: size, attributes: telegramMediaFileAttributesFromApiAttributes(attributes))
case let .webDocumentNoProxy(webDocumentNoProxyData):
let (url, size, mimeType, attributes) = (webDocumentNoProxyData.url, webDocumentNoProxyData.size, webDocumentNoProxyData.mimeType, webDocumentNoProxyData.attributes)
self.init(resource: HttpReferenceMediaResource(url: url, size: Int64(size)), mimeType: mimeType, size: size, attributes: telegramMediaFileAttributesFromApiAttributes(attributes))
}
}
}