diff --git a/AVOS/AVOSCloud/UserAgent.h b/AVOS/AVOSCloud/UserAgent.h index 2a809872c..5a4887e36 100644 --- a/AVOS/AVOSCloud/UserAgent.h +++ b/AVOS/AVOSCloud/UserAgent.h @@ -1 +1 @@ -#define SDK_VERSION @"v11.4.4" +#define SDK_VERSION @"v11.4.5" diff --git a/AVOS/AVOSCloudIM/Client/AVIMClient.m b/AVOS/AVOSCloudIM/Client/AVIMClient.m index 8e75cd7e5..fcff701b4 100644 --- a/AVOS/AVOSCloudIM/Client/AVIMClient.m +++ b/AVOS/AVOSCloudIM/Client/AVIMClient.m @@ -1919,7 +1919,80 @@ - (AVIMConversationQuery *)conversationQuery - (AVIMConversation *)conversationWithKeyedConversation:(AVIMKeyedConversation *)keyedConversation { AssertNotRunInQueue(self->_internalSerialQueue); - NSString *conversationId = keyedConversation.rawDataDic[AVIMConversationKeyObjectId]; + NSString *conversationId = nil; + NSMutableDictionary *rawDataDic = [keyedConversation.rawDataDic mutableCopy]; + if (rawDataDic) { + conversationId = [NSString lc__decodingDictionary:rawDataDic key:AVIMConversationKeyObjectId]; + } else { + rawDataDic = [NSMutableDictionary dictionary]; + if (keyedConversation.conversationId) { + conversationId = keyedConversation.conversationId; + rawDataDic[AVIMConversationKeyObjectId] = conversationId; + } + if (keyedConversation.creator) { + rawDataDic[AVIMConversationKeyCreator] = keyedConversation.creator; + } + if (keyedConversation.createAt) { + rawDataDic[AVIMConversationKeyCreatedAt] = keyedConversation.createAt; + } + if (keyedConversation.updateAt) { + rawDataDic[AVIMConversationKeyUpdatedAt] = keyedConversation.updateAt; + } + if (keyedConversation.lastMessage) { + AVIMMessage *message = keyedConversation.lastMessage; + if (message.content) { + rawDataDic[AVIMConversationKeyLastMessageContent] = message.content; + } + if (message.messageId) { + rawDataDic[AVIMConversationKeyLastMessageId] = message.messageId; + } + if (message.clientId) { + rawDataDic[AVIMConversationKeyLastMessageFrom] = message.clientId; + } + if (message.sendTimestamp) { + rawDataDic[AVIMConversationKeyLastMessageTimestamp] = @(message.sendTimestamp); + } + if (message.updatedAt) { + rawDataDic[AVIMConversationKeyLastMessagePatchTimestamp] = @(message.updatedAt.timeIntervalSince1970 * 1000.0); + } + if (message.mentionAll) { + rawDataDic[AVIMConversationKeyLastMessageMentionAll] = @(message.mentionAll); + } + if (message.mentionList) { + rawDataDic[AVIMConversationKeyLastMessageMentionPids] = message.mentionList; + } + } + if (keyedConversation.name) { + rawDataDic[AVIMConversationKeyName] = keyedConversation.name; + } + if (keyedConversation.members) { + rawDataDic[AVIMConversationKeyMembers] = keyedConversation.members; + } + if (keyedConversation.attributes) { + rawDataDic[AVIMConversationKeyAttributes] = keyedConversation.attributes; + } + if (keyedConversation.uniqueId) { + rawDataDic[AVIMConversationKeyUniqueId] = keyedConversation.uniqueId; + } + if (keyedConversation.unique) { + rawDataDic[AVIMConversationKeyUnique] = @(keyedConversation.unique); + } + if (keyedConversation.transient) { + rawDataDic[AVIMConversationKeyTransient] = @(keyedConversation.transient); + } + if (keyedConversation.system) { + rawDataDic[AVIMConversationKeySystem] = @(keyedConversation.system); + } + if (keyedConversation.temporary) { + rawDataDic[AVIMConversationKeyTemporary] = @(keyedConversation.temporary); + } + if (keyedConversation.temporaryTTL) { + rawDataDic[AVIMConversationKeyTemporaryTTL] = @(keyedConversation.temporaryTTL); + } + if (keyedConversation.muted) { + rawDataDic[AVIMConversationKeyMutedMembers] = @(keyedConversation.muted); + } + } if (!conversationId) { return nil; } @@ -1927,7 +2000,7 @@ - (AVIMConversation *)conversationWithKeyedConversation:(AVIMKeyedConversation * dispatch_sync(self->_internalSerialQueue, ^{ conv = [self->_conversationManager conversationForId:conversationId]; if (!conv) { - conv = [AVIMConversation conversationWithRawJSONData:keyedConversation.rawDataDic.mutableCopy client:self]; + conv = [AVIMConversation conversationWithRawJSONData:rawDataDic client:self]; if (conv) { [self->_conversationManager insertConversation:conv]; } diff --git a/AVOS/AVOSCloudIM/Conversation/AVIMConversation.m b/AVOS/AVOSCloudIM/Conversation/AVIMConversation.m index 0d6614b91..ce552490d 100644 --- a/AVOS/AVOSCloudIM/Conversation/AVIMConversation.m +++ b/AVOS/AVOSCloudIM/Conversation/AVIMConversation.m @@ -264,20 +264,38 @@ - (NSString *)creator - (NSDate *)createAt { - __block NSString *value = nil; + __block id value = nil; [self internalSyncLock:^{ value = [NSString lc__decodingDictionary:self->_rawJSONData key:AVIMConversationKeyCreatedAt]; + if (!value) { + value = [NSDate lc__decodingDictionary:self->_rawJSONData key:AVIMConversationKeyCreatedAt]; + } }]; - return LCDateFromString(value); + if ([NSString lc__checkingType:value]) { + return LCDateFromString(value); + } else if ([NSDate lc__checkingType:value]) { + return value; + } else { + return nil; + } } - (NSDate *)updateAt { - __block NSString *value = nil; + __block id value = nil; [self internalSyncLock:^{ value = [NSString lc__decodingDictionary:self->_rawJSONData key:AVIMConversationKeyUpdatedAt]; + if (!value) { + value = [NSDate lc__decodingDictionary:self->_rawJSONData key:AVIMConversationKeyUpdatedAt]; + } }]; - return LCDateFromString(value); + if ([NSString lc__checkingType:value]) { + return LCDateFromString(value); + } else if ([NSDate lc__checkingType:value]) { + return value; + } else { + return nil; + } } - (NSString *)name @@ -337,11 +355,20 @@ - (void)removeMembers:(NSArray *)members - (BOOL)muted { - __block NSArray *value = nil; + __block id value = nil; [self internalSyncLock:^{ value = [NSArray lc__decodingDictionary:self->_rawJSONData key:AVIMConversationKeyMutedMembers].copy; + if (!value) { + value = [NSNumber lc__decodingDictionary:self->_rawJSONData key:AVIMConversationKeyMutedMembers]; + } }]; - return value ? [value containsObject:self->_clientId] : false; + if ([NSArray lc__checkingType:value]) { + return [value containsObject:self->_clientId]; + } else if ([NSNumber lc__checkingType:value]) { + return [(NSNumber *)value boolValue]; + } else { + return false; + } } - (NSDictionary *)attributes @@ -3155,6 +3182,25 @@ - (void)process_member_info_changed:(NSString *)memberId role:(NSString *)role - (AVIMKeyedConversation *)keyedConversation { AVIMKeyedConversation *keyedConversation = [AVIMKeyedConversation new]; + keyedConversation.conversationId = self.conversationId; + keyedConversation.clientId = self.clientId; + keyedConversation.creator = self.creator; + keyedConversation.createAt = self.createAt; + keyedConversation.updateAt = self.updateAt; + keyedConversation.lastMessageAt = self.lastMessageAt; + keyedConversation.lastDeliveredAt = self.lastDeliveredAt; + keyedConversation.lastReadAt = self.lastReadAt; + keyedConversation.lastMessage = self.lastMessage; + keyedConversation.name = self.name; + keyedConversation.members = self.members; + keyedConversation.attributes = self.attributes; + keyedConversation.uniqueId = self.uniqueId; + keyedConversation.unique = self.unique; + keyedConversation.transient = self.transient; + keyedConversation.system = self.system; + keyedConversation.temporary = self.temporary; + keyedConversation.temporaryTTL = self.temporaryTTL; + keyedConversation.muted = self.muted; keyedConversation.rawDataDic = self.rawJSONDataCopy; return keyedConversation; } diff --git a/AVOS/AVOSCloudIM/Conversation/AVIMKeyedConversation.m b/AVOS/AVOSCloudIM/Conversation/AVIMKeyedConversation.m index 324fc539b..09e36296b 100644 --- a/AVOS/AVOSCloudIM/Conversation/AVIMKeyedConversation.m +++ b/AVOS/AVOSCloudIM/Conversation/AVIMKeyedConversation.m @@ -15,21 +15,122 @@ - (id)initWithCoder:(NSCoder *)aDecoder { self = [super init]; if (self) { - NSString *key = NSStringFromSelector(@selector(rawDataDic)); - if ([aDecoder containsValueForKey:key]) { - self.rawDataDic = [aDecoder decodeObjectForKey:key]; - } else { - return nil; + NSString *conversationId = NSStringFromSelector(@selector(conversationId)); + if ([aDecoder containsValueForKey:conversationId]) { + self.conversationId = [aDecoder decodeObjectForKey:conversationId]; } + NSString *clientId = NSStringFromSelector(@selector(clientId)); + if ([aDecoder containsValueForKey:clientId]) { + self.clientId = [aDecoder decodeObjectForKey:clientId]; + } + NSString *creator = NSStringFromSelector(@selector(creator)); + if ([aDecoder containsValueForKey:creator]) { + self.creator = [aDecoder decodeObjectForKey:creator]; + } + NSString *createAt = NSStringFromSelector(@selector(createAt)); + if ([aDecoder containsValueForKey:createAt]) { + self.createAt = [aDecoder decodeObjectForKey:createAt]; + } + NSString *updateAt = NSStringFromSelector(@selector(updateAt)); + if ([aDecoder containsValueForKey:updateAt]) { + self.updateAt = [aDecoder decodeObjectForKey:updateAt]; + } + NSString *lastMessageAt = NSStringFromSelector(@selector(lastMessageAt)); + if ([aDecoder containsValueForKey:lastMessageAt]) { + self.lastMessageAt = [aDecoder decodeObjectForKey:lastMessageAt]; + } + NSString *lastDeliveredAt = NSStringFromSelector(@selector(lastDeliveredAt)); + if ([aDecoder containsValueForKey:lastDeliveredAt]) { + self.lastDeliveredAt = [aDecoder decodeObjectForKey:lastDeliveredAt]; + } + NSString *lastReadAt = NSStringFromSelector(@selector(lastReadAt)); + if ([aDecoder containsValueForKey:lastReadAt]) { + self.lastReadAt = [aDecoder decodeObjectForKey:lastReadAt]; + } + NSString *lastMessage = NSStringFromSelector(@selector(lastMessage)); + if ([aDecoder containsValueForKey:lastMessage]) { + self.lastMessage = [aDecoder decodeObjectForKey:lastMessage]; + } + NSString *name = NSStringFromSelector(@selector(name)); + if ([aDecoder containsValueForKey:name]) { + self.name = [aDecoder decodeObjectForKey:name]; + } + NSString *members = NSStringFromSelector(@selector(members)); + if ([aDecoder containsValueForKey:members]) { + self.members = [aDecoder decodeObjectForKey:members]; + } + NSString *attributes = NSStringFromSelector(@selector(attributes)); + if ([aDecoder containsValueForKey:attributes]) { + self.attributes = [aDecoder decodeObjectForKey:attributes]; + } + NSString *uniqueId = NSStringFromSelector(@selector(uniqueId)); + if ([aDecoder containsValueForKey:uniqueId]) { + self.uniqueId = [aDecoder decodeObjectForKey:uniqueId]; + } + NSString *rawDataDic = NSStringFromSelector(@selector(rawDataDic)); + if ([aDecoder containsValueForKey:rawDataDic]) { + self.rawDataDic = [aDecoder decodeObjectForKey:rawDataDic]; + } + self.unique = [aDecoder decodeBoolForKey:NSStringFromSelector(@selector(unique))]; + self.transient = [aDecoder decodeBoolForKey:NSStringFromSelector(@selector(transient))]; + self.system = [aDecoder decodeBoolForKey:NSStringFromSelector(@selector(system))]; + self.temporary = [aDecoder decodeBoolForKey:NSStringFromSelector(@selector(temporary))]; + self.muted = [aDecoder decodeBoolForKey:NSStringFromSelector(@selector(muted))]; + self.temporaryTTL = [aDecoder decodeIntegerForKey:NSStringFromSelector(@selector(temporaryTTL))]; } return self; } - (void)encodeWithCoder:(NSCoder *)aCoder { + if (self.conversationId) { + [aCoder encodeObject:self.conversationId forKey:NSStringFromSelector(@selector(conversationId))]; + } + if (self.clientId) { + [aCoder encodeObject:self.clientId forKey:NSStringFromSelector(@selector(clientId))]; + } + if (self.creator) { + [aCoder encodeObject:self.creator forKey:NSStringFromSelector(@selector(creator))]; + } + if (self.createAt) { + [aCoder encodeObject:self.createAt forKey:NSStringFromSelector(@selector(createAt))]; + } + if (self.updateAt) { + [aCoder encodeObject:self.updateAt forKey:NSStringFromSelector(@selector(updateAt))]; + } + if (self.lastMessageAt) { + [aCoder encodeObject:self.lastMessageAt forKey:NSStringFromSelector(@selector(lastMessageAt))]; + } + if (self.lastDeliveredAt) { + [aCoder encodeObject:self.lastDeliveredAt forKey:NSStringFromSelector(@selector(lastDeliveredAt))]; + } + if (self.lastReadAt) { + [aCoder encodeObject:self.lastReadAt forKey:NSStringFromSelector(@selector(lastReadAt))]; + } + if (self.lastMessage) { + [aCoder encodeObject:self.lastMessage forKey:NSStringFromSelector(@selector(lastMessage))]; + } + if (self.name) { + [aCoder encodeObject:self.name forKey:NSStringFromSelector(@selector(name))]; + } + if (self.members) { + [aCoder encodeObject:self.members forKey:NSStringFromSelector(@selector(members))]; + } + if (self.attributes) { + [aCoder encodeObject:self.attributes forKey:NSStringFromSelector(@selector(attributes))]; + } + if (self.uniqueId) { + [aCoder encodeObject:self.uniqueId forKey:NSStringFromSelector(@selector(uniqueId))]; + } if (self.rawDataDic) { [aCoder encodeObject:self.rawDataDic forKey:NSStringFromSelector(@selector(rawDataDic))]; } + [aCoder encodeBool:self.unique forKey:NSStringFromSelector(@selector(unique))]; + [aCoder encodeBool:self.transient forKey:NSStringFromSelector(@selector(transient))]; + [aCoder encodeBool:self.system forKey:NSStringFromSelector(@selector(system))]; + [aCoder encodeBool:self.temporary forKey:NSStringFromSelector(@selector(temporary))]; + [aCoder encodeBool:self.muted forKey:NSStringFromSelector(@selector(muted))]; + [aCoder encodeInteger:self.temporaryTTL forKey:NSStringFromSelector(@selector(temporaryTTL))]; } @end diff --git a/AVOSCloud.podspec b/AVOSCloud.podspec index 2ca0aa6df..5798e380c 100644 --- a/AVOSCloud.podspec +++ b/AVOSCloud.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'AVOSCloud' - s.version = '11.4.4' + s.version = '11.4.5' s.homepage = 'https://leancloud.cn/' s.summary = 'LeanCloud Objective-C SDK' s.authors = 'LeanCloud' diff --git a/AVOSCloudIM.podspec b/AVOSCloudIM.podspec index 182718f72..3f7b2c743 100644 --- a/AVOSCloudIM.podspec +++ b/AVOSCloudIM.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'AVOSCloudIM' - s.version = '11.4.4' + s.version = '11.4.5' s.homepage = 'https://leancloud.cn/' s.summary = 'LeanCloud IM Objective-C SDK' s.authors = 'LeanCloud' diff --git a/AVOSCloudLiveQuery.podspec b/AVOSCloudLiveQuery.podspec index 7c2cd8399..a1ab051a9 100644 --- a/AVOSCloudLiveQuery.podspec +++ b/AVOSCloudLiveQuery.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'AVOSCloudLiveQuery' - s.version = '11.4.4' + s.version = '11.4.5' s.homepage = 'https://leancloud.cn/' s.summary = 'LeanCloud LiveQuery Objective-C SDK' s.authors = 'LeanCloud'