Skip to content
This repository has been archived by the owner on May 10, 2019. It is now read-only.

Commit

Permalink
no message
Browse files Browse the repository at this point in the history
  • Loading branch information
petertechstories committed Jul 23, 2017
1 parent f7a711d commit 9bd7c52
Show file tree
Hide file tree
Showing 442 changed files with 31,392 additions and 26,099 deletions.
7,731 changes: 0 additions & 7,731 deletions LegacyDatabase/ApiLayer69.h

This file was deleted.

7,746 changes: 7,746 additions & 0 deletions LegacyDatabase/ApiLayer70.h

Large diffs are not rendered by default.

21,752 changes: 10,923 additions & 10,829 deletions LegacyDatabase/ApiLayer69.m → LegacyDatabase/ApiLayer70.m

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion LegacyDatabase/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>4.1.1</string>
<string>4.2</string>
<key>CFBundleVersion</key>
<string>$(CURRENT_PROJECT_VERSION)</string>
<key>NSPrincipalClass</key>
Expand Down
2 changes: 1 addition & 1 deletion LegacyDatabase/LegacyDatabase.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ FOUNDATION_EXPORT const unsigned char LegacyDatabaseVersionString[];
#import <LegacyDatabase/PSLMDBTable.h>
#import <LegacyDatabase/TGMemoryCache.h>
#import <LegacyDatabase/TGPoolWithTimeout.h>
#import <LegacyDatabase/ApiLayer69.h>
#import <LegacyDatabase/ApiLayer70.h>

