Private
Public Access
1
0
Files
Kordophone/kordophone/Bridge/Operations/MBIMConversationListOperation.m
2018-11-13 12:29:15 -08:00

41 lines
1.0 KiB
Objective-C

//
// 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