41 lines
1.0 KiB
Mathematica
41 lines
1.0 KiB
Mathematica
|
|
//
|
||
|
|
// 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
|