#import <LegacyDatabase/TGPeerId.h>
#import <LegacyDatabase/TGContactModel.h>
Expand Down
10 changes: 5 additions & 5 deletions LegacyDatabase/TGChatListAvatarSignal.m
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ @implementation TGChatListAvatarSignal
+ (SSignal *)remoteChatListAvatarWithContext:(TGShareContext *)context location:(TGFileLocation *)location imageSize:(CGSize)imageSize
{
NSString *key = [NSString stringWithFormat:@"%@-%d", [location description], (int)imageSize.width];
Api69_InputFileLocation_inputFileLocation *inputFileLocation = [Api69_InputFileLocation inputFileLocationWithVolumeId:@(location.volumeId) localId:@(location.localId) secret:@(location.secret)];
return [[context datacenter:location.datacenterId function:[Api69 upload_getFileWithLocation:inputFileLocation offset:@(0) limit:@(1024 * 1024)]] map:^id(Api69_upload_File *result)
Api70_InputFileLocation_inputFileLocation *inputFileLocation = [Api70_InputFileLocation inputFileLocationWithVolumeId:@(location.volumeId) localId:@(location.localId) secret:@(location.secret)];
return [[context datacenter:location.datacenterId function:[Api70 upload_getFileWithLocation:inputFileLocation offset:@(0) limit:@(1024 * 1024)]] map:^id(Api70_upload_File *result)
{
if ([result isKindOfClass:[Api69_upload_File_upload_file class]]) {
[context.persistentCache setValue:((Api69_upload_File_upload_file *)result).bytes forKey:[[location description] dataUsingEncoding:NSUTF8StringEncoding]];
if ([result isKindOfClass:[Api70_upload_File_upload_file class]]) {
[context.persistentCache setValue:((Api70_upload_File_upload_file *)result).bytes forKey:[[location description] dataUsingEncoding:NSUTF8StringEncoding]];

OSSpinLockLock(&imageDataLock);
UIImage *image = [[UIImage alloc] initWithData:((Api69_upload_File_upload_file *)result).bytes];
UIImage *image = [[UIImage alloc] initWithData:((Api70_upload_File_upload_file *)result).bytes];
OSSpinLockUnlock(&imageDataLock);

image = TGRoundImage(image, imageSize);
Expand Down
2 changes: 1 addition & 1 deletion LegacyDatabase/TGChatListSignal.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

@interface TGChatListSignal : NSObject

+ (TGUserModel *)userModelWithApiUser:(Api69_User *)user;
+ (TGUserModel *)userModelWithApiUser:(Api70_User *)user;

+ (SSignal *)remoteChatListWithContext:(TGShareContext *)context;

Expand Down
112 changes: 56 additions & 56 deletions LegacyDatabase/TGChatListSignal.m
Original file line number Diff line number Diff line change
Expand Up @@ -4,31 +4,31 @@

@implementation TGChatListSignal

+ (TGFileLocation *)fileLocationWithApiLocation:(Api69_FileLocation *)location
+ (TGFileLocation *)fileLocationWithApiLocation:(Api70_FileLocation *)location
{
if ([location isKindOfClass:[Api69_FileLocation_fileLocation class]])
if ([location isKindOfClass:[Api70_FileLocation_fileLocation class]])
{
Api69_FileLocation_fileLocation *concreteLocation = (Api69_FileLocation_fileLocation *)location;
Api70_FileLocation_fileLocation *concreteLocation = (Api70_FileLocation_fileLocation *)location;
return [[TGFileLocation alloc] initWithDatacenterId:[concreteLocation.dcId intValue] volumeId:[[concreteLocation volumeId] longLongValue] localId:[concreteLocation.localId intValue] secret:[concreteLocation.secret longLongValue]];
}
return nil;
}

+ (TGFileLocation *)fileLocationWithUserProfilePhoto:(Api69_UserProfilePhoto *)photo
+ (TGFileLocation *)fileLocationWithUserProfilePhoto:(Api70_UserProfilePhoto *)photo
{
if ([photo isKindOfClass:[Api69_UserProfilePhoto_userProfilePhoto class]])
if ([photo isKindOfClass:[Api70_UserProfilePhoto_userProfilePhoto class]])
{
Api69_UserProfilePhoto_userProfilePhoto *concretePhoto = (Api69_UserProfilePhoto_userProfilePhoto *)photo;
Api70_UserProfilePhoto_userProfilePhoto *concretePhoto = (Api70_UserProfilePhoto_userProfilePhoto *)photo;
return [self fileLocationWithApiLocation:concretePhoto.photoSmall];
}
return nil;
}

+ (TGUserModel *)userModelWithApiUser:(Api69_User *)user
+ (TGUserModel *)userModelWithApiUser:(Api70_User *)user
{
if ([user isKindOfClass:[Api69_User_user class]])
if ([user isKindOfClass:[Api70_User_user class]])
{
Api69_User_user *concreteUser = (Api69_User_user *)user;
Api70_User_user *concreteUser = (Api70_User_user *)user;

bool isSelf = [concreteUser.flags intValue] & (1 << 10);

Expand All @@ -38,44 +38,44 @@ + (TGUserModel *)userModelWithApiUser:(Api69_User *)user
return nil;
}

+ (SSignal *)remoteChatListWithContext:(TGShareContext *)context offsetDate:(int32_t)offsetDate offsetPeer:(Api69_InputPeer *)offsetPeer offsetMessageId:(int32_t)offsetMessageId limit:(NSUInteger)limit
+ (SSignal *)remoteChatListWithContext:(TGShareContext *)context offsetDate:(int32_t)offsetDate offsetPeer:(Api70_InputPeer *)offsetPeer offsetMessageId:(int32_t)offsetMessageId limit:(NSUInteger)limit
{
return [[context function:[Api69 messages_getDialogsWithFlags:@(0) offsetDate:@(offsetDate) offsetId:@(offsetMessageId) offsetPeer:offsetPeer limit:@(limit)]] map:^id(Api69_messages_Dialogs *dialogs)
return [[context function:[Api70 messages_getDialogsWithFlags:@(0) offsetDate:@(offsetDate) offsetId:@(offsetMessageId) offsetPeer:offsetPeer limit:@(limit)]] map:^id(Api70_messages_Dialogs *dialogs)
{
NSMutableArray *chatModels = [[NSMutableArray alloc] init];
NSMutableArray *userModels = [[NSMutableArray alloc] init];

for (Api69_Dialog *dialog in dialogs.dialogs)
for (Api70_Dialog *dialog in dialogs.dialogs)
{
if ([dialog.peer isKindOfClass:[Api69_Peer_peerChat class]])
if ([dialog.peer isKindOfClass:[Api70_Peer_peerChat class]])
{
Api69_Peer_peerChat *peerChat = (Api69_Peer_peerChat *)dialog.peer;
for (Api69_Chat *chat in dialogs.chats)
Api70_Peer_peerChat *peerChat = (Api70_Peer_peerChat *)dialog.peer;
for (Api70_Chat *chat in dialogs.chats)
{
if ([chat.pid isEqual:peerChat.chatId])
{
if ([chat isKindOfClass:[Api69_Chat_chat class]])
if ([chat isKindOfClass:[Api70_Chat_chat class]])
{
Api69_Chat_chat *concreteChat = (Api69_Chat_chat *)chat;
Api70_Chat_chat *concreteChat = (Api70_Chat_chat *)chat;
if (([concreteChat.flags intValue] & (1 << 5)) != 0) {
continue;
}

TGFileLocation *avatarLocation = nil;
if ([concreteChat.photo isKindOfClass:[Api69_ChatPhoto_chatPhoto class]])
if ([concreteChat.photo isKindOfClass:[Api70_ChatPhoto_chatPhoto class]])
{
avatarLocation = [self fileLocationWithApiLocation:((Api69_ChatPhoto_chatPhoto *)concreteChat.photo).photoSmall];
avatarLocation = [self fileLocationWithApiLocation:((Api70_ChatPhoto_chatPhoto *)concreteChat.photo).photoSmall];
}
[chatModels addObject:[[TGGroupChatModel alloc] initWithGroupId:[concreteChat.pid intValue] title:concreteChat.title avatarLocation:avatarLocation]];
}
break;
}
}
}
else if ([dialog.peer isKindOfClass:[Api69_Peer_peerUser class]])
else if ([dialog.peer isKindOfClass:[Api70_Peer_peerUser class]])
{
Api69_Peer_peerUser *peerUser = (Api69_Peer_peerUser *)dialog.peer;
for (Api69_User *user in dialogs.users)
Api70_Peer_peerUser *peerUser = (Api70_Peer_peerUser *)dialog.peer;
for (Api70_User *user in dialogs.users)
{
if ([user.pid isEqual:peerUser.userId])
{
Expand All @@ -89,20 +89,20 @@ + (SSignal *)remoteChatListWithContext:(TGShareContext *)context offsetDate:(int
}
}
}
else if ([dialog.peer isKindOfClass:[Api69_Peer_peerChannel class]])
else if ([dialog.peer isKindOfClass:[Api70_Peer_peerChannel class]])
{
Api69_Peer_peerChannel *peerChannel = (Api69_Peer_peerChannel *)dialog.peer;
for (Api69_Chat *chat in dialogs.chats)
Api70_Peer_peerChannel *peerChannel = (Api70_Peer_peerChannel *)dialog.peer;
for (Api70_Chat *chat in dialogs.chats)
{
if ([chat.pid isEqual:peerChannel.channelId])
{
if ([chat isKindOfClass:[Api69_Chat_channel class]])
if ([chat isKindOfClass:[Api70_Chat_channel class]])
{
Api69_Chat_channel *concreteChannel = (Api69_Chat_channel *)chat;
Api70_Chat_channel *concreteChannel = (Api70_Chat_channel *)chat;
TGFileLocation *avatarLocation = nil;
if ([concreteChannel.photo isKindOfClass:[Api69_ChatPhoto_chatPhoto class]])
if ([concreteChannel.photo isKindOfClass:[Api70_ChatPhoto_chatPhoto class]])
{
avatarLocation = [self fileLocationWithApiLocation:((Api69_ChatPhoto_chatPhoto *)concreteChannel.photo).photoSmall];
avatarLocation = [self fileLocationWithApiLocation:((Api70_ChatPhoto_chatPhoto *)concreteChannel.photo).photoSmall];
}
NSInteger flags = concreteChannel.flags.intValue;
bool isGroup = (flags & (1 << 8));
Expand All @@ -124,57 +124,57 @@ + (SSignal *)remoteChatListWithContext:(TGShareContext *)context offsetDate:(int
NSDictionary *nextRequestOffset = @{};

if (dialogs.dialogs.count != 0) {
Api69_Dialog *lastDialog = dialogs.dialogs.lastObject;
Api70_Dialog *lastDialog = dialogs.dialogs.lastObject;
int32_t peerId = 0;
if ([lastDialog.peer isKindOfClass:[Api69_Peer_peerUser class]]) {
peerId = [((Api69_Peer_peerUser *)lastDialog.peer).userId intValue];
} else if ([lastDialog.peer isKindOfClass:[Api69_Peer_peerChat class]]) {
peerId = [((Api69_Peer_peerChat *)lastDialog.peer).chatId intValue];
} else if ([lastDialog.peer isKindOfClass:[Api69_Peer_peerChannel class]]) {
peerId = [((Api69_Peer_peerChannel *)lastDialog.peer).channelId intValue];
if ([lastDialog.peer isKindOfClass:[Api70_Peer_peerUser class]]) {
peerId = [((Api70_Peer_peerUser *)lastDialog.peer).userId intValue];
} else if ([lastDialog.peer isKindOfClass:[Api70_Peer_peerChat class]]) {
peerId = [((Api70_Peer_peerChat *)lastDialog.peer).chatId intValue];
} else if ([lastDialog.peer isKindOfClass:[Api70_Peer_peerChannel class]]) {
peerId = [((Api70_Peer_peerChannel *)lastDialog.peer).channelId intValue];
}

if (peerId != 0) {
for (Api69_Message *message in dialogs.messages) {
if ([message isKindOfClass:[Api69_Message_message class]]) {
Api69_Message_message *concreteMessage = (Api69_Message_message *)message;
for (Api70_Message *message in dialogs.messages) {
if ([message isKindOfClass:[Api70_Message_message class]]) {
Api70_Message_message *concreteMessage = (Api70_Message_message *)message;

int32_t messagePeerId = 0;
Api69_InputPeer *messagePeer = [Api69_InputPeer inputPeerEmpty];
Api70_InputPeer *messagePeer = [Api70_InputPeer inputPeerEmpty];

if ([concreteMessage.toId isKindOfClass:[Api69_Peer_peerUser class]]) {
if ([concreteMessage.toId isKindOfClass:[Api70_Peer_peerUser class]]) {
if (([concreteMessage.flags intValue] & 2) != 0) {
messagePeerId = [((Api69_Peer_peerUser *)concreteMessage.toId).userId intValue];
messagePeerId = [((Api70_Peer_peerUser *)concreteMessage.toId).userId intValue];
} else {
messagePeerId = [concreteMessage.fromId intValue];
}
} else if ([concreteMessage.toId isKindOfClass:[Api69_Peer_peerChat class]]) {
messagePeerId = [((Api69_Peer_peerChat *)concreteMessage.toId).chatId intValue];
} else if ([concreteMessage.toId isKindOfClass:[Api69_Peer_peerChannel class]]) {
messagePeerId = [((Api69_Peer_peerChannel *)concreteMessage.toId).channelId intValue];
} else if ([concreteMessage.toId isKindOfClass:[Api70_Peer_peerChat class]]) {
messagePeerId = [((Api70_Peer_peerChat *)concreteMessage.toId).chatId intValue];
} else if ([concreteMessage.toId isKindOfClass:[Api70_Peer_peerChannel class]]) {
messagePeerId = [((Api70_Peer_peerChannel *)concreteMessage.toId).channelId intValue];
}

if (messagePeerId == peerId) {
if (nextRequestOffset.count == 0) {
nextRequestOffset = @{@"offsetDate": @([concreteMessage.date intValue]), @"offsetPeer": messagePeer, @"offsetMessageId": @([concreteMessage.pid intValue])};
}
}
} else if ([message isKindOfClass:[Api69_Message_messageService class]]) {
Api69_Message_messageService *concreteMessage = (Api69_Message_messageService *)message;
} else if ([message isKindOfClass:[Api70_Message_messageService class]]) {
Api70_Message_messageService *concreteMessage = (Api70_Message_messageService *)message;

int32_t messagePeerId = 0;
Api69_InputPeer *messagePeer = [Api69_InputPeer inputPeerEmpty];
Api70_InputPeer *messagePeer = [Api70_InputPeer inputPeerEmpty];

if ([concreteMessage.toId isKindOfClass:[Api69_Peer_peerUser class]]) {
if ([concreteMessage.toId isKindOfClass:[Api70_Peer_peerUser class]]) {
if (([concreteMessage.flags intValue] & 2) != 0) {
messagePeerId = [((Api69_Peer_peerUser *)concreteMessage.toId).userId intValue];
messagePeerId = [((Api70_Peer_peerUser *)concreteMessage.toId).userId intValue];
} else {
messagePeerId = [concreteMessage.fromId intValue];
}
} else if ([concreteMessage.toId isKindOfClass:[Api69_Peer_peerChat class]]) {
messagePeerId = [((Api69_Peer_peerChat *)concreteMessage.toId).chatId intValue];
} else if ([concreteMessage.toId isKindOfClass:[Api69_Peer_peerChannel class]]) {
messagePeerId = [((Api69_Peer_peerChannel *)concreteMessage.toId).channelId intValue];
} else if ([concreteMessage.toId isKindOfClass:[Api70_Peer_peerChat class]]) {
messagePeerId = [((Api70_Peer_peerChat *)concreteMessage.toId).chatId intValue];
} else if ([concreteMessage.toId isKindOfClass:[Api70_Peer_peerChannel class]]) {
messagePeerId = [((Api70_Peer_peerChannel *)concreteMessage.toId).channelId intValue];
}

if (messagePeerId == peerId) {
Expand All @@ -193,7 +193,7 @@ + (SSignal *)remoteChatListWithContext:(TGShareContext *)context offsetDate:(int

+ (SSignal *)remoteChatListWithContext:(TGShareContext *)context
{
return [[self remoteChatListWithContext:context offsetDate:0 offsetPeer:[Api69_InputPeer inputPeerEmpty] offsetMessageId:0 limit:32] mapToSignal:^SSignal *(NSDictionary *chats) {
return [[self remoteChatListWithContext:context offsetDate:0 offsetPeer:[Api70_InputPeer inputPeerEmpty] offsetMessageId:0 limit:32] mapToSignal:^SSignal *(NSDictionary *chats) {
SSignal *nextSignal = [SSignal complete];
NSDictionary *nextRequestOffset = chats[@"nextRequestOffset"];
if (nextRequestOffset.count != 0) {
Expand Down
4 changes: 2 additions & 2 deletions LegacyDatabase/TGDatacenterConnectionContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#import <MTProtoKitDynamic/MTProto.h>
#import <MTProtoKitDynamic/MTRequestMessageService.h>
#import <SSignalKit/SSignalKit.h>
#import "ApiLayer69.h"
#import "ApiLayer70.h"

@interface TGDatacenterConnectionContext : NSObject

Expand All @@ -15,7 +15,7 @@

- (instancetype)initWithDatacenterId:(NSInteger)datacenterId mtContext:(MTContext *)mtContext mtProto:(MTProto *)mtProto mtRequestService:(MTRequestMessageService *)mtRequestService;

- (SSignal *)function:(Api69_FunctionContext *)functionContext;
- (SSignal *)function:(Api70_FunctionContext *)functionContext;

@end

Expand Down
2 changes: 1 addition & 1 deletion LegacyDatabase/TGDatacenterConnectionContext.m
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ - (void)dealloc
[_mtProto stop];
}

- (SSignal *)function:(Api69_FunctionContext *)functionContext
- (SSignal *)function:(Api70_FunctionContext *)functionContext
{
__weak TGDatacenterConnectionContext *weakSelf = self;
return [[SSignal alloc] initWithGenerator:^id<SDisposable> (SSubscriber *subscriber)
Expand Down
10 changes: 5 additions & 5 deletions LegacyDatabase/TGSearchSignals.m
Original file line number Diff line number Diff line change
Expand Up @@ -148,22 +148,22 @@ + (SSignal *)searchUsersWithContext:(TGShareContext *)context query:(NSString *)
if (query.length < 5)
return [SSignal single:@{@"chats": @[], @"users": @[]}];

return [[context function:[Api69 contacts_searchWithQ:query limit:@(100)]] map:^id(Api69_contacts_Found *result)
return [[context function:[Api70 contacts_searchWithQ:query limit:@(100)]] map:^id(Api70_contacts_Found *result)
{
NSMutableArray *chatModels = [[NSMutableArray alloc] init];
NSMutableArray *userModels = [[NSMutableArray alloc] init];

for (Api69_User *user in result.users)
for (Api70_User *user in result.users)
{
TGUserModel *userModel = [TGChatListSignal userModelWithApiUser:user];
if (userModel != nil)
[userModels addObject:userModel];
}

for (Api69_Peer *peerFound in result.results)
for (Api70_Peer *peerFound in result.results)
{
if ([peerFound isKindOfClass:[Api69_Peer_peerUser class]]) {
int32_t userId = [((Api69_Peer_peerUser *)peerFound).userId intValue];
if ([peerFound isKindOfClass:[Api70_Peer_peerUser class]]) {
int32_t userId = [((Api70_Peer_peerUser *)peerFound).userId intValue];

for (TGUserModel *userModel in userModels)
{
Expand Down
Loading

0 comments on commit 9bd7c52

Please sign in to comment.