Merge commit '7621e2f8dec938cf48181c8b10afc9b01f444e68' into beta

This commit is contained in:
Ilya Laktyushin
2025-12-06 02:17:48 +04:00
commit 8344b97e03
28070 changed files with 7995182 additions and 0 deletions
+19
View File
@@ -0,0 +1,19 @@
load("@build_bazel_rules_swift//swift:swift.bzl", "swift_library")
swift_library(
name = "WebsiteType",
module_name = "WebsiteType",
srcs = glob([
"Sources/**/*.swift",
]),
copts = [
"-warnings-as-errors",
],
deps = [
"//submodules/Postbox",
"//submodules/TelegramCore",
],
visibility = [
"//visibility:public",
],
)
@@ -0,0 +1,19 @@
//
// WebsiteType.h
// WebsiteType
//
// Created by Peter on 8/11/19.
// Copyright © 2019 Telegram Messenger LLP. All rights reserved.
//
#import <UIKit/UIKit.h>
//! Project version number for WebsiteType.
FOUNDATION_EXPORT double WebsiteTypeVersionNumber;
//! Project version string for WebsiteType.
FOUNDATION_EXPORT const unsigned char WebsiteTypeVersionString[];
// In this header, you should import all the public headers of your framework using statements like #import <WebsiteType/PublicHeader.h>
@@ -0,0 +1,64 @@
import Foundation
import Postbox
import TelegramCore
public enum WebsiteType {
case generic
case twitter
case instagram
}
public func websiteType(of websiteName: String?) -> WebsiteType {
if let websiteName = websiteName?.lowercased() {
if websiteName == "twitter" {
return .twitter
} else if websiteName == "instagram" {
return .instagram
}
}
return .generic
}
public enum InstantPageType {
case generic
case album
}
public func instantPageType(of webpage: TelegramMediaWebpageLoadedContent) -> InstantPageType {
if let type = webpage.type, type == "telegram_album" {
return .album
}
switch websiteType(of: webpage.websiteName) {
case .instagram, .twitter:
return .album
default:
return .generic
}
}
public func defaultWebpageImageSizeIsSmall(webpage: TelegramMediaWebpageLoadedContent) -> Bool {
let type = websiteType(of: webpage.websiteName)
let mainMedia: Media?
switch type {
case .instagram, .twitter:
mainMedia = webpage.story ?? webpage.image ?? webpage.file
default:
mainMedia = webpage.story ?? webpage.file ?? webpage.image
}
if let image = mainMedia as? TelegramMediaImage {
if let type = webpage.type, (["photo", "video", "embed", "gif", "document", "telegram_album"] as [String]).contains(type) {
} else if let type = webpage.type, (["article"] as [String]).contains(type) {
return true
} else if let _ = largestImageRepresentation(image.representations)?.dimensions {
if webpage.instantPage == nil {
return true
}
}
}
return false
}