2018-11-13 12:29:15 -08:00
|
|
|
//
|
|
|
|
|
// MBIMConversationListOperation.m
|
|
|
|
|
// kordophoned
|
|
|
|
|
//
|
|
|
|
|
// Created by James Magahern on 11/13/18.
|
|
|
|
|
// Copyright © 2018 James Magahern. All rights reserved.
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
#import "MBIMConversationListOperation.h"
|
2018-11-16 01:30:38 -08:00
|
|
|
#import "MBIMHTTPUtilities.h"
|
2018-11-20 19:57:35 -07:00
|
|
|
#import "IMChat+Encoded.h"
|
2018-11-13 12:29:15 -08:00
|
|
|
|
2019-12-16 17:29:53 -08:00
|
|
|
#import "IMCore_ClassDump.h"
|
2018-11-13 12:29:15 -08:00
|
|
|
|
|
|
|
|
@implementation MBIMConversationListOperation
|
|
|
|
|
|
|
|
|
|
+ (void)load { [super load]; }
|
|
|
|
|
|
|
|
|
|
+ (NSString *)endpointName
|
|
|
|
|
{
|
|
|
|
|
return @"conversations";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void)main
|
|
|
|
|
{
|
2018-11-21 15:51:51 -07:00
|
|
|
__block NSMutableArray *conversations = [NSMutableArray array];
|
2018-11-13 12:29:15 -08:00
|
|
|
|
2018-11-21 15:51:51 -07:00
|
|
|
dispatch_sync([[self class] sharedIMAccessQueue], ^{
|
2019-12-16 17:29:53 -08:00
|
|
|
NSArray<IMChat *> *chats = [[IMChatRegistry sharedInstance] allExistingChats];
|
2018-11-21 15:51:51 -07:00
|
|
|
for (IMChat *chat in chats) {
|
|
|
|
|
NSDictionary *chatDict = [chat mbim_dictionaryRepresentation];
|
|
|
|
|
[conversations addObject:chatDict];
|
|
|
|
|
}
|
|
|
|
|
});
|
2018-11-13 12:29:15 -08:00
|
|
|
|
2018-11-16 01:30:38 -08:00
|
|
|
MBIMJSONDataResponse *response = [MBIMJSONDataResponse responseWithJSONObject:conversations];
|
2018-11-13 12:29:15 -08:00
|
|
|
self.serverCompletionBlock(response);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@end
|