forked from TelegramMessenger/Telegram-iOS
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAttachments.m
More file actions
35 lines (27 loc) · 775 Bytes
/
Copy pathAttachments.m
File metadata and controls
35 lines (27 loc) · 775 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#import "Attachments.h"
#ifdef BUCK
#import <MTProtoKit/MTProtoKit.h>
#else
#import <MTProtoKitDynamic/MTProtoKitDynamic.h>
#endif
#import "Api.h"
id _Nullable parseAttachment(NSData * _Nonnull data) {
if (data.length < 4) {
return nil;
}
MTInputStream *inputStream = [[MTInputStream alloc] initWithData:data];
int32_t signature = [inputStream readInt32];
NSData *dataToParse = nil;
if (signature == 0x3072cfa1) {
NSData *bytes = [inputStream readBytes];
if (bytes != nil) {
dataToParse = [MTGzip decompress:bytes];
}
} else {
dataToParse = data;
}
if (dataToParse == nil) {
return nil;
}
return [Api1__Environment parseObject:dataToParse];
}