@@ -252,15 +252,25 @@ @implementation JMSGConversation (JMessage)
252252-(NSMutableDictionary *)conversationToDictionary {
253253 NSMutableDictionary *dict = [NSMutableDictionary dictionary ];
254254
255- if (self.conversationType == kJMSGConversationTypeSingle ) {
256- JMSGUser *user = self.target ;
257- dict[@" target" ] = [user userToDictionary ];
258- dict[@" conversationType" ] = @" single" ;
259-
260- } else {
261- JMSGGroup *group = self.target ;
262- dict[@" target" ] = [group groupToDictionary ];
263- dict[@" conversationType" ] = @" group" ;
255+ switch (self.conversationType ) {
256+ case kJMSGConversationTypeSingle :{
257+ JMSGUser *user = self.target ;
258+ dict[@" target" ] = [user userToDictionary ];
259+ dict[@" conversationType" ] = @" single" ;
260+ break ;
261+ }
262+ case kJMSGConversationTypeGroup :{
263+ JMSGGroup *group = self.target ;
264+ dict[@" target" ] = [group groupToDictionary ];
265+ dict[@" conversationType" ] = @" group" ;
266+ break ;
267+ }
268+ case kJMSGConversationTypeChatRoom :{
269+ JMSGChatRoom *chatRoom = self.target ;
270+ dict[@" target" ] = [chatRoom chatRoomToDictionary ];
271+ dict[@" conversationType" ] = @" chatRoom" ;
272+ break ;
273+ }
264274 }
265275
266276 dict[@" latestMessage" ] = [self .latestMessage messageToDictionary ];
@@ -355,12 +365,23 @@ - (NSMutableDictionary *)messageToDictionary {
355365 dict[@" extras" ] = self.content .extras ;
356366 }
357367
358- if (self.targetType == kJMSGConversationTypeSingle ) {
359- JMSGUser *user = self.target ;
360- dict[@" target" ] = [user userToDictionary ];
361- } else {
362- JMSGGroup *group = self.target ;
363- dict[@" target" ] = [group groupToDictionary ];
368+ switch (self.targetType ) {
369+ case kJMSGConversationTypeSingle : {
370+ JMSGUser *user = self.target ;
371+ dict[@" target" ] = [user userToDictionary ];
372+ break ;
373+ }
374+
375+ case kJMSGConversationTypeGroup :{
376+ JMSGGroup *group = self.target ;
377+ dict[@" target" ] = [group groupToDictionary ];
378+ break ;
379+ }
380+ case kJMSGConversationTypeChatRoom :{
381+ JMSGChatRoom *chatRoom= self.target ;
382+ dict[@" target" ] = [chatRoom chatRoomToDictionary ];
383+ break ;
384+ }
364385 }
365386
366387 dict[@" createTime" ] = self.timestamp ;
@@ -520,7 +541,7 @@ - (NSDictionary *)errorToDictionary {
520541@implementation JMSGChatRoom (JMessage)
521542- (NSMutableDictionary *)chatRoomToDictionary {
522543 NSMutableDictionary *dict = @{}.mutableCopy ;
523- dict[@" type" ] = @" chatroom " ;
544+ dict[@" type" ] = @" chatRoom " ;
524545 dict[@" roomId" ] = self.roomID ;
525546 dict[@" roomName" ] = self.name ;
526547 dict[@" appKey" ] = self.appkey ;
0 commit comments