Encoding: need to include associated chat item guids.
Beginning to understand associated chat items (reactions, etc).
This commit is contained in:
@@ -1704,3 +1704,4 @@ extern NSURL* IMAttachmentPreviewFileURL(NSURL *attachmentURL, NSString *extensi
|
||||
- (id)initWithSerializedError_im:(struct NSDictionary *)arg1;
|
||||
@end
|
||||
|
||||
extern NSString *IMAssociatedMessageDecodeGUID(NSString* guid);
|
||||
|
||||
@@ -20,6 +20,13 @@
|
||||
chatDict[@"date"] = MBIMWebServerFormatISO8601([self lastFinishedMessageDate]);
|
||||
chatDict[@"unreadCount"] = @([self unreadMessageCount]);
|
||||
|
||||
// NOTE: -[IMChat lastMessage] != -[[IMChat chatItems] lastMessage].
|
||||
// This means the messages we get back from the message list operation might be different from this here, which means we
|
||||
// can't reliably use `lastMessage.guid` as a sync anchor.
|
||||
//
|
||||
// Ideally, everything should move to use chat items instead of messages so we can handle associated message items (reactions).
|
||||
// When that happens, we should use `lastFinishedMessageItem` here instead of `lastMessage`, and avoid the db hit.
|
||||
//
|
||||
IMMessage *lastMessage = [self lastMessage];
|
||||
if (lastMessage) {
|
||||
NSString *lastMessagePreview = [lastMessage descriptionForPurpose:IMMessageDescriptionConversationList];
|
||||
|
||||
@@ -9,6 +9,40 @@
|
||||
#import "IMMessageItem+Encoded.h"
|
||||
#import "MBIMHTTPUtilities.h"
|
||||
|
||||
static NSString* IMAssociatedMessageTypeValue(IMAssociatedMessageType type) {
|
||||
switch (type) {
|
||||
case IMAssociatedMessageTypeAcknowledgmentHeart:
|
||||
return @"heart";
|
||||
case IMAssociatedMessageTypeAcknowledgmentThumbsUp:
|
||||
return @"thumbsUp";
|
||||
case IMAssociatedMessageTypeAcknowledgmentThumbsDown:
|
||||
return @"thumbsDown";
|
||||
case IMAssociatedMessageTypeAcknowledgmentHa:
|
||||
return @"ha";
|
||||
case IMAssociatedMessageTypeAcknowledgmentExclamation:
|
||||
return @"exclamation";
|
||||
case IMAssociatedMessageTypeAcknowledgmentQuestionMark:
|
||||
return @"questionMark";
|
||||
|
||||
case IMAssociatedMessageTypeAcknowledgmentHeartRemoved:
|
||||
return @"removed heart";
|
||||
case IMAssociatedMessageTypeAcknowledgmentThumbsUpRemoved:
|
||||
return @"removed thumbsUp";
|
||||
case IMAssociatedMessageTypeAcknowledgmentThumbsDownRemoved:
|
||||
return @"removed thumbsDown";
|
||||
case IMAssociatedMessageTypeAcknowledgmentHaRemoved:
|
||||
return @"removed ha";
|
||||
case IMAssociatedMessageTypeAcknowledgmentExclamationRemoved:
|
||||
return @"removed exclamation";
|
||||
case IMAssociatedMessageTypeAcknowledgmentQuestionMarkRemoved:
|
||||
return @"removed questionMark";
|
||||
|
||||
case IMAssociatedMessageTypeUnspecified:
|
||||
default:
|
||||
return @"unknown";
|
||||
}
|
||||
}
|
||||
|
||||
@implementation IMMessage (Encoded)
|
||||
|
||||
- (NSDictionary *)mbim_dictionaryRepresentation
|
||||
@@ -19,6 +53,15 @@
|
||||
messageDict[@"sender"] = ([self isFromMe] ? nil : [[self sender] displayID]); // TODO: nil sender is still a weird way to represent this...
|
||||
messageDict[@"guid"] = [self guid];
|
||||
|
||||
if ([self associatedMessageGUID]) {
|
||||
NSString *encodedAssociatedMessageGUID = [self associatedMessageGUID];
|
||||
messageDict[@"associatedMessageGUID"] = encodedAssociatedMessageGUID;
|
||||
messageDict[@"associatedMessageType"] = IMAssociatedMessageTypeValue([self associatedMessageType]);
|
||||
|
||||
NSString *decodedAssociatedChatItemGUID = IMAssociatedMessageDecodeGUID(encodedAssociatedMessageGUID);
|
||||
if (decodedAssociatedChatItemGUID) messageDict[@"associatedChatItemGUID"] = decodedAssociatedChatItemGUID;
|
||||
}
|
||||
|
||||
if ([self fileTransferGUIDs]) {
|
||||
// Support only images right now
|
||||
NSMutableDictionary *attachmentMetadatas = [NSMutableDictionary dictionary];
|
||||
|
||||
Reference in New Issue
Block a user