EMMessageModel.m 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. //
  2. // EMMessageModel.m
  3. // ChatDemo-UI3.0
  4. //
  5. // Created by XieYajie on 2019/1/18.
  6. // Copyright © 2019 XieYajie. All rights reserved.
  7. //
  8. #import "EMMessageModel.h"
  9. @implementation EMMessageModel
  10. - (instancetype)initWithEMMessage:(EMMessage *)aMsg
  11. {
  12. self = [super init];
  13. if (self) {
  14. _emModel = aMsg;
  15. _direction = aMsg.direction;
  16. if (aMsg.body.type == EMMessageBodyTypeText) {
  17. if ([aMsg.ext objectForKey:MSG_EXT_GIF]) {
  18. _type = EMMessageTypeExtGif;
  19. } else if ([aMsg.ext objectForKey:MSG_EXT_RECALL]) {
  20. _type = EMMessageTypeExtRecall;
  21. } else {
  22. NSString *conferenceId = [aMsg.ext objectForKey:@"conferenceId"];
  23. if ([conferenceId length] == 0) {
  24. conferenceId = [aMsg.ext objectForKey:MSG_EXT_CALLID];
  25. }
  26. if ([conferenceId length] > 0) {
  27. _type = EMMessageTypeExtCall;
  28. } else {
  29. _type = EMMessageTypeText;
  30. }
  31. }
  32. if (aMsg.isNeedGroupAck) {
  33. _readReceiptCount = [NSString stringWithFormat:@"阅读回执,已读用户(%d)",aMsg.groupAckCount];
  34. }
  35. if(aMsg.isNeedGroupAck && aMsg.status == EMMessageStatusFailed) {
  36. _readReceiptCount = @"只有群主支持本格式消息";
  37. }
  38. } else {
  39. _type = (EMMessageType)aMsg.body.type;
  40. }
  41. }
  42. return self;
  43. }
  44. @end