Private
Public Access
1
0

Organize everything into operations

This commit is contained in:
James Magahern
2018-11-13 12:29:15 -08:00
parent 7a3dee7073
commit ce7e6e7dd8
10 changed files with 354 additions and 106 deletions

View File

@@ -0,0 +1,40 @@
//
// MBIMConversationListOperation.m
// kordophoned
//
// Created by James Magahern on 11/13/18.
// Copyright © 2018 James Magahern. All rights reserved.
//
#import "MBIMConversationListOperation.h"
#import <IMCore/IMCore.h>
@implementation MBIMConversationListOperation
+ (void)load { [super load]; }
+ (NSString *)endpointName
{
return @"conversations";
}
- (void)main
{
NSArray<IMChat *> *chats = [sChatRegistry allExistingChats];
NSMutableArray *conversations = [NSMutableArray array];
for (IMChat *chat in chats) {
NSMutableDictionary *chatDict = [NSMutableDictionary dictionary];
chatDict[@"guid"] = [chat guid];
chatDict[@"displayName"] = [chat displayName];
chatDict[@"date"] = GCDWebServerFormatRFC822([chat lastFinishedMessageDate]);
[conversations addObject:chatDict];
}
GCDWebServerResponse *response = [GCDWebServerDataResponse responseWithJSONObject:conversations];
self.serverCompletionBlock(response);
}
@end