Skip to content

Commit

Permalink
Merge pull request #531 from zapcannon87/master
Browse files Browse the repository at this point in the history
Release v11.4.5
  • Loading branch information
zapcannon87 authored Oct 24, 2018
2 parents 7559bfa + d15583d commit f29d4ea
Show file tree
Hide file tree
Showing 7 changed files with 237 additions and 17 deletions.
2 changes: 1 addition & 1 deletion AVOS/AVOSCloud/UserAgent.h
Original file line number Diff line number Diff line change
@@ -1 +1 @@
#define SDK_VERSION @"v11.4.4"
#define SDK_VERSION @"v11.4.5"
77 changes: 75 additions & 2 deletions AVOS/AVOSCloudIM/Client/AVIMClient.m
Original file line number Diff line number Diff line change
Expand Up @@ -1919,15 +1919,88 @@ - (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;
}
__block AVIMConversation *conv = nil;
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];
}
Expand Down
58 changes: 52 additions & 6 deletions AVOS/AVOSCloudIM/Conversation/AVIMConversation.m
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -337,11 +355,20 @@ - (void)removeMembers:(NSArray<NSString *> *)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
Expand Down Expand Up @@ -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;
}
Expand Down
111 changes: 106 additions & 5 deletions AVOS/AVOSCloudIM/Conversation/AVIMKeyedConversation.m
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion AVOSCloud.podspec
Original file line number Diff line number Diff line change
@@ -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'
Expand Down
2 changes: 1 addition & 1 deletion AVOSCloudIM.podspec
Original file line number Diff line number Diff line change
@@ -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'
Expand Down
2 changes: 1 addition & 1 deletion AVOSCloudLiveQuery.podspec
Original file line number Diff line number Diff line change
@@ -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'
Expand Down

0 comments on commit f29d4ea

Please sign in to comment.