Organize everything into operations
This commit is contained in:
40
kordophone/Bridge/Operations/MBIMConversationListOperation.m
Normal file
40
kordophone/Bridge/Operations/MBIMConversationListOperation.m
Normal 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
|
||||
Reference in New Issue
Block a user