From 0d9c4aafe7c992fe4e5537494afca751727d4706 Mon Sep 17 00:00:00 2001
From: Ali <>
Date: Fri, 19 Feb 2021 20:27:56 +0400
Subject: [PATCH] Fix notification service and content
---
Telegram/BUILD | 13 ++++-
Telegram/NotificationContent/Info.plist | 41 ---------------
.../NotificationContent-Bridging-Header.h | 4 --
Telegram/NotificationContent/main.m | 0
.../NotificationServiceObjC/BUILD | 1 +
.../NotificationServiceObjC/Sources/Api.h | 10 ++++
.../NotificationServiceObjC/Sources/Api.m | 52 +++++++++++++++++++
.../Sources/FetchImage.m | 30 ++---------
8 files changed, 78 insertions(+), 73 deletions(-)
delete mode 100644 Telegram/NotificationContent/Info.plist
delete mode 100644 Telegram/NotificationContent/NotificationContent-Bridging-Header.h
create mode 100644 Telegram/NotificationContent/main.m
diff --git a/Telegram/BUILD b/Telegram/BUILD
index d9af42bf74..5fabcd142c 100644
--- a/Telegram/BUILD
+++ b/Telegram/BUILD
@@ -1125,6 +1125,16 @@ plist_fragment(
)
)
+objc_library(
+ name = "NotificationContentExtensionLink",
+ srcs = [
+ "NotificationContent/main.m",
+ ],
+ sdk_frameworks = [
+ "UserNotificationsUI",
+ ],
+)
+
swift_library(
name = "NotificationContentExtensionLib",
module_name = "NotificationContentExtensionLib",
@@ -1132,7 +1142,8 @@ swift_library(
"NotificationContent/**/*.swift",
]),
deps = [
- "//submodules/TelegramUI:TelegramUI"
+ "//submodules/TelegramUI:TelegramUI",
+ ":NotificationContentExtensionLink",
],
)
diff --git a/Telegram/NotificationContent/Info.plist b/Telegram/NotificationContent/Info.plist
deleted file mode 100644
index cedf175e70..0000000000
--- a/Telegram/NotificationContent/Info.plist
+++ /dev/null
@@ -1,41 +0,0 @@
-
-
-
-
- CFBundleDevelopmentRegion
- $(DEVELOPMENT_LANGUAGE)
- CFBundleDisplayName
- NotificationContent
- CFBundleExecutable
- $(EXECUTABLE_NAME)
- CFBundleIdentifier
- $(PRODUCT_BUNDLE_IDENTIFIER)
- CFBundleInfoDictionaryVersion
- 6.0
- CFBundleName
- $(PRODUCT_NAME)
- CFBundlePackageType
- XPC!
- CFBundleShortVersionString
- $(PRODUCT_BUNDLE_SHORT_VERSION)
- CFBundleVersion
- ${BUILD_NUMBER}
- NSExtension
-
- NSExtensionAttributes
-
- UNNotificationExtensionCategory
-
- withReplyMedia
- withMuteMedia
-
- UNNotificationExtensionInitialContentSizeRatio
- 0.0001
-
- NSExtensionPointIdentifier
- com.apple.usernotifications.content-extension
- NSExtensionPrincipalClass
- NotificationViewController
-
-
-
diff --git a/Telegram/NotificationContent/NotificationContent-Bridging-Header.h b/Telegram/NotificationContent/NotificationContent-Bridging-Header.h
deleted file mode 100644
index aa1e3a7d15..0000000000
--- a/Telegram/NotificationContent/NotificationContent-Bridging-Header.h
+++ /dev/null
@@ -1,4 +0,0 @@
-#ifndef Share_Bridging_Header_h
-#define Share_Bridging_Header_h
-
-#endif
diff --git a/Telegram/NotificationContent/main.m b/Telegram/NotificationContent/main.m
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/Telegram/NotificationService/NotificationServiceObjC/BUILD b/Telegram/NotificationService/NotificationServiceObjC/BUILD
index 4a3ea0828a..f3e0d1c862 100644
--- a/Telegram/NotificationService/NotificationServiceObjC/BUILD
+++ b/Telegram/NotificationService/NotificationServiceObjC/BUILD
@@ -17,6 +17,7 @@ objc_library(
"//submodules/BuildConfig:BuildConfig",
"//submodules/MtProtoKit:MtProtoKit",
"//submodules/NotificationsPresentationData:NotificationsPresentationData",
+ "//submodules/OpenSSLEncryptionProvider:OpenSSLEncryptionProvider",
],
sdk_frameworks = [
"Foundation",
diff --git a/Telegram/NotificationService/NotificationServiceObjC/Sources/Api.h b/Telegram/NotificationService/NotificationServiceObjC/Sources/Api.h
index dd47051a4a..0e0bee73d3 100644
--- a/Telegram/NotificationService/NotificationServiceObjC/Sources/Api.h
+++ b/Telegram/NotificationService/NotificationServiceObjC/Sources/Api.h
@@ -13,6 +13,7 @@
@class Api1_PhotoSize_photoSize;
@class Api1_PhotoSize_photoCachedSize;
@class Api1_PhotoSize_photoStrippedSize;
+@class Api1_PhotoSize_photoSizeProgressive;
@class Api1_FileLocation;
@class Api1_FileLocation_fileLocationToBeDeprecated;
@@ -96,6 +97,7 @@
+ (Api1_PhotoSize_photoSize *)photoSizeWithType:(NSString *)type location:(Api1_FileLocation *)location w:(NSNumber *)w h:(NSNumber *)h size:(NSNumber *)size;
+ (Api1_PhotoSize_photoCachedSize *)photoCachedSizeWithType:(NSString *)type location:(Api1_FileLocation *)location w:(NSNumber *)w h:(NSNumber *)h bytes:(NSData *)bytes;
+ (Api1_PhotoSize_photoStrippedSize *)photoStrippedSizeWithType:(NSString *)type bytes:(NSData *)bytes;
++ (Api1_PhotoSize_photoSizeProgressive *)photoSizeProgressiveWithType:(NSString *)type location:(Api1_FileLocation *)location w:(NSNumber *)w h:(NSNumber *)h sizes:(NSArray *)sizes;
@end
@@ -127,6 +129,14 @@
@end
+@interface Api1_PhotoSize_photoSizeProgressive : Api1_PhotoSize
+
+@property (nonatomic, strong) Api1_FileLocation * location;
+@property (nonatomic, strong) NSNumber * w;
+@property (nonatomic, strong) NSNumber * h;
+@property (nonatomic, strong) NSArray * sizes;
+
+@end
@interface Api1_FileLocation : NSObject
diff --git a/Telegram/NotificationService/NotificationServiceObjC/Sources/Api.m b/Telegram/NotificationService/NotificationServiceObjC/Sources/Api.m
index baf8190911..d0a05b9b5f 100644
--- a/Telegram/NotificationService/NotificationServiceObjC/Sources/Api.m
+++ b/Telegram/NotificationService/NotificationServiceObjC/Sources/Api.m
@@ -422,6 +422,33 @@ static const char *Api1__Serializer_Key = "Api1__Serializer";
return nil;
return [Api1_PhotoSize photoSizeWithType:type location:location w:w h:h size:size];
} copy];
+ parsers[@((int32_t)0x5aa86a51)] = [^id (NSData *_data, NSUInteger* _offset, __unused id metaInfo)
+ {
+ NSString * type = nil;
+ if ((type = [Api1__Environment parseObject:_data offset:_offset implicitSignature:(int32_t)0xb5286e24 metaInfo:nil]) == nil)
+ return nil;
+ Api1_FileLocation * location = nil;
+ int32_t location_signature = 0; [_data getBytes:(void *)&location_signature range:NSMakeRange(*_offset, 4)]; *_offset += 4;
+ if ((location = [Api1__Environment parseObject:_data offset:_offset implicitSignature:location_signature metaInfo:nil]) == nil)
+ return nil;
+ NSNumber * w = nil;
+ if ((w = [Api1__Environment parseObject:_data offset:_offset implicitSignature:(int32_t)0xa8509bda metaInfo:nil]) == nil)
+ return nil;
+ NSNumber * h = nil;
+ if ((h = [Api1__Environment parseObject:_data offset:_offset implicitSignature:(int32_t)0xa8509bda metaInfo:nil]) == nil)
+ return nil;
+
+ NSMutableArray *sizes = [[NSMutableArray alloc] init];
+ *_offset += 4;
+ int32_t count = 0; [_data getBytes:(void *)&count range:NSMakeRange(*_offset, 4)]; *_offset += 4;
+
+ for (int32_t i = 0; i < count; i++) {
+ int32_t value = 0; [_data getBytes:(void *)&value range:NSMakeRange(*_offset, 4)]; *_offset += 4;
+ [sizes addObject:@(value)];
+ }
+
+ return [Api1_PhotoSize photoSizeProgressiveWithType:type location:location w:w h:h sizes:sizes];
+ } copy];
parsers[@((int32_t)0xe9a734fa)] = [^id (NSData *_data, NSUInteger* _offset, __unused id metaInfo)
{
NSString * type = nil;
@@ -1079,6 +1106,15 @@ id sizes_result = [Api1__Serializer addSerializerToObject:sizes_copy serializer:
return _object;
}
++ (Api1_PhotoSize_photoSizeProgressive *)photoSizeProgressiveWithType:(NSString *)type location:(Api1_FileLocation *)location w:(NSNumber *)w h:(NSNumber *)h sizes:(NSArray *)sizes {
+ Api1_PhotoSize_photoSizeProgressive *_object = [[Api1_PhotoSize_photoSizeProgressive alloc] init];
+ _object.type = [Api1__Serializer addSerializerToObject:[type copy] serializer:[[Api1_BuiltinSerializer_String alloc] init]];
+ _object.location = location;
+ _object.w = [Api1__Serializer addSerializerToObject:[[Api1__Number alloc] initWithNumber:w] serializer:[[Api1_BuiltinSerializer_Int alloc] init]];
+ _object.h = [Api1__Serializer addSerializerToObject:[[Api1__Number alloc] initWithNumber:h] serializer:[[Api1_BuiltinSerializer_Int alloc] init]];
+ _object.sizes = sizes;
+ return _object;
+}
@end
@@ -1197,7 +1233,23 @@ id sizes_result = [Api1__Serializer addSerializerToObject:sizes_copy serializer:
@end
+@implementation Api1_PhotoSize_photoSizeProgressive : Api1_PhotoSize
+- (instancetype)init
+{
+ self = [super init];
+ if (self != nil)
+ {
+ }
+ return self;
+}
+
+- (NSString *)description
+{
+ return [[NSString alloc] initWithFormat:@"(photoSizeProgressive type:%d location:%@ w:%@ h:%@ sizes:%@)", (int)[self.type length], self.location, self.w, self.h, self.sizes];
+}
+
+@end
@interface Api1_FileLocation ()
diff --git a/Telegram/NotificationService/NotificationServiceObjC/Sources/FetchImage.m b/Telegram/NotificationService/NotificationServiceObjC/Sources/FetchImage.m
index 58a85bdce1..f8713fa2c0 100644
--- a/Telegram/NotificationService/NotificationServiceObjC/Sources/FetchImage.m
+++ b/Telegram/NotificationService/NotificationServiceObjC/Sources/FetchImage.m
@@ -1,34 +1,10 @@
#import "FetchImage.h"
-#import
-#import
+#import
+#import
#import "Serialization.h"
-@interface EmptyEncryptionProvider: NSObject
-
-@end
-
-@implementation EmptyEncryptionProvider
-
-- (id)createBignumContext {
- return nil;
-}
-
-- (NSData * _Nullable)rsaEncryptWithPublicKey:(NSString *)publicKey data:(NSData *)data {
- return nil;
-}
-
-- (NSData * _Nullable)rsaEncryptPKCS1OAEPWithPublicKey:(NSString *)publicKey data:(NSData *)data {
- return nil;
-}
-
-- (id)parseRSAPublicKey:(NSString *)publicKey {
- return nil;
-}
-
-@end
-
@interface InMemoryKeychain : NSObject {
NSMutableDictionary *_dict;
}
@@ -108,7 +84,7 @@ dispatch_block_t fetchImage(BuildConfig *buildConfig, AccountProxyConnection * _
apiEnvironment = [apiEnvironment withUpdatedSocksProxySettings:[[MTSocksProxySettings alloc] initWithIp:proxyConnection.host port:(uint16_t)proxyConnection.port username:proxyConnection.username password:proxyConnection.password secret:proxyConnection.secret]];
}
- MTContext *context = [[MTContext alloc] initWithSerialization:serialization encryptionProvider:[[EmptyEncryptionProvider alloc] init] apiEnvironment:apiEnvironment isTestingEnvironment:account.isTestingEnvironment useTempAuthKeys:true];
+ MTContext *context = [[MTContext alloc] initWithSerialization:serialization encryptionProvider:[[OpenSSLEncryptionProvider alloc] init] apiEnvironment:apiEnvironment isTestingEnvironment:account.isTestingEnvironment useTempAuthKeys:true];
context.tempKeyExpiration = 10 * 60 * 60;
NSDictionary *seedAddressList = @{};