Private
Public Access
1
0

JSON encoding error for super long messages

This commit is contained in:
2024-10-24 22:27:19 -07:00
parent 030e86e205
commit 9007b4503f
3 changed files with 6 additions and 2 deletions

View File

@@ -12,8 +12,10 @@
+ (instancetype)responseWithJSONObject:(id)object
{
NSData *data = [NSJSONSerialization dataWithJSONObject:object options:0 error:NULL];
NSError *error = nil;
NSData *data = [NSJSONSerialization dataWithJSONObject:object options:0 error:&error];
if (data == nil) {
NSLog(@"JSON encoding error: %@", error);
return nil;
}

View File

@@ -22,7 +22,8 @@
IMMessage *lastMessage = [self lastMessage];
if (lastMessage) {
chatDict[@"lastMessagePreview"] = [lastMessage descriptionForPurpose:IMMessageDescriptionConversationList];
NSString *lastMessagePreview = [lastMessage descriptionForPurpose:IMMessageDescriptionConversationList];
chatDict[@"lastMessagePreview"] = [lastMessagePreview substringToIndex:MIN(128, [lastMessagePreview length])];
chatDict[@"lastMessage"] = [lastMessage mbim_dictionaryRepresentation];
}