Private
Public Access
1
0

Updates to sending and message sequences

This commit is contained in:
James Magahern
2018-11-20 19:57:35 -07:00
parent ddec4be8d6
commit 4f5cd058c5
17 changed files with 264 additions and 45 deletions

View File

@@ -0,0 +1,17 @@
//
// IMChat+Encoded.h
// kordophoned
//
// Created by James Magahern on 11/19/18.
// Copyright © 2018 James Magahern. All rights reserved.
//
#import <IMCore/IMCore.h>
NS_ASSUME_NONNULL_BEGIN
@interface IMChat (Encoded)
- (NSDictionary *)mbim_dictionaryRepresentation;
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,40 @@
//
// IMChat+Encoded.m
// kordophoned
//
// Created by James Magahern on 11/19/18.
// Copyright © 2018 James Magahern. All rights reserved.
//
#import "IMChat+Encoded.h"
#import "MBIMHTTPUtilities.h"
@implementation IMChat (Encoded)
- (NSDictionary *)mbim_dictionaryRepresentation
{
NSMutableDictionary *chatDict = [NSMutableDictionary dictionary];
chatDict[@"guid"] = [self guid];
chatDict[@"displayName"] = [self displayName];
chatDict[@"date"] = MBIMWebServerFormatISO8601([self lastFinishedMessageDate]);
chatDict[@"unreadCount"] = @([self unreadMessageCount]);
IMMessage *lastMessage = [self lastMessage];
if (lastMessage) {
chatDict[@"lastMessagePreview"] = [[lastMessage text] string];
}
NSMutableArray *participantStrings = [NSMutableArray array];
for (IMHandle *participantHandle in self.participants) {
NSString *participantString = [participantHandle displayNameForChat:self];
if (participantString) {
[participantStrings addObject:participantString];
}
}
chatDict[@"participantDisplayNames"] = participantStrings;
return chatDict;
}
@end

View File

@@ -15,7 +15,7 @@
{
NSMutableDictionary *messageDict = [NSMutableDictionary dictionary];
messageDict[@"text"] = [[self text] string];
messageDict[@"date"] = MBIMWebServerFormatRFC822([self time]);
messageDict[@"date"] = MBIMWebServerFormatISO8601([self time]);
messageDict[@"sender"] = [[self sender] displayID];
return messageDict;
@@ -29,7 +29,7 @@
{
NSMutableDictionary *messageDict = [NSMutableDictionary dictionary];
messageDict[@"text"] = [[self body] string];
messageDict[@"date"] = MBIMWebServerFormatRFC822([self time]);
messageDict[@"date"] = MBIMWebServerFormatISO8601([self time]);
messageDict[@"sender"] = [self sender];
return messageDict;